Re: [LTP] [PATCH 4/4] lib: add tst_res_r.c

chrubis
2014-02-19T15:19:46Z

Hi!
> > > random note: never never never use () with functions. always always
> > > always
> > > use (void). i'm guessing you're not aware, but what you've written here
> > > may>
> > > be called (warning free!) like so:
> > > get_tst_count(1, 2, 3);
> > >
> > > yes, even with -W -Wall -Wextra. please stamp this horrible habit out of
> > > your code.
> >
> > Thank you for explanation!
> > There is a trick to try g++ to compile the code, it will throw an error
> > on that and stops compilation.
>
> yeah, C++ fixed this historical wart of C. sorry for not clarifying.
>
> iiuc (and i could be wrong as i'm not old enough to have lived through it),
> this dates back to when C (ANSI?) didn't have prototypes. with a lot of code
> out there relying on the behavior, gcc never stopped accepting it.

That would be K&R C that dates back to UNIX days (at least from what
I've read about the history, haven't lived these days either).

> i wonder if we could argue for like a newer GNU standard to reject it.

That would be nice. Although there is a lot of code that dates back to
the old days, quite a lot of test in LTP as well so there is no way to
get this mandatory for existing projects, we simply have no manpower to
rewrite all the sources in a week or so. On the other way it would be
nice to instruct the compiler to abort on any new code that includes
old-style declarations.

--
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.