]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp: Make argument names consistent.
authorBruno Haible <bruno@clisp.org>
Mon, 31 Jul 2023 14:29:46 +0000 (16:29 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 31 Jul 2023 14:29:46 +0000 (16:29 +0200)
* lib/readutmp.h (UT_TIME_MEMBER, UT_EXIT_E_TERMINATION, UT_EXIT_E_EXIT,
UT_USER, UT_PID, UT_TYPE_EQ, UT_TYPE_BOOT_TIME, UT_TYPE_USER_PROCESS,
IS_USER_PROCESS): Rename parameter to 'UT'.
* lib/readutmp.c (desirable_utmp_entry, read_utmp): Rename local
variable 'u' to 'ut'.

ChangeLog
lib/readutmp.c
lib/readutmp.h

index d3bc0c13aeeccb6efaf1676c6e23b434aa71f8fc..a26958d8b8f28ac60d055c1a284a1d7a18097de5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-07-31  Bruno Haible  <bruno@clisp.org>
+
+       readutmp: Make argument names consistent.
+       * lib/readutmp.h (UT_TIME_MEMBER, UT_EXIT_E_TERMINATION, UT_EXIT_E_EXIT,
+       UT_USER, UT_PID, UT_TYPE_EQ, UT_TYPE_BOOT_TIME, UT_TYPE_USER_PROCESS,
+       IS_USER_PROCESS): Rename parameter to 'UT'.
+       * lib/readutmp.c (desirable_utmp_entry, read_utmp): Rename local
+       variable 'u' to 'ut'.
+
 2023-07-31  Bruno Haible  <bruno@clisp.org>
 
        readutmp: Make the header file and function usable on all platforms.
index af43d1ad6b618c4eed2520aa165b246c3045fb18..82dbe69506d0095f97871c7377517aead99a4a53 100644 (file)
@@ -63,18 +63,18 @@ extract_trimmed_name (const STRUCT_UTMP *ut)
 
 #if READ_UTMP_SUPPORTED
 
-/* Is the utmp entry U desired by the user who asked for OPTIONS?  */
+/* Is the utmp entry UT desired by the user who asked for OPTIONS?  */
 
 static bool
-desirable_utmp_entry (STRUCT_UTMP const *u, int options)
+desirable_utmp_entry (STRUCT_UTMP const *ut, int options)
 {
-  bool user_proc = IS_USER_PROCESS (u);
+  bool user_proc = IS_USER_PROCESS (ut);
   if ((options & READ_UTMP_USER_PROCESS) && !user_proc)
     return false;
   if ((options & READ_UTMP_CHECK_PIDS)
       && user_proc
-      && 0 < UT_PID (u)
-      && (kill (UT_PID (u), 0) < 0 && errno == ESRCH))
+      && 0 < UT_PID (ut)
+      && (kill (UT_PID (ut), 0) < 0 && errno == ESRCH))
     return false;
   return true;
 }
@@ -133,7 +133,7 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
   idx_t n_read = 0;
   idx_t n_alloc = 0;
   STRUCT_UTMP *utmp = NULL;
