Skip to contentSkip to conversation

use boolean '||' to join two bools, not bitwise '|'

PATCH In review Gert Doering 2 participants 3 messages Oct 4, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use boolean '||' to join two bools, not bitwise '|'

FreeBSD 14 clang complains about this:

init.c:3530:13: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]

            platform_group_get(c->options.groupname, &c0->platform_state_group)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

init.c:3530:13: note: cast one or both operands to int to silence this warning 1 warning generated.

.. so do what it wants us to do.

---
 src/openvpn/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/init.c +1 -1
index 03416844..c88c0915 100644
@@ -3528,7 +3528,7 @@ do_init_first_time(struct context *c)
         /* get user and/or group that we want to setuid/setgid to */
         c0->uid_gid_specified =
             platform_group_get(c->options.groupname, &c0->platform_state_group)
-            |platform_user_get(c->options.username, &c0->platform_state_user);
+            || platform_user_get(c->options.username, &c0->platform_state_user);
 
         /* perform postponed chdir if --daemon */
         if (c->did_we_daemonize && c->options.cd_dir == NULL)
Signature · 1 line
2.37.3
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 1 line · Gert Doering

FreeBSD 14 clang complains about this:

and it is right.

Quoted 10 lines

init.c:3530:13: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]

             platform_group_get(c->options.groupname, &c0->platform_state_group)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

init.c:3530:13: note: cast one or both operands to int to silence this warning 1 warning generated.

.. so do what it wants us to do.

Quoted 17 lines
---
  src/openvpn/init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/init.c +1 -1
index 03416844..c88c0915 100644
@@ -3528,7 +3528,7 @@ do_init_first_time(struct context *c)
          /* get user and/or group that we want to setuid/setgid to */
          c0->uid_gid_specified =
              platform_group_get(c->options.groupname, &c0->platform_state_group)
-            |platform_user_get(c->options.username, &c0->platform_state_user);
+            || platform_user_get(c->options.username, &c0->platform_state_user);
 
          /* perform postponed chdir if --daemon */
          if (c->did_we_daemonize && c->options.cd_dir == NULL)
Signature · 1 line
Antonio Quartulli
#2 lore raw
In reply to Gert Doering

For sanity reasons, tested on the oldest system I have around (FreeBSD 7.4). No complaints (none expected).

Patch has been applied to the master branch.

commit facb6fffb35f51e67eefaab8ba357b676b3c6328

Author: Gert Doering
Date:   Tue Oct 4 16:51:42 2022 +0200
     use boolean '||' to join two bools, not bitwise '|'

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg25333.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering