Blame SOURCES/glibc-rh1505492-undef-54.patch

25845f
commit ccb729df47188874401c655dda8d47b55cddd3b7
25845f
Author: Joseph Myers <joseph@codesourcery.com>
25845f
Date:   Wed Aug 19 00:50:17 2015 +0000
25845f
25845f
    Fix -Wundef warnings in login/tst-utmp.c.
25845f
    
25845f
    To remove -Wno-error=undef, we need to fix the remaining cases where
25845f
    there are -Wundef warnings in the testsuite.  One of those places is
25845f
    in login/tst-utmp.c.
25845f
    
25845f
    When included from tst-utmpx.c, <utmpx.h> is included instead of
25845f
    <utmp.h>, meaning the _HAVE_UT_* macros are not defined.  The test is
25845f
    prepared for them not being defined, in that all the relevant
25845f
    conditionals also include "defined UTMPX".  However, they test the
25845f
    _HAVE_UT_* macros first, so resulting in -Wundef warnings.
25845f
    
25845f
    This patch does the minimal fix of swapping the || operands.  This is
25845f
    logically correct - avoiding checking a macro we know will not be
25845f
    defined in the case where it is not defined.  It won't fix such
25845f
    warnings for the case where the toplevel bits/utmp.h is used and most
25845f
    _HAVE_UT_* aren't defined at all even when <utmp.h> is included, but
25845f
    that case doesn't apply to any current glibc configuration.  Fixing it
25845f
    would also be tricky in that, while glibc itself consistently uses
25845f
    _HAVE_UT_* in ways that would work with 0 instead of undefined,
25845f
    external packages that use the macros expect defined / undefined
25845f
    instead of 1 / 0 (codesearch.debian.net shows uses by util-linux,
25845f
    python-utmp, libsys-utmp-perl).
25845f
    
25845f
    Tested for x86_64.
25845f
    
25845f
            * login/tst-utmp.c [_HAVE_UT_TYPE || defined UTMPX]: Change
25845f
            conditional to [defined UTMPX || _HAVE_UT_TYPE].
25845f
            [_HAVE_UT_TV || defined UTMPX]: Change conditional to [defined
25845f
            UTMPX || _HAVE_UT_TV].
25845f
            [_HAVE_UT_TV - 0 || defined UTMPX]: Change conditional to [defined
25845f
            UTMPX || _HAVE_UT_TV - 0].
25845f
25845f
diff --git a/login/tst-utmp.c b/login/tst-utmp.c
25845f
index 7cc39cb2b7ff2dba..84945934e249ca25 100644
25845f
--- a/login/tst-utmp.c
25845f
+++ b/login/tst-utmp.c
25845f
@@ -39,7 +39,7 @@
25845f
 #endif
25845f
 
25845f
 
25845f
-#if _HAVE_UT_TYPE || defined UTMPX
25845f
+#if defined UTMPX || _HAVE_UT_TYPE
25845f
 
25845f
 /* Prototype for our test function.  */
25845f
 static int do_test (int argc, char *argv[]);
25845f
@@ -75,7 +75,7 @@ do_prepare (int argc, char *argv[])
25845f
 
25845f
 struct utmp entry[] =
25845f
 {
25845f
-#if _HAVE_UT_TV || defined UTMPX
25845f
+#if defined UTMPX || _HAVE_UT_TV
25845f
 #define UT(a)  .ut_tv = { .tv_sec = (a)}
25845f
 #else
25845f
 #define UT(a)  .ut_time = (a)
25845f
@@ -167,7 +167,7 @@ simulate_login (const char *line, const char *user)
25845f
 	    entry[n].ut_pid = (entry_pid += 27);
25845f
 	  entry[n].ut_type = USER_PROCESS;
25845f
 	  strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user));
25845f
-#if _HAVE_UT_TV - 0 || defined UTMPX
25845f
+#if defined UTMPX || _HAVE_UT_TV - 0
25845f
 	  entry[n].ut_tv.tv_sec = (entry_time += 1000);
25845f
 #else
25845f
           entry[n].ut_time = (entry_time += 1000);
25845f
@@ -201,7 +201,7 @@ simulate_logout (const char *line)
25845f
 	{
25845f
 	  entry[n].ut_type = DEAD_PROCESS;
25845f
 	  strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user));
25845f
-#if _HAVE_UT_TV - 0 || defined UTMPX
25845f
+#if defined UTMPX || _HAVE_UT_TV - 0
25845f
           entry[n].ut_tv.tv_sec = (entry_time += 1000);
25845f
 #else
25845f
           entry[n].ut_time = (entry_time += 1000);