[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squid-cvs
Subject:    /bzr/squid3/trunk/ r12685: Polish: remove dead code added by rev.12670
From:       Amos Jeffries <squid3 () treenet ! co ! nz>
Date:       2013-02-14 3:42:26
Message-ID: 20130214034502.22529.qmail () squid-cache ! org
[Download RAW message or body]

--===============0194825527==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------
revno: 12685
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: trunk
timestamp: Wed 2013-02-13 20:42:26 -0700
message:
  Polish: remove dead code added by rev.12670
  
  Remove the do_free_filename hack which on most modern systems causes the
  extra if() code and local variable to be optimized out.
  
  Detected by Coverity Scan. Issue 980999.
modified:
  src/tools.cc

--===============0194825527==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; name="r12685.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

=== modified file 'src/tools.cc'
--- a/src/tools.cc	2013-02-12 01:35:25 +0000
+++ b/src/tools.cc	2013-02-14 03:42:26 +0000
@@ -130,7 +130,6 @@
 {
     FILE *fp = NULL;
     static char command[256];
-    bool do_free_filename=false;
 
     const mode_t prev_umask=umask(S_IRWXU);
 
@@ -143,7 +142,6 @@
     }
 #else
     char *filename;
-    do_free_filename=true;
     // XXX tempnam is obsolete since POSIX.2008-1
     // tmpfile is not an option, we want the created files to stick around
     if ((filename = tempnam(NULL, APP_SHORTNAME)) == NULL ||
@@ -166,8 +164,9 @@
     snprintf(command, 256, "%s %s < %s", Config.EmailProgram, Config.adminEmail, filename);
     if (system(command)) {}		/* XXX should avoid system(3) */
     unlink(filename);
-    if (do_free_filename)
-        xfree(filename);
+#if !HAVE_MKSTEMP
+    xfree(filename); // tempnam() requires us to free its allocation
+#endif
 }
 
 void


--===============0194825527==--
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic