Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Oct 2003 22:32:37 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        ertr1013@student.uu.se
Cc:        cvs-src@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libc/rpc clnt_simple.c
Message-ID:  <20031029.223237.01027561.imp@bsdimp.com>
In-Reply-To: <20031029101805.GA24695@falcon.midgard.homeip.net>
References:  <200310290918.h9T9IiwQ095857@repoman.freebsd.org> <20031029095700.GU84474@garage.freebsd.pl> <20031029101805.GA24695@falcon.midgard.homeip.net>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20031029101805.GA24695@falcon.midgard.homeip.net>
            Erik Trulsson <ertr1013@student.uu.se> writes:
: On Wed, Oct 29, 2003 at 10:57:00AM +0100, Pawel Jakub Dawidek wrote:
: > On Wed, Oct 29, 2003 at 01:18:44AM -0800, Martin Blapp wrote:
: > +>   Commiter:	Martin Blapp <mbr@FreeBSD.org>
: > 
: > Hi Martin!:)
: > 
: > +>   Log:
: > +>   Don't use NULL to compare against a character.
: > [...]
: > +> -	if ((nettype == NULL) || (nettype[0] == NULL))
: > +> +	if ((nettype == NULL) || (nettype[0] == 0))
: > 
: > More correct is to use '\0' for characters comparsion.
: 
: No, not *more* correct.  '\0' and 0 are both constants with type "int"
: and value zero, so they can be used interchangeably.
: For stylistic reasons one might wish to use '\0' instead of 0 for
: character comparisons, but the the C language does not make a
: difference.

Yes.  More correct.  For the same reason that

      while (foo) {
      ...
      }

is more correct than:

top:
	if (foo) goto out;
	...
	goto top;
out:

In that it is the more appropriate construct to use in the context.
Even though they are both guaranteed to be the same, one is more
correct than the other.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031029.223237.01027561.imp>