bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Clang analyze on Win32


From: Ángel González
Subject: Re: [Bug-wget] Clang analyze on Win32
Date: Thu, 18 Jun 2015 00:24:28 +0200
User-agent: Thunderbird

On 17/06/15 22:31, Gisle Vanem wrote:
I'm trying to familiarize myself with clang and did a
quick 'clang-cl --analyze <MSVC-CFLAGS> <SOURCES>'. This is what
it revealed:

init.c(569,13) : warning: Value stored to 'home' during its initialization is never read
     char *home = home_dir ();
            ^~~~   ~~~~~~~~~~~

Makes sense since since:
   char *home = home_dir (); << line 569
   xfree (file);
   home = ws_mypath ();

Seems this last line should be dropped since home_dir() already
calls ws_mypath(). So I think this patch is in order:

--- a/init.c    2015-05-25 18:36:26 +0000
+++ b/init.c      2015-06-17 22:26:34 +0000
@@ -568,7 +568,6 @@
     {
       char *home = home_dir ();
       xfree (file);
-      home = ws_mypath ();
       if (home)
         {
           file = aprintf ("%s/wget.ini", home);

In that case, we could remove the whole #ifdef WINDOWS
block, as wgetrc_user_file_name() would have succeeded.

I think the patch should be:
diff --git a/src/init.c b/src/init.c
index a436ef2..027657b 100644
--- a/src/init.c
+++ b/src/init.c
@@ -566,9 +566,7 @@ wgetrc_file_name (void)
      SYSTEM_WGETRC should not be defined under WINDOWS.  */
   if (!file)
     {
-      char *home = home_dir ();
-      xfree (file);
-      home = ws_mypath ();
+      char *home = ws_mypath ();
       if (home)
         {
           file = aprintf ("%s/wget.ini", home);

in order to take into account the case where we are in Windows and
HOME is defined but to a folder with no .wgetrc, which seems to be
the desire.

[I'm also removing the xfree (file); since we're inside if (!file)]

Thanks for the notice, Gisle




reply via email to

[Prev in Thread] Current Thread [Next in Thread]