From 1491fc8e05b01e65aba8b50499407d9af0424d69 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Tue, 7 Apr 2026 22:52:28 +0200 Subject: [PATCH] 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 --- src/openvpn/error.h | 2 +- src/openvpn/options.c | 4 ++-- src/openvpnserv/common.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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, -- 2.47.3