This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/2764] New: Redundant check in the __utmpname() function


The innermost 'if' statement is redundant in the following code:

[login/utmpname.c]
<<<<
if (strcmp (file, __libc_utmp_file_name) != 0)
    {
      if (strcmp (file, default_file_name) == 0)
    {
      if (__libc_utmp_file_name != default_file_name)
        free ((char *) __libc_utmp_file_name);

      __libc_utmp_file_name = default_file_name;
    }
>>>>

If file is the same as the default one, but different from
the __libc_utmp_file_name, then, by definition,
__libc_utmp_file_name != default_file_name.
The patch is provided below.


Index: login/utmpname.c
===================================================================
RCS file: /cvs/glibc/libc/login/utmpname.c,v
retrieving revision 1.6
diff -u -r1.6 utmpname.c
--- login/utmpname.c    13 Mar 2002 05:09:36 -0000      1.6
+++ login/utmpname.c    14 Jun 2006 07:45:05 -0000
@@ -50,7 +50,6 @@
     {
       if (strcmp (file, default_file_name) == 0)
        {
-         if (__libc_utmp_file_name != default_file_name)
            free ((char *) __libc_utmp_file_name);

          __libc_utmp_file_name = default_file_name;

-- 
           Summary: Redundant check in the __utmpname() function
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: nikolay dot zhuravlev at auriga dot ru
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=2764

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]