kern/68081: sys/time.h (lint fix)

Cyrille Lefevre cyrille.lefevre at laposte.net
Fri Jun 18 15:11:33 GMT 2004


>Number:         68081
>Category:       kern
>Synopsis:       sys/time.h (lint fix)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 18 15:10:24 GMT 2004
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list