[Openvpn-devel,2/3] windows: define variable only where used

Message ID 20210501130640.9330-3-a@unstable.cc
State Accepted
Headers show
Series windows: kill a couple of warnings | expand

Commit Message

Antonio Quartulli May 1, 2021, 3:06 a.m. UTC
From: Antonio Quartulli <antonio@openvpn.net>

warn_used is a static variable but that is used only under certain
conditions. These conditions do not apply for Windows and therefore
mingw is spitting a warning for unused variable.

Move variable declaration inside code block that uses it.

Fixes:

run_command.c: In function ‘openvpn_popen’:
run_command.c:236:17: warning: unused variable ‘warn_shown’ [-Wunused-variable]
  236 |     static bool warn_shown = false;
      |                 ^~~~~~~~~~

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
---
 src/openvpn/run_command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arne Schwabe May 2, 2021, 2:14 a.m. UTC | #1
Am 01.05.21 um 15:06 schrieb Antonio Quartulli:
> From: Antonio Quartulli <antonio@openvpn.net>
> 
> warn_used is a static variable but that is used only under certain
> conditions. These conditions do not apply for Windows and therefore
> mingw is spitting a warning for unused variable.
> 
> Move variable declaration inside code block that uses it.
> 
> Fixes:
> 
> run_command.c: In function ‘openvpn_popen’:
> run_command.c:236:17: warning: unused variable ‘warn_shown’ [-Wunused-variable]
>   236 |     static bool warn_shown = false;
>       |                 ^~~~~~~~~~
> 
> Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
> ---
>  src/openvpn/run_command.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/run_command.c b/src/openvpn/run_command.c
> index 34f95c5c..650876c1 100644
> --- a/src/openvpn/run_command.c
> +++ b/src/openvpn/run_command.c
> @@ -233,11 +233,11 @@ openvpn_popen(const struct argv *a,  const struct env_set *es)
>  {
>      struct gc_arena gc = gc_new();
>      int ret = -1;
> -    static bool warn_shown = false;
>  
>      if (a && a->argv[0])
>      {
>  #if defined(ENABLE_FEATURE_EXECVE)
> +        static bool warn_shown = false;
>          if (script_security() >= SSEC_BUILT_IN)
>          {
>              const char *cmd = a->argv[0];
> 

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering May 2, 2021, 10:40 a.m. UTC | #2
Your patch has been applied to the master branch.

commit 00c36948297654d93174aed1f8244e6e6734e141
Author: Antonio Quartulli
Date:   Sat May 1 15:06:39 2021 +0200

     windows: define variable only where used

     Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20210501130640.9330-3-a@unstable.cc>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22265.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/run_command.c b/src/openvpn/run_command.c
index 34f95c5c..650876c1 100644
--- a/src/openvpn/run_command.c
+++ b/src/openvpn/run_command.c
@@ -233,11 +233,11 @@  openvpn_popen(const struct argv *a,  const struct env_set *es)
 {
     struct gc_arena gc = gc_new();
     int ret = -1;
-    static bool warn_shown = false;
 
     if (a && a->argv[0])
     {
 #if defined(ENABLE_FEATURE_EXECVE)
+        static bool warn_shown = false;
         if (script_security() >= SSEC_BUILT_IN)
         {
             const char *cmd = a->argv[0];