Advent4 patch, second try
stsp at stsp.name
Wed Sep 26 17:56:41 CEST 2007
On Wed, Sep 26, 2007 at 05:22:50PM +0200, Luis Javier Merino wrote:
> - if (sptr = strchr(username, '\n'))
> + if (sptr == strchr(username, '\n'))
> *sptr = '\0';
> It is customary to assign values to a variable inside an if condition
> if you intend to reuse the result of a function.
And it's lazy and stupid not to test the condition explicitely.
if ((sptr = strchr(username, '\n')) != NULL)
is easier to understand for humans and the same to the compiler.
Or simply avoid assigning inside a conditional statement altogether.
Even if just not to confuse newbies reading the code.
If you need to know tons of crazy idioms to read code,
it's not well written. This attiude leads to brain-damaged
stuff like using
*((char *) mempcpy (dst, src, n)) = '\0';
to copy a string.
> Aside from that, I wouldn't really lose time fixing warnings on code
> written for pre-ANSI compilers.
True, but at the same time these warnings are quite annoying.
http://stsp.name PGP Key: 0xF59D25F0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.dslinux.in-berlin.de/pipermail/dslinux-devel-dslinux.in-berlin.de/attachments/20070926/0667fc55/attachment.pgp
More information about the dslinux-devel