From dan@obluda.cz  Sun Sep 12 02:37:33 2004
Return-Path: <dan@obluda.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5259716A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 Sep 2004 02:37:33 +0000 (GMT)
Received: from kulesh.obluda.cz (kulesh.obluda.cz [193.179.22.243])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2F16643D45
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 Sep 2004 02:37:32 +0000 (GMT)
	(envelope-from dan@obluda.cz)
Received: from kulesh.obluda.cz (localhost.eunet.cz [127.0.0.1])
	by kulesh.obluda.cz (8.13.1/8.13.1) with ESMTP id i8C2bUPN007093
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 Sep 2004 04:37:30 +0200 (CEST)
	(envelope-from dan@obluda.cz)
Received: (from root@localhost)
	by kulesh.obluda.cz (8.13.1/8.13.1/Submit) id i8C2bUP3007092
	for FreeBSD-gnats-submit@freebsd.org; Sun, 12 Sep 2004 04:37:30 +0200 (CEST)
	(envelope-from dan@obluda.cz)
Message-Id: <200409120237.i8C2bUP3007092@kulesh.obluda.cz>
Date: Sun, 12 Sep 2004 04:37:30 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] cleanup of the usr.sbin/yp_mkdb code
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         71616
>Category:       bin
>Synopsis:       [patch] [nis] yp_mkdb(8): cleanup of the usr.sbin/yp_mkdb code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 12 02:40:23 GMT 2004
>Closed-Date:    
>Last-Modified:  Mon Dec 29 17:08:38 UTC 2008
>Originator:     Dan Lukes
>Release:        FreeBSD 5.3-BETA3 i386
>Organization:
Obludarium
>Environment:
System: FreeBSD kulesh.obluda.cz 5.3-BETA3 FreeBSD 5.3-BETA3 #8: Sun Sep 5 07:06:40 CEST 2004 dan@kulesh.obluda.cz:/usr/obj/usr/src/sys/Dan i386
$FreeBSD: src/usr.sbin/yp_mkdb/yp_mkdb.c,v 1.16 2003/05/03 21:06:41 obrien

>Description:
	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
>Fix:
*** 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
***************
*** 87,93 ****
  
  	key.data = NULL;
  	while (yp_next_record(dbp, &key, &data, 1, 1) == YP_TRUE)
! 		printf("%.*s %.*s\n", key.size,key.data,data.size,data.data);
  
  	(void)(dbp->close)(dbp);
  	return;
--- 87,94 ----
  
  	key.data = NULL;
  	while (yp_next_record(dbp, &key, &data, 1, 1) == YP_TRUE)
! 		printf("%.*s %.*s\n", key.size, (char *)key.data, 
! 		         data.size, (char *)data.data);
  
  	(void)(dbp->close)(dbp);
  	return;
***************
*** 218,224 ****
  
  	key.data = "YP_LAST_MODIFIED";
  	key.size = sizeof("YP_LAST_MODIFIED") - 1;
! 	snprintf(buf, sizeof(buf), "%lu", time(NULL));
  	data.data = (char *)&buf;
  	data.size = strlen(buf);
  	yp_put_record(dbp, &key, &data, 0);
--- 219,225 ----
  
  	key.data = "YP_LAST_MODIFIED";
  	key.size = sizeof("YP_LAST_MODIFIED") - 1;
! 	snprintf(buf, sizeof(buf), "%lu", (long unsigned int)time(NULL));
  	data.data = (char *)&buf;
  	data.size = strlen(buf);
  	yp_put_record(dbp, &key, &data, 0);
>Release-Note:
>Audit-Trail:

From: Giorgos Keramidas <keramida@freebsd.org>
To: Dan Lukes <dan@obluda.cz>
Cc: bug-followup@freebsd.org
Subject: Re: bin/71616: [PATCH] cleanup of the usr.sbin/yp_mkdb code
Date: Sun, 12 Sep 2004 21:23:45 +0300

 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
 

From: Giorgos Keramidas <keramida@freebsd.org>
To: Brooks Davis <brooks@one-eyed-alien.net>
Cc: bug-followup@freebsd.org
Subject: Re: bin/71616: [PATCH] cleanup of the usr.sbin/yp_mkdb code
Date: Mon, 13 Sep 2004 09:05:27 +0300

 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 :)
>Unformatted:
