changeset 2951:8e5048c1f58e

PSARC 2006/510 Kstat Constification 6461778 kernel kstat routines should use constified char * Contributed by Garrett D'Amore <garrett_damore@tadpole.com>
author elowe
date Fri, 20 Oct 2006 07:42:03 -0700
parents 449abdd74783
children ecafc76e74a4
files usr/src/uts/common/fs/nfs/nfs_stats.c usr/src/uts/common/io/mac/mac_stat.c usr/src/uts/common/io/ppp/sppp/sppp.c usr/src/uts/common/io/ppp/spppcomp/spppcomp.c usr/src/uts/common/io/ppp/sppptun/sppptun.c usr/src/uts/common/ipp/ippconf.c usr/src/uts/common/os/errorq.c usr/src/uts/common/os/kstat_fr.c usr/src/uts/common/rpc/mt_rpcinit.c usr/src/uts/common/sys/kstat.h
diffstat 10 files changed, 54 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/nfs/nfs_stats.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/fs/nfs/nfs_stats.c	Fri Oct 20 07:42:03 2006 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -56,7 +55,7 @@
 
 	ks_data = kmem_alloc(template_size, KM_SLEEP);
 	bcopy(template, ks_data, template_size);
-	if ((ksp = kstat_create_zone((char *)module, vers, (char *)name, "misc",
+	if ((ksp = kstat_create_zone(module, vers, name, "misc",
 	    KSTAT_TYPE_NAMED, template_size / sizeof (kstat_named_t),
 	    KSTAT_FLAG_VIRTUAL | KSTAT_FLAG_WRITABLE, zoneid)) != NULL) {
 		ksp->ks_data = ks_data;
@@ -73,7 +72,7 @@
 nfsstat_zone_fini_common(zoneid_t zoneid, const char *module, int vers,
 			    const char *name)
 {
-	kstat_delete_byname_zone((char *)module, vers, (char *)name, zoneid);
+	kstat_delete_byname_zone(module, vers, name, zoneid);
 }
 
 /*
--- a/usr/src/uts/common/io/mac/mac_stat.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/io/mac/mac_stat.c	Fri Oct 20 07:42:03 2006 -0700
@@ -154,8 +154,8 @@
 	uint_t		count;
 
 	count = MAC_MOD_NKSTAT + MAC_NKSTAT + mip->mi_type->mt_statcount;
-	ksp = kstat_create((char *)mip->mi_drvname, mip->mi_instance,
-	    MAC_KSTAT_NAME, MAC_KSTAT_CLASS, KSTAT_TYPE_NAMED, count, 0);
+	ksp = kstat_create(mip->mi_drvname, mip->mi_instance, MAC_KSTAT_NAME,
+	    MAC_KSTAT_CLASS, KSTAT_TYPE_NAMED, count, 0);
 	if (ksp == NULL)
 		return;
 
--- a/usr/src/uts/common/io/ppp/sppp/sppp.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/io/ppp/sppp/sppp.c	Fri Oct 20 07:42:03 2006 -0700
@@ -1,7 +1,7 @@
 /*
  * sppp.c - Solaris STREAMS PPP multiplexing pseudo-driver
  *
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * Permission to use, copy, modify, and distribute this software and its
@@ -286,12 +286,12 @@
 	knt = (kstat_named_t *)ksp->ks_data;
 	for (cpp = kstats_names; cpp < kstats_names + Dim(kstats_names);
 	    cpp++) {
-		kstat_named_init(knt, (char *)*cpp, KSTAT_DATA_UINT32);
+		kstat_named_init(knt, *cpp, KSTAT_DATA_UINT32);
 		knt++;
 	}
 	for (cpp = kstats64_names; cpp < kstats64_names + Dim(kstats64_names);
 	    cpp++) {
-		kstat_named_init(knt, (char *)*cpp, KSTAT_DATA_UINT64);
+		kstat_named_init(knt, *cpp, KSTAT_DATA_UINT64);
 		knt++;
 	}
 	ksp->ks_update = sppp_kstat_update;
--- a/usr/src/uts/common/io/ppp/spppcomp/spppcomp.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/io/ppp/spppcomp/spppcomp.c	Fri Oct 20 07:42:03 2006 -0700
@@ -1,7 +1,7 @@
 /*
  * spppcomp.c - STREAMS module for kernel-level compression and CCP support.
  *
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * Permission to use, copy, modify, and distribute this software and its
@@ -1132,13 +1132,13 @@
 			knt = (kstat_named_t *)ksp->ks_data;
 			for (cpp = kstats_names;
 			    cpp < kstats_names + Dim(kstats_names); cpp++) {
-				kstat_named_init(knt, (char *)*cpp,
+				kstat_named_init(knt, *cpp,
 				    KSTAT_DATA_UINT32);
 				knt++;
 			}
 			for (cpp = kstats64_names;
 			    cpp < kstats64_names + Dim(kstats64_names); cpp++) {
-				kstat_named_init(knt, (char *)*cpp,
+				kstat_named_init(knt, *cpp,
 				    KSTAT_DATA_UINT64);
 				knt++;
 			}
--- a/usr/src/uts/common/io/ppp/sppptun/sppptun.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/io/ppp/sppptun/sppptun.c	Fri Oct 20 07:42:03 2006 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -455,11 +455,11 @@
 	int i;
 
 	for (i = 0; i < nstat; i++) {
-		kstat_set_string(knt[i].name, (char *)names[i]);
+		kstat_set_string(knt[i].name, names[i]);
 		knt[i].data_type = KSTAT_DATA_UINT64;
 	}
 	(void) sprintf(unitname, "%s%d", modname, unitnum);
-	ksp = kstat_create((char *)modname, unitnum, unitname, "net",
+	ksp = kstat_create(modname, unitnum, unitname, "net",
 	    KSTAT_TYPE_NAMED, nstat, KSTAT_FLAG_VIRTUAL);
 	if (ksp != NULL) {
 		ksp->ks_data = (void *)knt;
--- a/usr/src/uts/common/ipp/ippconf.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/ipp/ippconf.c	Fri Oct 20 07:42:03 2006 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1661,7 +1660,7 @@
 
 	DBG2(DBG_STATS, "creating stat set '%s' for action '%s'\n",
 	    name, class);
-	if ((ksp = kstat_create(modname, instance, (char *)name, class,
+	if ((ksp = kstat_create(modname, instance, name, class,
 	    KSTAT_TYPE_NAMED, nstat, KSTAT_FLAG_WRITABLE)) == NULL) {
 		kmem_free(sip, sizeof (ipp_stat_impl_t));
 		UNLOCK_ACTION(ap);
@@ -1802,7 +1801,7 @@
 	 */
 
 	DBG3(DBG_STATS, "%s.%s: knp = %p\n", sip->ippsi_name, name, np);
-	kstat_named_init(np, (char *)name, ktype);
+	kstat_named_init(np, name, ktype);
 	mutex_exit(sip->ippsi_lock);
 
 	return (0);
--- a/usr/src/uts/common/os/errorq.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/os/errorq.c	Fri Oct 20 07:42:03 2006 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -320,7 +319,7 @@
 		return (NULL);
 	}
 
-	if ((eqp->eq_ksp = kstat_create("unix", 0, (char *)name, "errorq",
+	if ((eqp->eq_ksp = kstat_create("unix", 0, name, "errorq",
 	    KSTAT_TYPE_NAMED, sizeof (struct errorq_kstat) /
 	    sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL)) == NULL) {
 		cmn_err(CE_WARN, "errorq_create: failed to create kstat "
--- a/usr/src/uts/common/os/kstat_fr.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/os/kstat_fr.c	Fri Oct 20 07:42:03 2006 -0700
@@ -413,7 +413,7 @@
 }
 
 kstat_t *
-kstat_hold_byname(char *ks_module, int ks_instance, char *ks_name,
+kstat_hold_byname(const char *ks_module, int ks_instance, const char *ks_name,
     zoneid_t ks_zoneid)
 {
 	ekstat_t e;
@@ -608,14 +608,14 @@
 }
 
 void
-kstat_set_string(char *dst, char *src)
+kstat_set_string(char *dst, const char *src)
 {
 	bzero(dst, KSTAT_STRLEN);
 	(void) strncpy(dst, src, KSTAT_STRLEN - 1);
 }
 
 void
-kstat_named_init(kstat_named_t *knp, char *name, uchar_t data_type)
+kstat_named_init(kstat_named_t *knp, const char *name, uchar_t data_type)
 {
 	kstat_set_string(knp->name, name);
 	knp->data_type = data_type;
@@ -625,7 +625,7 @@
 }
 
 void
-kstat_timer_init(kstat_timer_t *ktp, char *name)
+kstat_timer_init(kstat_timer_t *ktp, const char *name)
 {
 	kstat_set_string(ktp->name, name);
 }
@@ -917,8 +917,8 @@
 }
 
 kstat_t *
-kstat_create(char *ks_module, int ks_instance, char *ks_name, char *ks_class,
-    uchar_t ks_type, uint_t ks_ndata, uchar_t ks_flags)
+kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
+    const char *ks_class, uchar_t ks_type, uint_t ks_ndata, uchar_t ks_flags)
 {
 	return (kstat_create_zone(ks_module, ks_instance, ks_name, ks_class,
 		    ks_type, ks_ndata, ks_flags, ALL_ZONES));
@@ -931,8 +931,8 @@
  * kstat driver until kstat_install().
  */
 kstat_t *
-kstat_create_zone(char *ks_module, int ks_instance, char *ks_name,
-    char *ks_class, uchar_t ks_type, uint_t ks_ndata, uchar_t ks_flags,
+kstat_create_zone(const char *ks_module, int ks_instance, const char *ks_name,
+    const char *ks_class, uchar_t ks_type, uint_t ks_ndata, uchar_t ks_flags,
     zoneid_t ks_zoneid)
 {
 	size_t ks_data_size;
@@ -1277,8 +1277,8 @@
 }
 
 void
-kstat_delete_byname_zone(char *ks_module, int ks_instance, char *ks_name,
-    zoneid_t ks_zoneid)
+kstat_delete_byname_zone(const char *ks_module, int ks_instance,
+    const char *ks_name, zoneid_t ks_zoneid)
 {
 	kstat_t *ksp;
 
@@ -1290,7 +1290,7 @@
 }
 
 void
-kstat_delete_byname(char *ks_module, int ks_instance, char *ks_name)
+kstat_delete_byname(const char *ks_module, int ks_instance, const char *ks_name)
 {
 	kstat_delete_byname_zone(ks_module, ks_instance, ks_name, ALL_ZONES);
 }
--- a/usr/src/uts/common/rpc/mt_rpcinit.c	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/rpc/mt_rpcinit.c	Fri Oct 20 07:42:03 2006 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -73,7 +72,7 @@
  */
 	ks_data = kmem_alloc(template_size, KM_SLEEP);
 	bcopy(template, ks_data, template_size);
-	if ((ksp = kstat_create_zone((char *)module, 0, (char *)name, "rpc",
+	if ((ksp = kstat_create_zone(module, 0, name, "rpc",
 	    KSTAT_TYPE_NAMED, template_size / sizeof (kstat_named_t),
 	    KSTAT_FLAG_VIRTUAL | KSTAT_FLAG_WRITABLE, zoneid)) != NULL) {
 		ksp->ks_data = ks_data;
@@ -85,7 +84,7 @@
 void
 rpcstat_zone_fini_common(zoneid_t zoneid, const char *module, const char *name)
 {
-	kstat_delete_byname_zone((char *)module, 0, (char *)name, zoneid);
+	kstat_delete_byname_zone(module, 0, name, zoneid);
 }
 
 static void *
--- a/usr/src/uts/common/sys/kstat.h	Fri Oct 20 07:29:03 2006 -0700
+++ b/usr/src/uts/common/sys/kstat.h	Fri Oct 20 07:42:03 2006 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -783,18 +782,18 @@
  * thus making it seem like you were never gone.
  */
 
-extern kstat_t *kstat_create(char *, int, char *, char *, uchar_t,
-    uint_t, uchar_t);
-extern kstat_t *kstat_create_zone(char *, int, char *, char *, uchar_t,
-    uint_t, uchar_t, zoneid_t);
+extern kstat_t *kstat_create(const char *, int, const char *, const char *,
+    uchar_t, uint_t, uchar_t);
+extern kstat_t *kstat_create_zone(const char *, int, const char *,
+    const char *, uchar_t, uint_t, uchar_t, zoneid_t);
 extern void kstat_install(kstat_t *);
 extern void kstat_delete(kstat_t *);
 extern void kstat_named_setstr(kstat_named_t *knp, const char *src);
-extern void kstat_set_string(char *, char *);
-extern void kstat_delete_byname(char *, int, char *);
-extern void kstat_delete_byname_zone(char *, int, char *, zoneid_t);
-extern void kstat_named_init(kstat_named_t *, char *, uchar_t);
-extern void kstat_timer_init(kstat_timer_t *, char *);
+extern void kstat_set_string(char *, const char *);
+extern void kstat_delete_byname(const char *, int, const char *);
+extern void kstat_delete_byname_zone(const char *, int, const char *, zoneid_t);
+extern void kstat_named_init(kstat_named_t *, const char *, uchar_t);
+extern void kstat_timer_init(kstat_timer_t *, const char *);
 extern void kstat_waitq_enter(kstat_io_t *);
 extern void kstat_waitq_exit(kstat_io_t *);
 extern void kstat_runq_enter(kstat_io_t *);
@@ -809,7 +808,7 @@
 extern int kstat_zone_find(kstat_t *, zoneid_t);
 
 extern kstat_t *kstat_hold_bykid(kid_t kid, zoneid_t);
-extern kstat_t *kstat_hold_byname(char *, int, char *, zoneid_t);
+extern kstat_t *kstat_hold_byname(const char *, int, const char *, zoneid_t);
 extern void kstat_rele(kstat_t *);
 
 #endif	/* defined(_KERNEL) */