[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
readutmp: Fix for platforms without ut_type
From: |
Bruno Haible |
Subject: |
readutmp: Fix for platforms without ut_type |
Date: |
Tue, 15 Aug 2023 13:01:34 +0200 |
On OpenBSD, 'test-readutmp' prints two entries of type BOOT_TIME. The second
one should not be present, since it is only a fallback. The cause is that
have_boot_time always returns false.
This patch fixes it.
2023-08-15 Bruno Haible <bruno@clisp.org>
readutmp: Fix for platforms without ut_type (regression 2023-08-08).
* lib/readutmp.h (UT_TYPE_BOOT_TIME, UT_TYPE_USER_PROCESS): Don't use
UT_TYPE_EQ macro.
(IS_USER_PROCESS): Don't use UT_USER, UT_TYPE_NOT_DEFINED macros.
* lib/readutmp.c (IS_USER_PROCESS): Don't override.
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 7967db60a8..0173b7e0c1 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -67,7 +67,6 @@
#undef UT_PID
#undef UT_TYPE_EQ
#undef UT_TYPE_NOT_DEFINED
-#undef IS_USER_PROCESS
#undef UT_EXIT_E_TERMINATION
#undef UT_EXIT_E_EXIT
@@ -102,12 +101,6 @@
# define UT_TYPE_NOT_DEFINED 1
#endif
-/* Determines whether an entry *UT corresponds to a user process. */
-#define IS_USER_PROCESS(UT) \
- ((UT)->ut_user[0] \
- && (UT_TYPE_USER_PROCESS (UT) \
- || (UT_TYPE_NOT_DEFINED && (UT)->ut_ts.tv_sec != 0)))
-
#if HAVE_UTMPX_H
# if HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION
# define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.e_termination)
diff --git a/lib/readutmp.h b/lib/readutmp.h
index 3ddecf3727..fa30fa9a00 100644
--- a/lib/readutmp.h
+++ b/lib/readutmp.h
@@ -270,21 +270,19 @@ struct utmpx32
/* Macros that test (UT)->ut_type. */
#ifdef BOOT_TIME
-# define UT_TYPE_BOOT_TIME(UT) UT_TYPE_EQ (UT, BOOT_TIME)
+# define UT_TYPE_BOOT_TIME(UT) ((UT)->ut_type == BOOT_TIME)
#else
# define UT_TYPE_BOOT_TIME(UT) 0
#endif
#ifdef USER_PROCESS
-# define UT_TYPE_USER_PROCESS(UT) UT_TYPE_EQ (UT, USER_PROCESS)
+# define UT_TYPE_USER_PROCESS(UT) ((UT)->ut_type == USER_PROCESS)
#else
# define UT_TYPE_USER_PROCESS(UT) 0
#endif
/* Determines whether an entry *UT corresponds to a user process. */
#define IS_USER_PROCESS(UT) \
- (UT_USER (UT)[0] \
- && (UT_TYPE_USER_PROCESS (UT) \
- || (UT_TYPE_NOT_DEFINED && UT_TIME_MEMBER (UT) != 0)))
+ ((UT)->ut_user[0] && UT_TYPE_USER_PROCESS (UT))
/* Define if read_utmp is not just a dummy. */
#if READUTMP_USE_SYSTEMD || HAVE_UTMPX_H || HAVE_UTMP_H || defined __CYGWIN__
|| defined _WIN32
- readutmp: Fix for platforms without ut_type,
Bruno Haible <=