hail-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: Jim Meyering <jim@meyering.net>,
	Project Hail <hail-devel@vger.kernel.org>
Subject: Re: [PATCH tabled] server/server.c don't deref NULL on failed malloc
Date: Thu, 23 Sep 2010 15:41:08 -0400	[thread overview]
Message-ID: <4C9BAD54.30303@garzik.org> (raw)
In-Reply-To: <20100923080710.22d3f6e4@lembas.zaitcev.lan>

On 09/23/2010 10:07 AM, Pete Zaitcev wrote:
> On Thu, 23 Sep 2010 13:03:15 +0200
> Jim Meyering<jim@meyering.net>  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



      reply	other threads:[~2010-09-23 19:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 11:03 [PATCH tabled] server/server.c don't deref NULL on failed malloc Jim Meyering
2010-09-23 14:07 ` Pete Zaitcev
2010-09-23 19:41   ` Jeff Garzik [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C9BAD54.30303@garzik.org \
    --to=jeff@garzik.org \
    --cc=hail-devel@vger.kernel.org \
    --cc=jim@meyering.net \
    --cc=zaitcev@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).