From patchwork Tue Dec 9 15:37:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4669 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:29c3:b0:7b1:439f:bdf with SMTP id g3csp1415830max; Tue, 9 Dec 2025 07:37:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWjUoI2gCTNw7Opw6aNiIGNsCvJUMHuvQ/p8WbJNx3om570AjyJCgNBKKkm0j30pmcRcKM7FmX1A7E=@openvpn.net X-Google-Smtp-Source: AGHT+IF9AqFWbCfWXbeiOhorfL9rcIkRynhTIJRHicGp6UsuQHFO3RqDMcD4UGua4dNwBi9j8i03 X-Received: by 2002:a05:6830:6205:b0:7c7:59ed:ca0d with SMTP id 46e09a7af769-7c9708293c0mr5644773a34.36.1765294648450; Tue, 09 Dec 2025 07:37:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1765294648; cv=none; d=google.com; s=arc-20240605; b=LVJUwo7fDHlmrlG9MhLD15exmI4X3rObApCeP7GYv7HFb7Uq5aNjy3bTBqJ0Tdgl2v 8FpZad/EsGFF+qEE147Y5bak/mTG2YyW2Z2HkgcMZRgqu6MwwdOQD9KgOCMNu2B619qO K5KqjR78dZWJ9J6I6nuXW7uGUEVFBDrJugMgt0F76PrK7LeM5fRVnEobUUBFXDxy3TIs 9ejE5rjCv3spcK47pBubr+vyAM++1DlceRmMFHApQkOAi41bB9HKRkKTefxidL2xylLG 4Uejnj97crwZrFY2/KQzvOb8grTIAlmcPkkM4UP1WfG4KIW0/Ptsr+cZmLZdDuuts8eW CkGg== 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=naIc7Lp0LohDeLZi8pSUkgNyeS8apBX9KTkRQbLzXog=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=TyyNNi9TXfwR3a2jdfVZLaZUAOGxYqFQJs1DRnjlMQYOJeh9VfpmzSFyr6n/aF61lE J3V29cM8V570t6Om7HEk01lf8+B6yx/NUZcNPbRs1D+PimudO3O7lssx6toqYT/RKUd6 sVWgXAxu8gm+Tv414CpdNa+izr22ac1S3HMzZ3LZ5OxzChQUv+el1cS+VtM9oITHMW4B pA1nvEj+IE3p7S/ZBhCRWoq3cje4f797T5xGLmEb4XnbKTkJy8eZryMLlcfPVL2wGnUy +zSkKS3dOj7Sd5EgjRTZHtSuN3Na5HopOI/eN/v7fzPsl7yl0pgMQW+8ZS01qMag0fL5 3Ceg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ZQzRRFi4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=JTFW7H0B; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=kKWLQ4ey; 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 46e09a7af769-7caca948272si369478a34.157.2025.12.09.07.37.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2025 07:37:28 -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=ZQzRRFi4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=JTFW7H0B; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=kKWLQ4ey; 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=naIc7Lp0LohDeLZi8pSUkgNyeS8apBX9KTkRQbLzXog=; b=ZQzRRFi4mUe73ipKDPEpn7m31S aHnLGam9WGLpUQKOKi5SWA9DumwD0WOhGqsriTUEADQK/1WJzKFc8ZxnECLSCCDOJwruD/ySecikZ ISFDl5ViuXWa4162hsxHiL2nVPjilGewut6LpZXwO5RC7qz3IS6ZIvQDXrzqNO9ZKr/c=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vSzmI-0006gT-2Q; Tue, 09 Dec 2025 15:37:26 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vSzmF-0006f7-QQ for openvpn-devel@lists.sourceforge.net; Tue, 09 Dec 2025 15:37:23 +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=brNQENsVdeK8iXfRWPuyw1KDSU+oRZxEGJrRgHwj7RM=; b=JTFW7H0Ba0yl1YJ6bAouMWRRhx sEcXjT1FT3xPszEi50E+v61eTT5Lc6rspfO+ZKL2YAZn/hzfH/B2wgzRI0f6oF0DivxHZCnGIsPnS 4cr9/4ktfUA8f5Q+G54U4u6fC0AndKKHURdgMK/DcOy/HQZlzvWeyX24c2n9sx2FI1Sk=; 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=brNQENsVdeK8iXfRWPuyw1KDSU+oRZxEGJrRgHwj7RM=; b=kKWLQ4eyfMs4kcySpH68bsshWv jngYwKGA9U5XfTDvfuA28a71NOj861a5ix+Up6BqwacRE66KTBuVdpzcBwpn7apCoXHCnw52BZ5vE r0iqXJiSPJvbZXiKI0fNw9EIhXWo+XJsOwOHaJuFIeWyMyGcROm9s1n+3gcGGUnuX8Vk=; Received: from [193.149.48.134] (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 1vSzmE-00074P-QH for openvpn-devel@lists.sourceforge.net; Tue, 09 Dec 2025 15:37:23 +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 5B9FbFjH015888 for ; Tue, 9 Dec 2025 16:37:15 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 5B9FbFvA015887 for openvpn-devel@lists.sourceforge.net; Tue, 9 Dec 2025 16:37:15 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 9 Dec 2025 16:37:07 +0100 Message-ID: <20251209153715.15832-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.51.2 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 So we can directly give back the actual return type from write/read. Even if we then cast it back to int. The cast should be safe since we also specify an int as we also put an int in as length. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block for more information. [193.149.48.134 listed in list.dnswl.org] 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1vSzmE-00074P-QH Subject: [Openvpn-devel] [PATCH v10] tun: Change return type of write_tun/read_tun to ssize_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?1849256656581242483?= X-GMAIL-MSGID: =?utf-8?q?1851045601247432399?= From: Frank Lichtenheld So we can directly give back the actual return type from write/read. Even if we then cast it back to int. The cast should be safe since we also specify an int as we also put an int in as length. Change-Id: I67f5bf53b80f53fd2e349f844479ed172a7b3aa1 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1376 --- 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/+/1376 This mail reflects revision 10 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 6f1bc0c..913fb92 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1292,11 +1292,6 @@ #endif /* if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD)) */ } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /* * Output: c->c2.buf */ @@ -1323,11 +1318,11 @@ if (c->c1.tuntap->backend_driver == DRIVER_AFUNIX) { c->c2.buf.len = - read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); + (int)read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); } else { - c->c2.buf.len = read_tun(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); + c->c2.buf.len = (int)read_tun(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); } #endif /* ifdef _WIN32 */ @@ -1357,6 +1352,11 @@ check_status(c->c2.buf.len, "read from TUN/TAP", NULL, c->c1.tuntap); } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + /** * Drops UDP packets which OS decided to route via tun. * diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index b4e3cb4..0299285 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1706,8 +1706,8 @@ #include #include -static inline int -header_modify_read_write_return(int len) +static inline ssize_t +header_modify_read_write_return(ssize_t len) { if (len > 0) { @@ -1719,12 +1719,7 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - -static int +static ssize_t write_tun_header(struct tuntap *tt, uint8_t *buf, int len) { if (tt->type == DEV_TYPE_TUN) @@ -1755,7 +1750,7 @@ } } -static int +static ssize_t read_tun_header(struct tuntap *tt, uint8_t *buf, int len) { if (tt->type == DEV_TYPE_TUN) @@ -1776,30 +1771,25 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* For MacOS this extra handling is conditional on the UTUN driver. * So it needs its own read_tun()/write_tun() with the necessary * checks. They are located in the macOS-specific section below. */ #if !defined(TARGET_DARWIN) -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { return write_tun_header(tt, buf, len); } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { return read_tun_header(tt, buf, len); } #endif - -#endif /* defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || defined(TARGET_NETBSD) || if defined (TARGET_OPENBSD) || defined(TARGET_DARWIN) */ +#endif /* if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || defined(TARGET_NETBSD) || defined (TARGET_OPENBSD) || defined(TARGET_DARWIN) */ bool tun_name_is_fixed(const char *dev) @@ -2056,13 +2046,13 @@ free(tt); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { return write(tt->fd, buf, len); } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { return read(tt->fd, buf, len); @@ -2261,27 +2251,18 @@ free(tt); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { return write(tt->fd, buf, len); } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { return read(tt->fd, buf, len); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #elif defined(TARGET_SOLARIS) #ifndef TUNNEWPPA @@ -2606,7 +2587,7 @@ argv_free(&argv); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { struct strbuf sbuf; @@ -2615,7 +2596,7 @@ return putmsg(tt->fd, NULL, &sbuf, 0) >= 0 ? sbuf.len : -1; } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { struct strbuf sbuf; @@ -3090,11 +3071,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - void close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx) { @@ -3118,7 +3094,7 @@ gc_free(&gc); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { if (tt->backend_driver == DRIVER_UTUN) @@ -3131,7 +3107,7 @@ } } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { if (tt->backend_driver == DRIVER_UTUN) @@ -3144,10 +3120,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #elif defined(TARGET_AIX) void @@ -3270,13 +3242,13 @@ argv_free(&argv); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { return write(tt->fd, buf, len); } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { return read(tt->fd, buf, len); @@ -6322,13 +6294,13 @@ free(tt); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { return write(tt->fd, buf, len); } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { return read(tt->fd, buf, len); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 876f147..8bc876e 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -274,9 +274,9 @@ void close_tun_handle(struct tuntap *tt); -int write_tun(struct tuntap *tt, uint8_t *buf, int len); +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len); -int read_tun(struct tuntap *tt, uint8_t *buf, int len); +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len); #ifdef ENABLE_FEATURE_TUN_PERSIST void tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode,