From: Pádraig Brady Date: Sun, 5 Feb 2023 13:51:20 +0000 (+0000) Subject: build: uptime: avoid issues on systems without utmp.h X-Git-Tag: v9.2~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2984e47c789ebc39f55a3b1cb20b943de88eeedc;p=thirdparty%2Fcoreutils.git build: uptime: avoid issues on systems without utmp.h * src/uptime.c (print_uptime): Following gnulib commit 9041103 HAVE_UTMP_H will always be defined. Therefore key on whether the utmp.ut_type member is present. * boottime.m4 (GNULIB_BOOT_TIME): Assume utmp.h is present. --- diff --git a/m4/boottime.m4 b/m4/boottime.m4 index ac277e0f25..aa440ce1d7 100644 --- a/m4/boottime.m4 +++ b/m4/boottime.m4 @@ -27,7 +27,7 @@ AC_DEFUN([GNULIB_BOOT_TIME], [#if HAVE_SYS_PARAM_H #include #endif]]) - AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h]) + AC_CHECK_HEADERS_ONCE([utmpx.h OS.h]) AC_CACHE_CHECK( [whether we can get the system boot time], [gnulib_cv_have_boot_time], @@ -43,9 +43,8 @@ AC_DEFUN([GNULIB_BOOT_TIME], #endif #if HAVE_UTMPX_H # include -#elif HAVE_UTMP_H -# include #endif +#include #if HAVE_OS_H # include #endif diff --git a/src/uptime.c b/src/uptime.c index b1d9e96c34..061b85c166 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -102,7 +102,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this) } #endif -#if HAVE_UTMPX_H || HAVE_UTMP_H +#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE /* Loop through all the utmp entries we just read and count up the valid ones, also in the process possibly gleaning boottime. */ while (n--) @@ -179,7 +179,7 @@ uptime (char const *filename, int options) size_t n_users; STRUCT_UTMP *utmp_buf = NULL; -#if HAVE_UTMPX_H || HAVE_UTMP_H +#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE if (read_utmp (filename, &n_users, &utmp_buf, options) != 0) die (EXIT_FAILURE, errno, "%s", quotef (filename)); #endif