cvs commit: src/usr.sbin/nologin nologin.c

Xin LI delphij at frontfree.net
Thu Jan 6 06:59:13 PST 2005


Hi, Paul,

On Thu, Jan 06, 2005 at 11:57:06AM +0000, Paul Richards wrote:
> On Thu, Jan 06, 2005 at 10:43:56AM +0000, Nik Clayton wrote:
> > On Tue, Jan 04, 2005 at 11:11:07PM +0000, Robert Watson wrote:
> > > On Tue, 4 Jan 2005, Maxime Henrion wrote:
> > > > I bet there is a reason behind this, but I'm totally puzzled at why you
> > > > would do such a thing.  It was much prettier and more "C" before.  Could
> > > > you shed some light on this please? 
> > > 
> > > I ran into exactly the same problem I assume Xin Li is now running into
> > > just a few days ago: gcc warns if argc and argv are unused in the main() 
> > > definition if they aren't referenced when running at higher WARNS levels. 
> > > I would argue this is a bug in gcc, since main() is part of an API calling
> > > convention, and it doesn't matter if the arguments are unused by the
> > > function -- they are still provided by the caller.  But then, I'm not a C
> > > expert, so maybe this opinion is the result of poor breeding? :-) 
> > 
> > What's wrong with (the perfectly legal):
> > 
> >    int
> >    main(void)
> >    {
> >    ...
> >    }
> > 
> > or does gcc complain about that too?
> 
> No it doesn't and it seems to me to be more correct than using a gcc macro.

__unused is a FreeBSD macro IIRC.

I have a rough statistic before committing the revision 1.6:

%find bin sbin usr.bin usr.sbin libexec -name '*.c' | xargs grep "main(" | grep :main | grep void | wc -l
       5
%find bin sbin usr.bin usr.sbin libexec -name '*.c' | xargs grep "main(" | grep :main | grep __unused | wc -l    
       9

My rationale of having main(void) is that both argc and argv are not
supposed to be used in any way in nologin(8), while main(void) is my
habit when dealing with these situations.  However, since there is
no written style guidelines about main(), with the above statistic
result, and I think Jacques has more experience on these issues, I
have accepted his suggestion.

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/cvs-all/attachments/20050106/c4dd2583/attachment.bin


More information about the cvs-all mailing list