This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 2764
  Redundant check in the __utmpname() function Last modified: 2006-08-14 03:58:41
     Query page      Enter new bug
Bug#: 2764   Hardware:   Reporter: Nikolay Zhuravlev <nikolay.zhuravlev@auriga.ru>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: Ulrich Drepper <drepper@redhat.com>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 2764 depends on: Show dependency tree
Show dependency graph
Bug 2764 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2006-06-14 07:49
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;

------- Additional Comment #1 From Ulrich Drepper 2006-08-14 03:58 -------
I changed this in CVS.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In