From cyrille.lefevre@laposte.net  Fri Jun 18 15:02:10 2004
Return-Path: <cyrille.lefevre@laposte.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3AB2516A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Jun 2004 15:02:10 +0000 (GMT)
Received: from ioskeha.hittite.isp.9tel.net (ioskeha.hittite.isp.9tel.net [62.62.156.27])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EAEED43D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Jun 2004 15:02:08 +0000 (GMT)
	(envelope-from cyrille.lefevre@laposte.net)
Received: from mail.gits.dyndns.org (unknown [80.119.175.57])
	by ioskeha.hittite.isp.9tel.net (Postfix) with ESMTP id 78E5C14BA78
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Jun 2004 17:03:36 +0200 (CEST)
Received: from gits.gits.invalid (IDENT:u4cextmt6fjrgf7t@localhost [127.0.0.1])
	by mail.gits.dyndns.org (8.12.11/8.12.11) with ESMTP id i5IF1D6E022222
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Jun 2004 17:01:14 +0200 (CEST)
	(envelope-from cyrille.lefevre@laposte.net)
Received: by gits.gits.invalid (tmda-sendmail, from uid 0);
	Fri, 18 Jun 2004 17:01:13 +0200 (CEST)
Message-Id: <20040618150109.GA4394@gits.dyndns.org>
Date: Fri, 18 Jun 2004 17:01:09 +0200
From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Reply-To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: sys/time.h (lint fix)
X-Send-Pr-Version: 3.113

>Number:         68081
>Category:       kern
>Synopsis:       [headers] [patch] sys/time.h (lint fix)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 18 15:10:24 GMT 2004
>Closed-Date:    Tue Jul 29 18:23:41 UTC 2008
>Last-Modified:  Tue Jul 29 18:23:41 UTC 2008
>Originator:     Cyrille Lefevre
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
ACME
>Environment:
System: FreeBSD gits 5.2-CURRENT FreeBSD 5.2-CURRENT #29: Mon May 31 01:35:59 CEST 2004 root@gits:/disk3/freebsd/current/obj/disk3/freebsd/current/src/sys/CUSTOM i386
>Description:
	see below.
>How-To-Repeat:
	cat << EOF > c.c
	#include <sys/time.h>
	EOF
	lint -cghapbx c.c
	time.h(112): warning: conversion from 'unsigned long long' may lose accuracy [132]
	time.h(129): warning: conversion from 'unsigned long long' may lose accuracy [132]
	time.h(136): warning: conversion from 'long' may lose accuracy [132]
	...
>Fix:
Index: time.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/time.h,v
retrieving revision 1.65
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.65 time.h
--- time.h	7 Apr 2004 04:19:49 -0000	1.65
+++ time.h	18 Jun 2004 14:54:36 -0000
@@ -109,7 +109,7 @@
 {
 
 	ts->tv_sec = bt->sec;
-	ts->tv_nsec = ((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32;
+	ts->tv_nsec = (uint32_t)(((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32);
 }
 
 static __inline void
@@ -126,14 +126,14 @@
 {
 
 	tv->tv_sec = bt->sec;
-	tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32;
+	tv->tv_usec = (uint32_t)(((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32);
 }
 
 static __inline void
 timeval2bintime(const struct timeval *tv, struct bintime *bt)
 {
 
-	bt->sec = tv->tv_sec;
+	bt->sec = (time_t)tv->tv_sec;
 	/* 18446744073709 = int(2^64 / 1000000) */
 	bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
 }
>Release-Note:
>Audit-Trail:

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: bug-followup@FreeBSD.org, cyrille.lefevre@laposte.net
Cc:  
Subject: Re: kern/68081: [headers] [patch] sys/time.h (lint fix)
Date: Fri, 20 Jun 2008 17:19:59 -0700

 Haven't used lint(1) before, but I don't think this is an issue (at
 least not on 8-CURRENT):
 Cheers,
 -Garrett
 
 [gcooper@optimus /devel/ncvs/src]$ lint time_test.c
 time_test.c:
 _types.h(60): warning: struct __timer never defined [233]
 _types.h(61): warning: struct __mq never defined [233]
 _pthreadtypes.h(44): warning: struct pthread never defined [233]
 _pthreadtypes.h(45): warning: struct pthread_attr never defined [233]
 _pthreadtypes.h(46): warning: struct pthread_cond never defined [233]
 _pthreadtypes.h(47): warning: struct pthread_cond_attr never defined [233]
 _pthreadtypes.h(48): warning: struct pthread_mutex never defined [233]
 _pthreadtypes.h(49): warning: struct pthread_mutex_attr never defined [233]
 _pthreadtypes.h(51): warning: struct pthread_rwlock never defined [233]
 _pthreadtypes.h(52): warning: struct pthread_rwlockattr never defined [233]
 _pthreadtypes.h(53): warning: struct pthread_barrier never defined [233]
 _pthreadtypes.h(54): warning: struct pthread_barrier_attr never defined [233]
 _pthreadtypes.h(55): warning: struct pthread_spinlock never defined [233]
 _pthreadtypes.h(75): warning: struct pthread_barrierattr never defined [233]
 time.h(59): warning: static function bintime_addx unused [236]
 time.h(70): warning: static function bintime_add unused [236]
 time.h(82): warning: static function bintime_sub unused [236]
 time.h(108): warning: static function bintime2timespec unused [236]
 time.h(116): warning: static function timespec2bintime unused [236]
 time.h(125): warning: static function bintime2timeval unused [236]
 time.h(133): warning: static function timeval2bintime unused [236]
 time.h(152): warning: struct sigevent never defined [233]
 lint: cannot find llib-lc.ln
 Lint pass2:
 
 [gcooper@optimus /devel/ncvs/src]$ cat time_test.c
 #include "sys/sys/time.h"

From: John Baldwin <jhb@FreeBSD.org>
To: bug-followup@FreeBSD.org, cyrille.lefevre@laposte.net
Cc:  
Subject: Re: kern/68081: [headers] [patch] sys/time.h (lint fix)
Date: Mon, 28 Jul 2008 17:27:38 -0400

 You have to use 'lint -a' in which case you get 2 of the warnings:
 
 > lint -a stupid.c
 stupid.c:
 time.h(112): warning: conversion from 'unsigned long long' may lose accuracy 
 [132]
 time.h(129): warning: conversion from 'unsigned long long' may lose accuracy 
 [132]
 _types.h(60): warning: struct __timer never defined [233]
 _types.h(61): warning: struct __mq never defined [233]
 ...
 
 However, I'm not sure it is worth adding casts to appease optional behavior of 
 lint when there is no actual bug.   (The number of micro-seconds in a partial 
 second is always going to fit into a 32-bit value.)
 
 -- 
 John Baldwin
State-Changed-From-To: open->closed 
State-Changed-By: jhb 
State-Changed-When: Tue Jul 29 18:12:55 UTC 2008 
State-Changed-Why:  
After bde's followup, we are going to leave time.h as it is.  If anything 
needs to be fixed it is lint.  gcc's static analysis is smart enough to 
see that the existing code is fine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=68081 
>Unformatted:
