public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nikolay dot zhuravlev at auriga dot ru" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/2764] New: Redundant check in the __utmpname() function
Date: Wed, 14 Jun 2006 07:49:00 -0000	[thread overview]
Message-ID: <20060614074902.2764.nikolay.zhuravlev@auriga.ru> (raw)

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.


             reply	other threads:[~2006-06-14  7:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14  7:49 nikolay dot zhuravlev at auriga dot ru [this message]
2006-08-14  3:58 ` [Bug libc/2764] " drepper at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060614074902.2764.nikolay.zhuravlev@auriga.ru \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).