Re: [PATCH tabled] server/server.c don't deref NULL on failed malloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/23/2010 10:07 AM, Pete Zaitcev wrote:
On Thu, 23 Sep 2010 13:03:15 +0200
Jim Meyering<jim@xxxxxxxxxxxx>  wrote:

Just noticed that sometimes tabled uses this idiom:
   if (!(key = malloc(klen + 1)))
and sometimes this:
   if ((key = malloc(klen + 1)) == NULL)
This time I used "... == NULL".

Er... The bang is Jeff's, which I try to follow always, but perhaps
one or two slipped due to opposing habit. IIRC pathtokey() was mine.
In fact tabled does not use assignments in conditions, dunno why
but it's a tradition.

I always considered assignments in conditionals as fragile and error-prone, and try to avoid them. However, I occasionally break my own rule, such as with fgets(3) or getopt(3) loops.

And, getting back on topic, I do prefer implicit rather than explicit testing for zero and non-zero... but that too is a "weak preference" where I won't complain much if somebody else does it.

Typically the general rule for any codebase is "try to look like the rest of the codebase."

	Jeff



--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux