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

Paul Richards paul at originative.co.uk
Thu Jan 6 07:27:32 PST 2005


On Thu, Jan 06, 2005 at 10:58:43PM +0800, Xin LI wrote:
> 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.

Yes, though it maps to the __unused__ attribute to shut up gcc so
in this context it's the same :-)

> result, and I think Jacques has more experience on these issues, I

I guess he's the person to explain why we do this for main() then
since it doesn't make sense to me to do it when there are perfectly
valid C constructs that are more concise and portable.

-- 
Paul Richards


More information about the cvs-src mailing list