cvs commit: src/lib/libutil pidfile.3

Bruce Evans bde at zeta.org.au
Fri Mar 3 03:05:59 PST 2006


On Fri, 3 Mar 2006, Ruslan Ermilov wrote:

> On Fri, Mar 03, 2006 at 04:43:09AM +0200, Giorgos Keramidas wrote:
>> On 2006-01-28 14:13, Pawel Jakub Dawidek <pjd at FreeBSD.org> wrote:
>>> pjd         2006-01-28 14:13:15 UTC
>>>
>>>   FreeBSD src repository
>>>
>>>   Modified files:
>>>     lib/libutil          pidfile.3
>>>   Log:
>>> ...
>>>   - Cast pid_t to int.
>> ...
>> Doesn't it make more sense to cast pid_t to intmax_t, or is it by
>> definition always <= int?
>>
> POSIX only requires that "blksize_t, pid_t, and ssize_t shall be signed
> integer types."

I always cast pid_t to long for printing.  This was correct before C99
broke the promise that long was the longest signed integer type.  In
practice, PID_MAX is 30000 in 4.4BSD, so casting to int was enough
even on systems with 16-bit ints.  FreeBSD changed PID_MAX to 99999
on 13 Nov 1998, but FreeBSD never supported any systems with 16-bit
ints, so casting to int has always worked on FreeBSD.  It is just
unportable.

pidfile.3 has other bad examples on the same line that the pid_t wasn't
cast on.  It capitalizes the first word in syslog messages and terminates
error messages with a ".".  Error messages are conventionally never
punctuated like this.  My /var/log/messages currently has 4641 lines and
only 96 of the lines are terminated with a ".".  These lines are for 32
copies of the same 3 kernel messages

%%%
Copyright (c) 1992-2004 The FreeBSD Project.
The Regents of the University of California. All rights reserved.
Preloaded elf kernel "kernel" at 0xc06a4c00.
%%%

Punctuating the copright message is OK since it is a multiline one with
almost real sentences, but puncting the "Preloaded" messages is just
a style bug.  All other bot messages in my /var/log/messages are missing
this bug.

Bruce


More information about the cvs-src mailing list