From patchwork Tue Apr 7 11:24:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4880 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:d1c6:b0:83c:d90d:321 with SMTP id ly6csp1947588mab; Tue, 7 Apr 2026 04:24:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHEGqkxuWfWx8hYQeSCynVKbhkclBs54p9Ze+YLNXIl1O/v06znb2k2ROGIY4CF4mXL1M3XyqpBW0=@openvpn.net X-Received: by 2002:a05:6808:2393:b0:44d:9dc2:2be5 with SMTP id 5614622812f47-46ef9c6eb21mr9103452b6e.21.1775561090689; Tue, 07 Apr 2026 04:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775561090; cv=none; d=google.com; s=arc-20240605; b=YvEbI0A2/0dmIntPo+9lzhEJ1B2FjVuDF2F8icjWfjXmbx2I/AsYAno3YXRtXePOcP jWS4enz4o/1/tzdE9WQ04eeq6JP3HWwStVZ6HkT09xUFPAojjYlpJj34fUB8nCewq6e3 GgtWbj2f0ZQmVYIvWBqd2cG0xV7zKRaPss5TRAIipyyilHxleXqdKWzK7yXyyXiqAOsr x6K+ZbEuE8RjDtU+z9ZEqR1od02FCVmzbcPOWZjYQApQ7Ukzdt19CGC1AXUsKpeuSuUO 9jcMLplGimtBUnsoiGNtjcE1E4zxTQrHtSwczGYNvS1tPX3NYS6x8eLB0b80E3wbigBj a4+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=fse0tYKpqVFpIHbycI4iAtYYEdVhfv/Rnwa5orgZijE=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=ha7NCOameMy+adfDIpGOFchR9fw9z7vCEnk5bdtVvghPbg7OSjRDOI00+vU/YHWu5y ZjIDgEZc//2yM2FemH3Igr5wV5DFqLvoeDOiqmnAD85qAw3gxGbp6mAg5ZJxHGdHLRYE nRPPWyTABadTE44+DAogXBQrCM4OlM1IeIEI4iGu8+HuEXqPmEaxBIFwn0wqT6/QG9Nj ELkeDW0eWEMOcmpiEMINoKWcMhtA1ZbCZNURcxKUVgqBHBD695xjhK93xV571FjkYCES 1SEGqYWU1VH7ao2wGvXaDgnfA1OU0dwlokrdsN2HhGq9UM2Hqw/72L54z8Q2EjNvKIrC 2twA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=J8wG2sXt; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=lA5c9xc1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=estZULf8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-422eaf12bd5si13864045fac.25.2026.04.07.04.24.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2026 04:24:50 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=J8wG2sXt; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=lA5c9xc1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=estZULf8; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fse0tYKpqVFpIHbycI4iAtYYEdVhfv/Rnwa5orgZijE=; b=J8wG2sXtMXsBMVFXIrJiFY7kVo yF1w9YAGGtCCR1yF1vZml9vHawyZ1dcbBLZuwr1IEOK8fxY1FECfQ9JEhSNY9jZlieN/wVuL5VLhQ dZWOhB/7vKGn7TQnUCCoLLY2bEJfn0ZYs2ckeXSA0Zescy1OfaIYpNlEfUaqpzs0DRts=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wA4Y3-00070o-L5; Tue, 07 Apr 2026 11:24:48 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wA4Y2-00070c-Td for openvpn-devel@lists.sourceforge.net; Tue, 07 Apr 2026 11:24:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NUSvhLhaQBmG+BSd9FTuNehxFi7VlS4jluj7gFcZCJ4=; b=lA5c9xc1ViMtN7DZTghXHVG6h4 k8ajpS391TGfPIR7UjxHt1t2+RYxqEjPws1ghlwGhCqqgV+ewzgDfwdneLoMgcyZ6Ci2bCZcy/17K RSu3jPjQIezP85s4VxEGMeswxqYzplKdFG+B6FsWasfGE1YEDaUAU2z5rK18c58pppMQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NUSvhLhaQBmG+BSd9FTuNehxFi7VlS4jluj7gFcZCJ4=; b=estZULf8hcu0rcYIJoLdSdEBGW JU6VRw9uoUV2yTWfuDUgBjwyW7G7yHq5f+i0l+lXSOKz9JtrJCMICeSAqOe87x7Fy9A13nntAjOBH ef3lQE8952lYDGsji6FeGjqnWIRGcVvmE6cEeBnzSIZ5RPbdDOm8QxuANllvBozkKPWU=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wA4Y2-0000MV-Hh for openvpn-devel@lists.sourceforge.net; Tue, 07 Apr 2026 11:24:47 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 637BOYw6005604 for ; Tue, 7 Apr 2026 13:24:34 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 637BOYZx005603 for openvpn-devel@lists.sourceforge.net; Tue, 7 Apr 2026 13:24:34 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 7 Apr 2026 13:24:28 +0200 Message-ID: <20260407112434.5588-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld peer_id is mostly this already (except in DCO context for some reason), and max_peerid was defined as uint32_t as well. So changing max_clients to uint32_t avoids many -Wsign-compare warnings. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wA4Y2-0000MV-Hh Subject: [Openvpn-devel] [PATCH v1] Change type of max_clients to uint32_t X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1861810746435570598?= X-GMAIL-MSGID: =?utf-8?q?1861810746435570598?= From: Frank Lichtenheld peer_id is mostly this already (except in DCO context for some reason), and max_peerid was defined as uint32_t as well. So changing max_clients to uint32_t avoids many -Wsign-compare warnings. While here fix limit for max_clients in options parsing. It is not allowed to be MAX_PEER_ID exactly. Change-Id: I8d6b7bc1b7744dc6d57aaed3231b8901275752f2 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1564 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1564 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index a1e373d..718cd8b 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -559,11 +559,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - static void dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nvl) { @@ -582,10 +577,6 @@ __func__, peerid, mi->context.c2.dco_read_bytes, mi->context.c2.dco_write_bytes); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int dco_read_and_process(dco_context_t *dco) { diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b92fa43..37171c5 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -858,11 +858,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - static int ovpn_handle_peer(dco_context_t *dco, struct nlattr *attrs[]) { @@ -889,7 +884,7 @@ if (dco->ifmode == OVPN_MODE_P2P) { c2 = &dco->c->c2; - if (c2->tls_multi->dco_peer_id != peer_id) + if (c2->tls_multi->dco_peer_id != (int)peer_id) { return NL_SKIP; } @@ -918,10 +913,6 @@ return NL_OK; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static bool ovpn_iface_check(dco_context_t *dco, struct nlattr *attrs[]) { diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index f46c24d..2e26f2a 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -739,11 +739,6 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err) { @@ -838,9 +833,9 @@ { OVPN_PEER_STATS *stat = &peer_stats[i]; - if (stat->PeerId >= dco->c->multi->max_clients) + if (stat->PeerId >= (int)dco->c->multi->max_clients) { - msg(M_WARN, "%s: received out of bound peer_id %u (max=%u)", __func__, stat->PeerId, + msg(M_WARN, "%s: received out of bound peer_id %d (max=%u)", __func__, stat->PeerId, dco->c->multi->max_clients); continue; } @@ -871,10 +866,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int dco_get_peer_stats_fallback(struct context *c, const bool raise_sigusr1_on_err) { diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index b359750..432c79a 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -180,11 +180,6 @@ return false; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * Get a client instance based on real address. If * the instance doesn't exist, create it while @@ -217,7 +212,7 @@ uint32_t peer_id = ((uint32_t)ptr[1] << 16) | ((uint32_t)ptr[2] << 8) | ((uint32_t)ptr[3]); peer_id_disabled = (peer_id == MAX_PEER_ID); - if (!peer_id_disabled && (peer_id < m->max_clients) && (m->instances[peer_id])) + if (!peer_id_disabled && (peer_id < m->max_clients) && m->instances[peer_id]) { /* Floating on TCP will never be possible, so ensure we only process * UDP clients */ @@ -315,10 +310,6 @@ return mi; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Send a packet to UDP socket. */ diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index c03e821..f825bf8 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -695,11 +695,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * Create a client instance object for a newly connected client. */ @@ -782,10 +777,6 @@ return NULL; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Dump tables -- triggered by SIGUSR2. * If status file is defined, write to file. @@ -3261,7 +3252,7 @@ return; } - if ((peer_id < m->max_clients) && (m->instances[peer_id])) + if (((uint32_t)peer_id < m->max_clients) && m->instances[peer_id]) { struct multi_instance *mi = m->instances[peer_id]; set_prefix(mi); @@ -4085,18 +4076,13 @@ #endif /* ifdef ENABLE_MANAGEMENT */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - void multi_assign_peer_id(struct multi_context *m, struct multi_instance *mi) { /* max_clients must be less then max peer-id value */ ASSERT(m->max_clients < MAX_PEER_ID); - for (int i = 0; i < m->max_clients; ++i) + for (uint32_t i = 0; i < m->max_clients; ++i) { if (!m->instances[i]) { @@ -4117,10 +4103,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** * @brief Determines the earliest wakeup interval based on periodic operations. * diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 17d850b..e0108ad 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -182,7 +182,7 @@ struct multi_reap *reaper; struct mroute_addr local; bool enable_c2c; - int max_clients; + uint32_t max_clients; int tcp_queue_limit; int status_file_version; int n_clients; /* current number of authenticated clients */ diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 8daec42..861e194 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1431,7 +1431,7 @@ SHOW_INT(cf_per); SHOW_INT(cf_initial_max); SHOW_INT(cf_initial_per); - SHOW_INT(max_clients); + SHOW_UINT(max_clients); SHOW_INT(max_routes_per_client); SHOW_STR(auth_user_pass_verify_script); SHOW_BOOL(auth_user_pass_verify_script_via_file); @@ -7354,7 +7354,7 @@ else if (streq(p[0], "max-clients") && p[1] && !p[2]) { VERIFY_PERMISSION(OPT_P_GENERAL); - if (!atoi_constrained(p[1], &options->max_clients, p[0], 1, MAX_PEER_ID, msglevel)) + if (!atoi_constrained(p[1], (int *)&options->max_clients, p[0], 1, MAX_PEER_ID - 1, msglevel)) { goto err; } diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 3d8b505..a956a96 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -530,7 +530,7 @@ int cf_initial_max; int cf_initial_per; - int max_clients; + uint32_t max_clients; int max_routes_per_client; int stale_routes_check_interval; int stale_routes_ageing_time;