Date: Mon, 25 Mar 2002 22:42:01 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: markm@FreeBSD.ORG Cc: audit@FreeBSD.ORG Subject: Re: src/lib __progname cleanup ; review please Message-ID: <20020325221929.W879-100000@gamplex.bde.org> In-Reply-To: <200203241926.g2OJQeER032292@greenpeace.grondar.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 24 Mar 2002 markm@FreeBSD.ORG wrote: > ... > Index: csu/i386/crt0.c > =================================================================== > RCS file: /home/ncvs/src/lib/csu/i386/crt0.c,v > retrieving revision 1.36 > diff -u -d -r1.36 crt0.c > --- csu/i386/crt0.c 27 Aug 1999 23:57:55 -0000 1.36 > +++ csu/i386/crt0.c 24 Mar 2002 17:54:05 -0000 > ... > @@ -89,7 +91,7 @@ > int _callmain(); > int errno; > static char empty[1]; > -char *__progname = empty; > +const char *__progname = empty; Why is the empty string spelled differently on i386's (aout case) only? > Index: csu/i386-elf/crt1.c > =================================================================== > RCS file: /home/ncvs/src/lib/csu/i386-elf/crt1.c,v > retrieving revision 1.6 > diff -u -d -r1.6 crt1.c > --- csu/i386-elf/crt1.c 27 Feb 2002 22:08:05 -0000 1.6 > +++ csu/i386-elf/crt1.c 24 Mar 2002 17:53:54 -0000 > ... > @@ -73,7 +74,7 @@ > env = argv + argc + 1; > environ = env; > if (argc > 0 && argv[0] != NULL) { > - char *s; > + const char *s; This change is missing in most places. You might fix the style bugs involving this line when changing it. > ... > Index: libc/gen/err.c > =================================================================== > RCS file: /home/ncvs/src/lib/libc/gen/err.c,v > retrieving revision 1.12 > diff -u -d -r1.12 err.c > --- libc/gen/err.c 22 Mar 2002 21:52:05 -0000 1.12 > +++ libc/gen/err.c 24 Mar 2002 13:42:26 -0000 > ... > @@ -110,7 +108,7 @@ > { > if (err_file == 0) > err_set_file((FILE *)0); > - fprintf(err_file, "%s: ", __progname); > + fprintf(err_file, "%s: ", getprogname()); A version of getprogname() that is not in the application namespace should be used, since some members of the err() family are called internally in libc. Similarly elsewhere. This is even more imporartant in Standard functions like malloc() and getopt(). > ... > Index: libc/gen/getprogname.c > =================================================================== > RCS file: /home/ncvs/src/lib/libc/gen/getprogname.c,v > retrieving revision 1.3 > diff -u -d -r1.3 getprogname.c > --- libc/gen/getprogname.c 1 Feb 2002 00:57:29 -0000 1.3 > +++ libc/gen/getprogname.c 24 Mar 2002 17:47:44 -0000 > @@ -3,7 +3,7 @@ > > #include <stdlib.h> > > -extern const char *__progname; > +#include "../include/libc_private.h" Bogus path. The path to libc_private.h is in CFLAGS, and every other include of libc_private.h in libc/gen depends on this. Similarly elsewhere. > Index: libc/include/libc_private.h > =================================================================== > RCS file: /home/ncvs/src/lib/libc/include/libc_private.h,v > retrieving revision 1.4 > diff -u -d -r1.4 libc_private.h > --- libc/include/libc_private.h 24 Jan 2001 13:00:08 -0000 1.4 > +++ libc/include/libc_private.h 24 Mar 2002 17:50:22 -0000 > @@ -63,4 +63,9 @@ > #define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) > #define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) > > +/* > + * Used in the C Run-Time startup > + */ Should be an English sentence in a non-block comment. > ... > Index: libc_r/uthread/uthread_spinlock.c > =================================================================== > RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_spinlock.c,v > retrieving revision 1.9 > diff -u -d -r1.9 uthread_spinlock.c > --- libc_r/uthread/uthread_spinlock.c 24 Jan 2001 13:03:36 -0000 1.9 > +++ libc_r/uthread/uthread_spinlock.c 24 Mar 2002 14:00:10 -0000 > ... > @@ -91,7 +91,7 @@ > cnt++; > if (cnt > 100) { > char str[256]; > - snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, curthread, lck, fname, lineno, lck->fname, lck->lineno); > + snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", getprogname(), curthread, lck, fname, lineno, lck->fname, lck->lineno); Disgustingly long line in both suce and output (old bug). Now longer than before. Similarly elsewhere. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020325221929.W879-100000>