From owner-freebsd-audit Tue May 1 22:12: 4 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id D882E37B43F for ; Tue, 1 May 2001 22:11:58 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA17617; Wed, 2 May 2001 15:11:53 +1000 Date: Wed, 2 May 2001 15:10:45 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Dima Dorfman Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: <20010502025322.114703E28@bazooka.unixfreak.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 1 May 2001, Dima Dorfman wrote: > Some time ago, kris sent a message to -arch asking for comments on the > inclusion of the getprogname and setprogname functions. These were > recently added to NetBSD. Responses to kris' query were generally > favorable. The message can be found here: > http://docs.FreeBSD.org/cgi/getmsg.cgi?fetch=234758+0+archive/2001/freebsd-arch/20010225.freebsd-arch > > Attached is a patch to implement these in FreeBSD. Obviously, there's > not much to implement since getprogname is a wrapper around a > `return', and setprogname is a stub. I think setprogname() should not be a stub. setproctitle() can be used to change the process's name, so why should setprogname() be weaker? Perhaps setproctitle() should affect __progname (or at least the result returned by getprogname()), and setprogname() shouldn't exist. > Please review and, if acceptable, commit it. > Index: include/stdlib.h > =================================================================== > RCS file: /st/src/FreeBSD/src/include/stdlib.h,v > retrieving revision 1.20 > diff -u -r1.20 stdlib.h > --- include/stdlib.h 2001/04/23 09:32:06 1.20 > +++ include/stdlib.h 2001/05/02 02:42:07 > @@ -157,6 +157,7 @@ > int daemon __P((int, int)); > char *devname __P((int, int)); > int getloadavg __P((double [], int)); > +const char *getprogname __P((void)); KNF strictly requires a tab after the first word. This is not very useful, but it is much easier for formatting programs to implement than putting a tab after the type, since it only requires lexical analysis. I think this prototype should be formatted as: const char * getprogname __P((void)); like all the other prototypes for all the other functions whose return type (name) is longer than 7. > Index: lib/libc/gen/Makefile.inc > =================================================================== > RCS file: /st/src/FreeBSD/src/lib/libc/gen/Makefile.inc,v > retrieving revision 1.77 > diff -u -r1.77 Makefile.inc > --- lib/libc/gen/Makefile.inc 2001/04/17 07:59:50 1.77 > +++ lib/libc/gen/Makefile.inc 2001/05/02 02:42:07 > @@ -22,7 +22,7 @@ > pause.c popen.c psignal.c pw_scan.c pwcache.c raise.c readdir.c rewinddir.c \ > posixshm.c \ > scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ > - setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ > + setdomainname.c sethostname.c setjmperr.c setmode.c setprogname.c setproctitle.c \ Line too long. > --- /dev/null Tue May 1 19:16:20 2001 > +++ lib/libc/gen/getprogname.c Tue May 1 19:41:55 2001 > @@ -0,0 +1,12 @@ > +/* > + * $FreeBSD$ > + */ Never put $FreeBSD$ in the copyright comment in *.c except in the kernel. It goes in an rcsid string. > + > +extern const char *__progname; /* Program name, from crt0 */ Similar formatting problems for the variable type and linkage. Wrong comment. The location of the instantiation of __progname is machine- dependent. It is in crt0 for i386-aout but is in crt1 for i386-elf. Missing punctuation in comment. > --- /dev/null Tue May 1 19:16:20 2001 > +++ lib/libc/gen/setprogname.c Tue May 1 19:42:05 2001 > @@ -0,0 +1,14 @@ > +/* > + * $FreeBSD$ > + */ As above. > + > +void > +setprogname(const char *progname) > +{ > + > + /* > + * In FreeBSD, the program name is set in crt0. This is just > + * a stub for programs that want to be more portable. > + */ See above. > + return; > +} Return before the closing brace in a function that returns void is redundant. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message