RFC: Two fields in kld_sym_lookup and nlist structures

Xin LI delphij at frontfree.net
Wed Jan 5 00:22:57 PST 2005


Dear folks,

While I was traversing our source tree, I found that kld_sym_lookup's
symname and nlist's n_name are defined as char *.  On the other hand,
it seems that the usual usage of them looks like:

	nlist[0].n_name = "foo";

Which generates warnings on higher warning levels, since "foo" is a
string constatnt, and n_name is supposed to be a variable char *.

Can we change these fields into const char *?  A preliminary patch
looks like:

Index: sys/sys/linker.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/linker.h,v
retrieving revision 1.39
diff -u -r1.39 linker.h
--- sys/sys/linker.h	27 Aug 2004 01:10:16 -0000	1.39
+++ sys/sys/linker.h	5 Jan 2005 07:46:03 -0000
@@ -270,7 +270,7 @@
 
 struct kld_sym_lookup {
     int		version;	/* set to sizeof(struct kld_sym_lookup) */
-    char	*symname;	/* Symbol name we are looking up */
+    const char	*symname;	/* Symbol name we are looking up */
     u_long	symvalue;
     size_t	symsize;
 };
Index: sys/sys/nlist_aout.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/nlist_aout.h,v
retrieving revision 1.11
diff -u -r1.11 nlist_aout.h
--- sys/sys/nlist_aout.h	7 Apr 2004 04:19:49 -0000	1.11
+++ sys/sys/nlist_aout.h	5 Jan 2005 07:56:06 -0000
@@ -51,11 +51,11 @@
 struct nlist {
 #ifdef _AOUT_INCLUDE_
 	union {
-		char *n_name;	/* symbol name (in memory) */
+		const char *n_name;	/* symbol name (in memory) */
 		long n_strx;	/* file string table offset (on disk) */
 	} n_un;
 #else
-	char *n_name;		/* symbol name (in memory) */
+	const char *n_name;		/* symbol name (in memory) */
 	int : 8 * (sizeof(long) > sizeof(char *) ?
 	    sizeof(long) - sizeof(char *) : sizeof(char *) - sizeof(long));
 #endif


Cheers,
-- 
Xin LI <delphij frontfree net>	http://www.delphij.net/
See complete headers for GPG key and other information.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20050105/bb9f7c87/attachment.bin


More information about the freebsd-arch mailing list