From 5c6b397ff191ce6fbc32f3629d5bee5c12d14c82 Mon Sep 17 00:00:00 2001 From: "Stephen J. Kiernan" Date: Thu, 22 Sep 2016 06:24:40 +0000 Subject: [PATCH] The getsecs() function is implemented in platform- and bootfw-specific files and, in a number of these places, there were problems with how they were declared. Some used int return instead of time_t. On some architectures the bit width of time_t did not naturally fit into an integer and could lead to some unexpected behavior. (For example, 32-bit ARM builds uses a 64-bit time_t.) Make sure the function prototypes always specify void for the argument list when they do not have any arguemnts, otherwise some compilers can complain about the prototype. Reported by: Kevin Zheng Reviewed by: sjg Approved by: sjg (mentor) Obtained from: Juniper Networks, Inc. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D7463 --- sys/boot/efi/libefi/time.c | 2 +- sys/boot/efi/libefi/time_event.c | 2 +- sys/boot/i386/libi386/pxe.c | 2 +- sys/boot/ofw/libofw/ofw_time.c | 4 ++-- sys/boot/powerpc/kboot/main.c | 4 ++-- sys/boot/powerpc/ps3/main.c | 6 +++--- sys/boot/uboot/lib/time.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/boot/efi/libefi/time.c b/sys/boot/efi/libefi/time.c index b73c8ccf2c9..99831e1cf1a 100644 --- a/sys/boot/efi/libefi/time.c +++ b/sys/boot/efi/libefi/time.c @@ -228,7 +228,7 @@ time(time_t *tloc) } time_t -getsecs() +getsecs(void) { return time(0); } diff --git a/sys/boot/efi/libefi/time_event.c b/sys/boot/efi/libefi/time_event.c index 370a73c0ede..f96f1d845f6 100644 --- a/sys/boot/efi/libefi/time_event.c +++ b/sys/boot/efi/libefi/time_event.c @@ -76,7 +76,7 @@ time(time_t *tloc) } time_t -getsecs() +getsecs(void) { return time(0); } diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c index 28046f3ba1d..f947ef6ddbe 100644 --- a/sys/boot/i386/libi386/pxe.c +++ b/sys/boot/i386/libi386/pxe.c @@ -586,7 +586,7 @@ bangpxe_call(int func) time_t -getsecs() +getsecs(void) { time_t n = 0; time(&n); diff --git a/sys/boot/ofw/libofw/ofw_time.c b/sys/boot/ofw/libofw/ofw_time.c index f53997dc059..d5ca271564d 100644 --- a/sys/boot/ofw/libofw/ofw_time.c +++ b/sys/boot/ofw/libofw/ofw_time.c @@ -41,8 +41,8 @@ time(time_t *tloc) return secs; } -int -getsecs() +time_t +getsecs(void) { time_t n = 0; time(&n); diff --git a/sys/boot/powerpc/kboot/main.c b/sys/boot/powerpc/kboot/main.c index ec5ba6b651a..50f63b11699 100644 --- a/sys/boot/powerpc/kboot/main.c +++ b/sys/boot/powerpc/kboot/main.c @@ -151,8 +151,8 @@ delay(int usecs) } while (t < ti + usecs); } -int -getsecs() +time_t +getsecs(void) { struct host_timeval tv; host_gettimeofday(&tv, NULL); diff --git a/sys/boot/powerpc/ps3/main.c b/sys/boot/powerpc/ps3/main.c index bb1fd84c4b7..bcfd7c9ef9a 100644 --- a/sys/boot/powerpc/ps3/main.c +++ b/sys/boot/powerpc/ps3/main.c @@ -179,10 +179,10 @@ delay(int usecs) tb = mftb(); } -int -getsecs() +time_t +getsecs(void) { - return ((mftb() - basetb)*ns_per_tick/1000000000); + return ((time_t)((mftb() - basetb)*ns_per_tick/1000000000)); } time_t diff --git a/sys/boot/uboot/lib/time.c b/sys/boot/uboot/lib/time.c index 9083675b75d..a3c73f471a2 100644 --- a/sys/boot/uboot/lib/time.c +++ b/sys/boot/uboot/lib/time.c @@ -47,7 +47,7 @@ time(time_t *tloc) return (secs); } -int +time_t getsecs(void) {