Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jan 2005 16:22:26 +0800
From:      Xin LI <delphij@frontfree.net>
To:        freebsd-arch@FreeBSD.org
Subject:   RFC: Two fields in kld_sym_lookup and nlist structures
Message-ID:  <20050105082226.GA1899@frontfree.net>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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.


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQFB26PC/cVsHxFZiIoRAjjVAJ0SZ4sE66b/NX9yAMwa05Ej2pOwTQCgiOh5
kfSW0HMfC2VtAQI2+oYJI+I=
=VPsU
-----END PGP SIGNATURE-----
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050105082226.GA1899>