From patchwork Fri Mar 6 16:33:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4807 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:a68f:b0:83c:d90d:321 with SMTP id wf15csp1675896mab; Fri, 6 Mar 2026 08:33:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWYTzaU7Edp6vkmgFW4/Eo2ony+mp6BKwFOspfhwc5yXBdWGUMOf8rVRafsDxC0C7AWm3MqvvhcAEQ=@openvpn.net X-Received: by 2002:a05:6808:6f93:b0:464:ab2d:3880 with SMTP id 5614622812f47-466dcbade5dmr1393917b6e.41.1772814829497; Fri, 06 Mar 2026 08:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772814829; cv=none; d=google.com; s=arc-20240605; b=V/yGrD4BnWvrfO+SzFLztrGy5zO6iRln9gWuGvLJG9jN45uGbGT2An90p1w0NeAB/3 EZ0xyGJhq0NAPtuBBbjqy64uDcp6ohq4XtChV95+ym+GVrfi+bGSVyUqaO+qFtir48L2 fQRMkrUAthlNPYKmGvrMA3/gRTyZB3GXNIOHDCJA6DdX/9s5ZMjVbvcu2tqIH9bSFWyK S3yS6nTmE5l1O+Fk9I6Q7vlYHIq3wgceCtFe4+jyeEfH7N9bCr0Vw8PXIIcntwYaSGST R1YA/9KWwbh3Enkzny3tpMO6zYrAgbqBiVHRHneBY+pGm0cx0w2bxCn6AXvwh71rynEj 28UQ== 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=GrrMi7po4gAlEQVu54oBiy1O1sEuYVfP3YjluTZzJIc=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=KVDt0ViOHh5RbQOVkzQvRgZpVXTO+PpFYEykyAe7lm2pFKp6besr2FlDr7zeBC4AJ0 Imxt8anq1IVSVvuKlAFNfQ5hQuuTnBQJILKlMW/qcijmlZjanzhGAoX8cGe53sQXqd+B +cKid6jiIYmmgGUHomirzN4MOahKEGCZMw3CjrqYr+b9MN4ocISSF1hl+70sUtFkPeNC X4JvzNBNGJyV/s8NZsRPp9D2YK2FNVWZ/ePZ+tAM1/y0qcyQ9NOyN7e/VxN1uaVNcKVZ 6rzTpTuFxIEq0NBFNvAnW1kz1La3QMgGzfNN5/r8GVZff6T7A7HhUYIdicSyGitKFre0 K4Qg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=dsxiUdx+; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TgxlXQ+t; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=YO8bW8TJ; 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-416e68438ddsi1612475fac.279.2026.03.06.08.33.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2026 08:33:49 -0800 (PST) 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=dsxiUdx+; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TgxlXQ+t; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=YO8bW8TJ; 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=GrrMi7po4gAlEQVu54oBiy1O1sEuYVfP3YjluTZzJIc=; b=dsxiUdx+WzdPcj/baswfkdho9j RA1Xd+0Ipnd2H6vQbtgr8B+Bm3tGsp8D/+4fipcdtQunlwjgTzTimtbx1iwhnPEu15YGl+FYqLL8t Zutp4ILlKYgoN+AYLI5E0ZBjNsaXeHf8+HvXDKIy6IxIR5cfLOAupBzu44XldbJDCI+g=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vyY7X-00035S-DO; Fri, 06 Mar 2026 16:33:47 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vyY7V-00035L-Ri for openvpn-devel@lists.sourceforge.net; Fri, 06 Mar 2026 16:33:45 +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=VCpy6Qy0q8LhWQHpHYLHp9xhMk63tIlI9NpplDfzSoE=; b=TgxlXQ+t2TIi3UP/0JLkNG1Lwd mde4ESepCglSIG6SUw59eMFkAKN26KX765bUYOjnhUcq0LQ/lkYEQDGfXZYJ9rrnVsKZYG3W2ssxO 1AjLcDRtKkWrgUE4eBDgLZKN+QaJriy22vhvu8Fiw9zaSZQJg/oLjE1Pkupr4T1T+qt4=; 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=VCpy6Qy0q8LhWQHpHYLHp9xhMk63tIlI9NpplDfzSoE=; b=YO8bW8TJLZQPXvR9ZXV+tt0yhC EiF1t1qR6upO9iQJiBq/lbFZCulmqMYgPvrglgaJQdZ4enAVh0MSoQHEsseWMP5Tml2V86++w1sNb e1XDhIa3mATHn97M64ZmKF7LzGQjW1OS60yCOdZjMdUXLxnaELgc3PpsXf8T4rEw4dh8=; 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 1vyY7U-00068J-K6 for openvpn-devel@lists.sourceforge.net; Fri, 06 Mar 2026 16:33:45 +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 626GXcZV002775 for ; Fri, 6 Mar 2026 17:33:38 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 626GXc0B002774 for openvpn-devel@lists.sourceforge.net; Fri, 6 Mar 2026 17:33:38 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 6 Mar 2026 17:33:31 +0100 Message-ID: <20260306163337.2756-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-1.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 write takes size_t as count (unsigned int on Windows) and returns ssize_t (int on Windows). But we often want to compare the return value to the count. 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: 1vyY7U-00068J-K6 Subject: [Openvpn-devel] [PATCH v3] Fix various sign-compare warnings due to write return value 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?1858931082678728483?= X-GMAIL-MSGID: =?utf-8?q?1858931082678728483?= From: Frank Lichtenheld write takes size_t as count (unsigned int on Windows) and returns ssize_t (int on Windows). But we often want to compare the return value to the count. Generally we can just rely on the fact that sizeof(ssize_t) == sizeof(size_t) and use that for all values. (Until we want to introduce -Wsign-conversion that is...) Change-Id: I3eb4581980f532cb2960b37a6fa43a7baee4b603 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1513 --- 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/+/1513 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index c589248..c3f54ed 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -327,11 +327,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * Record IP/port of client in filesystem, so that server receiving * the proxy can determine true client origin. @@ -357,7 +352,8 @@ int fd = platform_open(jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP); if (fd != -1) { - if (write(fd, f, strlen(f)) != strlen(f)) + ssize_t write_len = strlen(f); + if (write(fd, f, write_len) != write_len) { msg(M_WARN, "PORT SHARE: writing to journal file (%s) failed", jfn); } @@ -373,10 +369,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Cleanup function, on proxy process exit. */ diff --git a/src/openvpn/status.c b/src/openvpn/status.c index 4d42863..c7d375b 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -206,11 +206,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - #define STATUS_PRINTF_MAXLEN 512 void @@ -240,7 +235,7 @@ if (so->fd >= 0 && !so->errors) { strcat(buf, "\n"); - size_t len = strlen(buf); + ssize_t len = strlen(buf); if (len > 0) { if (write(so->fd, buf, (unsigned int)len) != len) @@ -258,10 +253,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool status_read(struct status_output *so, struct buffer *buf) { diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c index 0f3346f..3b7bcc2 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -184,15 +184,10 @@ return -1; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - static ssize_t send_string(int fd, const char *string) { - const size_t len = strlen(string) + 1; + const ssize_t len = strlen(string) + 1; const ssize_t size = write(fd, string, len); if (size == len) { @@ -204,10 +199,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #ifdef DO_DAEMONIZE /*