Bug 71616

Summary: [patch] [nis] yp_mkdb(8): cleanup of the usr.sbin/yp_mkdb code
Product: Base System Reporter: Dan Lukes <dan>
Component: binAssignee: Marcelo Araujo <araujo>
Status: Closed FIXED    
Severity: Affects Only Me CC: araujo
Priority: Normal    
Version: 5.3-BETA3   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Dan Lukes 2004-09-12 03:40:23 UTC
	There are more than 5000 warnings issued during "make buildworld".
Some of them are false positives, but some of them are sign of true errors.

	Nobody is upset by warnings due it's amount, so some errors remain
uncorrected.

	I want to cleanup the code-base from warnings, so warnings will
become "attention mark" again.

usr.sbin/yp_mkdb/yp_mkdb.c:90: warning: char format, void arg (arg 3)
usr.sbin/yp_mkdb/yp_mkdb.c:90: warning: char format, void arg (arg 5)
usr.sbin/yp_mkdb/yp_mkdb.c:221: warning: long unsigned int format, time_t arg (arg 4)
usr.sbin/yp_mkdb/yp_mkdb.c:221: warning: long unsigned int format, time_t arg (arg 4)

How-To-Repeat: 	N/A
Comment 1 Giorgos Keramidas freebsd_committer freebsd_triage 2004-09-12 19:23:45 UTC
On 2004-09-12 04:37, Dan Lukes <dan@obluda.cz> wrote:
> *** usr.sbin/yp_mkdb/yp_mkdb.c.ORIG	Sun Sep  5 18:54:07 2004
> --- usr.sbin/yp_mkdb/yp_mkdb.c	Sun Sep  5 19:01:20 2004
> [...]
> - 	snprintf(buf, sizeof(buf), "%lu", time(NULL));
> + 	snprintf(buf, sizeof(buf), "%lu", (long unsigned int)time(NULL));

Just a minor comment: An (unsigned long) cast should be fine here.

There's no need to add `int' and the ordering of long unsigned seems a bit
backwards -- most of the time I've seen it written with `unsigned' first.

- Giorgos
Comment 2 Giorgos Keramidas freebsd_committer freebsd_triage 2004-09-13 07:05:27 UTC
On 2004-09-12 16:40, Brooks Davis <brooks@one-eyed-alien.net> wrote:
> On Sun, Sep 12, 2004 at 08:10:55PM +0000, Giorgos Keramidas wrote:
> >  On 2004-09-12 04:37, Dan Lukes <dan@obluda.cz> wrote:
> >  > *** usr.sbin/yp_mkdb/yp_mkdb.c.ORIG	Sun Sep  5 18:54:07 2004
> >  > --- usr.sbin/yp_mkdb/yp_mkdb.c	Sun Sep  5 19:01:20 2004
> >  > [...]
> >  > - 	snprintf(buf, sizeof(buf), "%lu", time(NULL));
> >  > + 	snprintf(buf, sizeof(buf), "%lu", (long unsigned int)time(NULL));
> >
> >  Just a minor comment: An (unsigned long) cast should be fine here.
>
> Using unsigned here is actually bogus. time_t is a signed type
> in FreeBSD.  SUSv3 says "time_t and clock_t shall be integer or
> real-floating types."  In FreeBSD a cast an integer type is safe.
>
> Either long or intmax_t are decent choices today.

Hmmm, true.  I had forgotten about negative values of time_t that represent
dates before 1970.

Thanks :)
Comment 3 Marcelo Araujo freebsd_committer freebsd_triage 2015-10-02 09:15:36 UTC
It was fixed already in a different way. So this patch doesn't apply anymore.

Thanks to submit the patch.