Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Aug 2001 02:15:50 -0700
From:      "Crist J. Clark" <cristjc@earthlink.net>
To:        Ruslan Ermilov <ru@FreeBSD.ORG>
Cc:        freebsd-audit@FreeBSD.ORG
Subject:   Re: syslogd(8) Hostname Upgrade
Message-ID:  <20010822021550.L313@blossom.cjclark.org>
In-Reply-To: <20010822115024.A23430@sunbay.com>; from ru@FreeBSD.ORG on Wed, Aug 22, 2001 at 11:50:24AM %2B0300
References:  <20010822013841.A76483@blossom.cjclark.org> <20010822115024.A23430@sunbay.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 22, 2001 at 11:50:24AM +0300, Ruslan Ermilov wrote:
> On Wed, Aug 22, 2001 at 01:38:41AM -0700, Crist J. Clark wrote:
> [...]
> > +	if (gethostname(LocalHostName, sizeof(LocalHostName)))
> 
> Check explicitly against -1.

Since, gethostname(3) says,

  RETURN VALUES
       If the call succeeds a value of 0 is returned.

I figured the safest way was to verify that the return value was zero
rather than look for a specific failure mode (of course, -1 is listed
as the only one).

> > +		err(EX_OSERR, "gethostname failed");
> 
> Add "()" after "gethostname".

'K.

> > +	if (signo && strcmp(oldLocalHostName, LocalHostName)) {
> 
> I'm always confused when seeing this.  IMHO, ``strcmp(...) != 0''
> is much better.

I had done it that way because earlier lines wrapped in un-pretty
ways. But I personally prefer,

	if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) {

For clarity too (and IIRC K&R recommend that style ;), and it fits on
one line.
-- 
Crist J. Clark                           cjclark@alum.mit.edu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




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