From: Frank Lichtenheld Date: Tue, 7 Apr 2026 20:52:28 +0000 (+0200) Subject: Clarify operator precedence in a & b ? c : d X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fopenvpn.git Clarify operator precedence in a & b ? c : d As suggested by cppcheck. Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619 Message-Id: <20260407205235.31126-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36545.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 1198994af..3b742d79c 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -397,7 +397,7 @@ ignore_sys_error(const int err, bool crt_error) static inline msglvl_t nonfatal(const msglvl_t err) { - return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err; + return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err; } static inline int diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 713dcf40a..b8d0f5aa6 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -7044,12 +7044,12 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file, if (options->routes->flags & RG_REROUTE_GW) { setenv_int(es, "route_redirect_gateway_ipv4", - options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1); + (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1); } if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW)) { setenv_int(es, "route_redirect_gateway_ipv6", - options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1); + (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1); } #ifdef _WIN32 /* we need this here to handle pushed --redirect-gateway */ diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index f60e2f237..7fc8c14d7 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -276,7 +276,7 @@ MsgToEventLog(DWORD flags, LPCWSTR format, ...) const WCHAR *mesg[] = { msg[0], msg[1] }; ReportEvent(hEventSource, - flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, + (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, 0, EVT_TEXT_2, NULL,