From patchwork Wed Nov 19 21:42:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4618 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:3515:b0:7b1:439f:bdf with SMTP id ss21csp450372mab; Wed, 19 Nov 2025 13:42:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUFwUD7htnEQaWls6jczWd7FsgFKK3PoNDpRdxH/va4ZqrNJJrEe8lnKjaGqKUxa48bGPJym2cpyTA=@openvpn.net X-Google-Smtp-Source: AGHT+IEQRug2Sg9rsfgKJriTTUR21i4hR04j922qEuoqw1JTgbfEGswXi90DPC8Gu4VT0iT3AXcC X-Received: by 2002:a05:6808:6a8a:b0:450:c877:fd8c with SMTP id 5614622812f47-451000fea7fmr252425b6e.26.1763588578154; Wed, 19 Nov 2025 13:42:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1763588578; cv=none; d=google.com; s=arc-20240605; b=EoDBaqETOeDV6FWNpKi8FOgfpT2NL8jKEadygdil4bwZmQEQ/l+VLbxsS36tx/zUle ry/ZCdcjGWqPIT4Yvv8Pb4wHDN70VINIziee2hXwXxr6WIBqAuLok+fSdsawyGunkGg/ mwwYkxMTEuIvRKCGz4MdokAYaCZdSBRCg/WN8K9yIoMT3qgea04DZgUCIXjGz/Mjb0qF ejFhfZBSxxrXAvpvqhSmXtZjTT199pHcmFLY1D6sZbGDJh4BKedUvPz2kvOEemH6+4K6 YqpP3nuVCSdHX3gBh6ZJNaEmrgVEBAuiNNgZLDXPdmRSaOYt6qCjQVxS4as+WY2R5byY HIMw== 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=NBx9gCyYkJAaDnSMUa8fdpz8uCkCqz6MVhEO6sdcKCw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=il+YuwUCb4saYkfZeMgDZ1CS+blwWaCP1Mjf0PIFLg864GMmPFR/LIXKJTk2kHAlU3 d9Osw2N/RAWB2QsUN+6esP3Sz+Q5fFQzHsStjcpTQ+CSZKkZYroKIb1p3kd4eIO8gdmX YBBguI8++sPUxqXPnnFt0V7YfkODsjpwsnW5Wr5J8vOFN7bESCvxudqqQVyUf4XbsZ+2 +cZ8YlZwyrCr8cloDYaMNp6UV4sC5RXhYxUa5oNoP25AwSCNxczCRXbMERuIJG5VuO5U gBfiuctFCva4M9JXpupAATB8nZDhJlXsp3rxZQdYgEbLISJNLxUK71owsmYD/LdGjsdj Y6bw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=hCuPP0fI; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="fw8RlT/z"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="ShVTKl/q"; 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 006d021491bc7-65782a30861si214734eaf.6.2025.11.19.13.42.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2025 13:42:57 -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=hCuPP0fI; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="fw8RlT/z"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="ShVTKl/q"; 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=NBx9gCyYkJAaDnSMUa8fdpz8uCkCqz6MVhEO6sdcKCw=; b=hCuPP0fIM0FrLyX9UWgnU4VWyy MJ4QYh8QUKvzzidOf4ouRwCmeeggW3bpVPpnj0CLGSxgtnuUsIKie67Z2c3zGKtRSDh7eSDSS4iEb qcbRp1jodtnMCUbWUUh295/aIEdSdxYTs2olB5HVglc0es0EdDyA2EzCMjOyHLsak8Oc=; 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 1vLpwz-00056r-Uq; Wed, 19 Nov 2025 21:42:54 +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 1vLpwz-00056b-0R for openvpn-devel@lists.sourceforge.net; Wed, 19 Nov 2025 21:42:53 +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=3qQKKrIYqryy6ZG6A6fqpGoqE1n4sgepxrNDIZMHpMY=; b=fw8RlT/zMgYkc5pkHJCJEYQrsI 3k+AOOJYnCCTZdpivmBb62D7ggVnQdiow23CLtXF66y5BXIRvtdzZJ19gBSV5rtu7t3d9C+Kjoh3W VLaHQTHhpWqDOEhKNOv+rV+2k2WUTy26CYg1EH8jNldRYpM5JwE8HHr9P0v25yqksiLI=; 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=3qQKKrIYqryy6ZG6A6fqpGoqE1n4sgepxrNDIZMHpMY=; b=ShVTKl/qZjcQ/Xh0m0llv1hL+f S+K3pNdUwEbuBjP3bNi0myzmN1e6711UUFm0oKyYbs1Xqbb+b4Q/nrutx09dk+UISWPpMgUMB83N+ drxoAgRJXpVbEBVGy39Kb/9D4dAxIk2zchhuwy0Od3pE+DzpyHj85oJ534ITyrThCvNw=; 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 1vLpwx-0000RS-QW for openvpn-devel@lists.sourceforge.net; Wed, 19 Nov 2025 21:42:53 +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 5AJLgdNU013645 for ; Wed, 19 Nov 2025 22:42:39 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 5AJLgdEe013644 for openvpn-devel@lists.sourceforge.net; Wed, 19 Nov 2025 22:42:39 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 19 Nov 2025 22:42:34 +0100 Message-ID: <20251119214239.13629-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 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 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URI: openvpn.net] 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1vLpwx-0000RS-QW Subject: [Openvpn-devel] [PATCH v8] 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?1849256656581242483?= 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 8 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 e592eb5..9a2c928 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1300,11 +1300,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 */ @@ -1331,11 +1326,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 */ @@ -1365,6 +1360,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 90505a0..d1fc442 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1708,8 +1708,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) { @@ -1721,12 +1721,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) @@ -1757,7 +1752,7 @@ } } -static int +static ssize_t read_tun_header(struct tuntap *tt, uint8_t *buf, int len) { if (tt->type == DEV_TYPE_TUN) @@ -1778,26 +1773,21 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #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) @@ -2054,13 +2044,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); @@ -2268,27 +2258,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 @@ -2613,7 +2594,7 @@ argv_free(&argv); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { struct strbuf sbuf; @@ -2622,7 +2603,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; @@ -3097,11 +3078,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) { @@ -3125,7 +3101,7 @@ gc_free(&gc); } -int +ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len) { if (tt->backend_driver == DRIVER_UTUN) @@ -3138,7 +3114,7 @@ } } -int +ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len) { if (tt->backend_driver == DRIVER_UTUN) @@ -3151,10 +3127,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #elif defined(TARGET_AIX) void @@ -3277,13 +3249,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); @@ -6329,13 +6301,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 e13f99f..77c3c09 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); void tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode, const char *username, const char *groupname, const struct tuntap_options *options,