-  STRUCT_UTMP *u;
+  STRUCT_UTMP *ut;
 
   /* Ignore the return value for now.
      Solaris' utmpname returns 1 upon success -- which is contrary
@@ -143,13 +143,13 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,
 
   SET_UTMP_ENT ();
 
-  while ((u = GET_UTMP_ENT ()) != NULL)
-    if (desirable_utmp_entry (u, options))
+  while ((ut = GET_UTMP_ENT ()) != NULL)
+    if (desirable_utmp_entry (ut, options))
       {
         if (n_read == n_alloc)
           utmp = xpalloc (utmp, &n_alloc, 1, -1, sizeof *utmp);
 
-        copy_utmp_entry (&utmp[n_read++], u);
+        copy_utmp_entry (&utmp[n_read++], ut);
       }
 
   END_UTMP_ENT ();
index d710699525e965dbed1ebf78df1d555579c80255..0ddd724c22fd311a995f1c6d8eb4c67ff9f41a3f 100644 (file)
@@ -50,7 +50,7 @@
 #  endif
 #  include <utmpx.h>
 #  define UTMP_STRUCT_NAME utmpx
-#  define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
+#  define UT_TIME_MEMBER(UT) ((UT)->ut_tv.tv_sec)
 #  define SET_UTMP_ENT setutxent
 #  define GET_UTMP_ENT getutxent
 #  define END_UTMP_ENT endutxent
 #  endif
 
 #  if HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION
-#   define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.e_termination)
+#   define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.e_termination)
 #  else
 #   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_TERMINATION
-#    define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.ut_termination)
+#    define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.ut_termination)
 #   else
-#    define UT_EXIT_E_TERMINATION(U) 0
+#    define UT_EXIT_E_TERMINATION(UT) 0
 #   endif
 #  endif
 
 #  if HAVE_STRUCT_UTMPX_UT_EXIT_E_EXIT
-#   define UT_EXIT_E_EXIT(U) ((U)->ut_exit.e_exit)
+#   define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.e_exit)
 #  else
 #   if HAVE_STRUCT_UTMPX_UT_EXIT_UT_EXIT
-#    define UT_EXIT_E_EXIT(U) ((U)->ut_exit.ut_exit)
+#    define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.ut_exit)
 #   else
-#    define UT_EXIT_E_EXIT(U) 0
+#    define UT_EXIT_E_EXIT(UT) 0
 #   endif
 #  endif
 
@@ -87,7 +87,7 @@
     struct utmp *getutent (void);
 #  endif
 #  define UTMP_STRUCT_NAME utmp
-#  define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
+#  define UT_TIME_MEMBER(UT) ((UT)->ut_time)
 #  define SET_UTMP_ENT setutent
 #  define GET_UTMP_ENT getutent
 #  define END_UTMP_ENT endutent
 #  endif
 
 #  if HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION
-#   define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.e_termination)
+#   define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.e_termination)
 #  else
 #   if HAVE_STRUCT_UTMP_UT_EXIT_UT_TERMINATION
-#    define UT_EXIT_E_TERMINATION(U) ((U)->ut_exit.ut_termination)
+#    define UT_EXIT_E_TERMINATION(UT) ((UT)->ut_exit.ut_termination)
 #   else
-#    define UT_EXIT_E_TERMINATION(U) 0
+#    define UT_EXIT_E_TERMINATION(UT) 0
 #   endif
 #  endif
 
 #  if HAVE_STRUCT_UTMP_UT_EXIT_E_EXIT
-#   define UT_EXIT_E_EXIT(U) ((U)->ut_exit.e_exit)
+#   define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.e_exit)
 #  else
 #   if HAVE_STRUCT_UTMP_UT_EXIT_UT_EXIT
-#    define UT_EXIT_E_EXIT(U) ((U)->ut_exit.ut_exit)
+#    define UT_EXIT_E_EXIT(UT) ((UT)->ut_exit.ut_exit)
 #   else
-#    define UT_EXIT_E_EXIT(U) 0
+#    define UT_EXIT_E_EXIT(UT) 0
 #   endif
 #  endif
 
@@ -129,9 +129,9 @@ struct gl_utmp
   struct timeval ut_tv;
 };
 #  define UTMP_STRUCT_NAME gl_utmp
-#  define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
-#  define UT_EXIT_E_TERMINATION(U) 0
-#  define UT_EXIT_E_EXIT(U) 0
+#  define UT_TIME_MEMBER(UT) ((UT)->ut_tv.tv_sec)
+#  define UT_EXIT_E_TERMINATION(UT) 0
+#  define UT_EXIT_E_EXIT(UT) 0
 
 # endif
 
@@ -139,26 +139,26 @@ struct gl_utmp
 # if HAVE_UTMPX_H
 
 #  if HAVE_STRUCT_UTMPX_UT_USER
-#   define UT_USER(Utmp) ((Utmp)->ut_user)
+#   define UT_USER(UT) ((UT)->ut_user)
 #  endif
 #  if HAVE_STRUCT_UTMPX_UT_NAME
 #   undef UT_USER
-#   define UT_USER(Utmp) ((Utmp)->ut_name)
+#   define UT_USER(UT) ((UT)->ut_name)
 #  endif
 
 # elif HAVE_UTMP_H
 
 #  if HAVE_STRUCT_UTMP_UT_USER
-#   define UT_USER(Utmp) ((Utmp)->ut_user)
+#   define UT_USER(UT) ((UT)->ut_user)
 #  endif
 #  if HAVE_STRUCT_UTMP_UT_NAME
 #   undef UT_USER
-#   define UT_USER(Utmp) ((Utmp)->ut_name)
+#   define UT_USER(UT) ((UT)->ut_name)
 #  endif
 
 # else /* dummy fallback */
 
-#  define UT_USER(Utmp) ((Utmp)->ut_user)
+#  define UT_USER(UT) ((UT)->ut_user)
 
 # endif
 
@@ -210,38 +210,38 @@ enum { UT_USER_SIZE = sizeof UT_USER ((STRUCT_UTMP *) 0) };
 
 /* Accessor macro for the member named ut_pid.  */
 # if HAVE_STRUCT_XTMP_UT_PID
-#  define UT_PID(U) ((U)->ut_pid)
+#  define UT_PID(UT) ((UT)->ut_pid)
 # else
-#  define UT_PID(U) 0
+#  define UT_PID(UT) 0
 # endif
 
 /* Accessor macros for the member named ut_type.  */
 
 # if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE
-#  define UT_TYPE_EQ(U, V) ((U)->ut_type == (V))
+#  define UT_TYPE_EQ(UT, V) ((UT)->ut_type == (V))
 #  define UT_TYPE_NOT_DEFINED 0
 # else
-#  define UT_TYPE_EQ(U, V) 0
+#  define UT_TYPE_EQ(UT, V) 0
 #  define UT_TYPE_NOT_DEFINED 1
 # endif
 
 # ifdef BOOT_TIME
-#  define UT_TYPE_BOOT_TIME(U) UT_TYPE_EQ (U, BOOT_TIME)
+#  define UT_TYPE_BOOT_TIME(UT) UT_TYPE_EQ (UT, BOOT_TIME)
 # else
-#  define UT_TYPE_BOOT_TIME(U) 0
+#  define UT_TYPE_BOOT_TIME(UT) 0
 # endif
 
 # ifdef USER_PROCESS
-#  define UT_TYPE_USER_PROCESS(U) UT_TYPE_EQ (U, USER_PROCESS)
+#  define UT_TYPE_USER_PROCESS(UT) UT_TYPE_EQ (UT, USER_PROCESS)
 # else
-#  define UT_TYPE_USER_PROCESS(U) 0
+#  define UT_TYPE_USER_PROCESS(UT) 0
 # endif
 
-/* Determines whether an entry *U corresponds to a user process.  */
-# define IS_USER_PROCESS(U                                    \
-   (UT_USER (U)[0]                                              \
-    && (UT_TYPE_USER_PROCESS (U                               \
-        || (UT_TYPE_NOT_DEFINED && UT_TIME_MEMBER (U) != 0)))
+/* 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)))
 
 /* Define if read_utmp is not just a dummy.  */
 # if HAVE_UTMPX_H || HAVE_UTMP_H