]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - login/tst-utmp.c
iconv, localedef: avoid floating point rounding differences [BZ #24372]
[thirdparty/glibc.git] / login / tst-utmp.c
index a61b54305e7ae5c5bdce0b79039dd366e6df153b..ce48e8326ecc3a9c13a7e2b73ddc7c9aa8254424 100644 (file)
@@ -1,5 +1,5 @@
 /* Tests for UTMP functions.
-   Copyright (C) 1998-2013 Free Software Foundation, Inc.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998.
 
@@ -39,7 +39,7 @@
 #endif
 
 
-#if _HAVE_UT_TYPE || defined UTMPX
+#if defined UTMPX || _HAVE_UT_TYPE
 
 /* Prototype for our test function.  */
 static int do_test (int argc, char *argv[]);
@@ -62,20 +62,20 @@ do_prepare (int argc, char *argv[])
   size_t name_len;
 
   name_len = strlen (test_dir);
-  name = malloc (name_len + sizeof ("/utmpXXXXXX"));
+  name = xmalloc (name_len + sizeof ("/utmpXXXXXX"));
   mempcpy (mempcpy (name, test_dir, name_len),
           "/utmpXXXXXX", sizeof ("/utmpXXXXXX"));
-  add_temp_file (name);
 
   /* Open our test file.  */
   fd = mkstemp (name);
   if (fd == -1)
     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+  add_temp_file (name);
 }
 
 struct utmp entry[] =
 {
-#if _HAVE_UT_TV || defined UTMPX
+#if defined UTMPX || _HAVE_UT_TV
 #define UT(a)  .ut_tv = { .tv_sec = (a)}
 #else
 #define UT(a)  .ut_time = (a)
@@ -132,8 +132,8 @@ do_check (void)
   n = 0;
   while ((ut = getutent ()))
     {
-      if (n < num_entries &&
-         memcmp (ut, &entry[n], sizeof (struct utmp)))
+      if (n < num_entries
+         && memcmp (ut, &entry[n], sizeof (struct utmp)))
        {
          error (0, 0, "UTMP entry does not match");
          return 1;
@@ -160,14 +160,14 @@ simulate_login (const char *line, const char *user)
 
   for (n = 0; n < num_entries; n++)
     {
-      if (strcmp (line, entry[n].ut_line) == 0 ||
-         entry[n].ut_type == DEAD_PROCESS)
+      if (strcmp (line, entry[n].ut_line) == 0
+         || entry[n].ut_type == DEAD_PROCESS)
        {
          if (entry[n].ut_pid == DEAD_PROCESS)
            entry[n].ut_pid = (entry_pid += 27);
          entry[n].ut_type = USER_PROCESS;
          strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user));
-#if _HAVE_UT_TV - 0 || defined UTMPX
+#if defined UTMPX || _HAVE_UT_TV - 0
          entry[n].ut_tv.tv_sec = (entry_time += 1000);
 #else
           entry[n].ut_time = (entry_time += 1000);
@@ -201,7 +201,7 @@ simulate_logout (const char *line)
        {
          entry[n].ut_type = DEAD_PROCESS;
          strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user));
-#if _HAVE_UT_TV - 0 || defined UTMPX
+#if defined UTMPX || _HAVE_UT_TV - 0
           entry[n].ut_tv.tv_sec = (entry_time += 1000);
 #else
           entry[n].ut_time = (entry_time += 1000);