From patchwork Fri Jul 25 12:44:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4326 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:3644:b0:671:5a2c:6455 with SMTP id a4csp1456725mai; Fri, 25 Jul 2025 05:44:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVw1GO1ldP2kXgVsOGeeipj1PZUzi3Ir4JVEy/qtDYFZVxZbnHBFq3MQsbN4x1JkOz3usc6vvU0pyQ=@openvpn.net X-Google-Smtp-Source: AGHT+IGEo3mUz9ksU+UiwgI4wY18stPecCLPbAfFZ63dVJfWCIcojE1tHSbcsuYGc2LsTrxUEzIW X-Received: by 2002:a05:6808:228c:b0:40c:fe45:2ab5 with SMTP id 5614622812f47-42b9d156e08mr904071b6e.1.1753447473114; Fri, 25 Jul 2025 05:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1753447473; cv=none; d=google.com; s=arc-20240605; b=AUJHTxo6AIXXh8+n9NzAJ3m86CsbgxbajMx0q9kTOoa1h5W/FnLtLKpkpsvBTejMb5 6qrIlj5zUEeEtrdcGuw9lfXhI8TvFfp9A7p16jZGTio5PBIthUOmb0qNMyxOadqbcOyq C8PQvnH/mX00lH3cWFd/JvY+AM3D7B8+C2+e8NI7AaQQtRRRVF/jxCObz7Zgz1xsWCTy xBm9OuYqA+lj9dagM1VETPOd61epVTmXkM94F+dlE0CfenPjgBSo1owTsBJW5/KquXJP rQvKhzafNsSmhJWpsWbkYK6gurFaA9P0bcJCE20o09Vz0qfaVu6+SqyDTpKyQH91+GRr kJUQ== 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=fcT5m0QhMJp4FYp/OyXYqXyTC9mWCHpXVbzGgsKEKn4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=IHDXz1PkLCoVGXWWs+AP7ktJremEqPMocYlA7Xyx60rnazEni6WCxEbP9AIOxuqgpH e5MZaiGFmqnLBXPa65/DFvrV7dd2G8owFoAmYM5r7y19OEq8kXOH9pFYheATXx8ZVdDO cLNIzQ/1ex8C8hsF3AHl4Fz8dJpJfvHnhN6m7rwy+AopGldO9rio/9qMVsuMfDqaqzW3 DnHHxUhqEKM6SfFybUzPoPzW6rxjEKd+uqqtHLr5ne0sFelD8AvwPXfgSyDb+uK+uBvq E5X/rVgMwSb9Y+IgGrAK71EBvR+1UNWdY8IvkBomkdmsPD5K6MuVSUjxoCaqtmx+55P2 NxVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=J1tYVna6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SOG8jQW4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LVqFR5QX; 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 5614622812f47-42a2f6f97fasi1396420b6e.3.2025.07.25.05.44.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jul 2025 05:44:32 -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=J1tYVna6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SOG8jQW4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LVqFR5QX; 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=fcT5m0QhMJp4FYp/OyXYqXyTC9mWCHpXVbzGgsKEKn4=; b=J1tYVna6Y187v/omDGIbPcC98g Fc0uDghvdIi5e8boD0AM2R4sg2YxwXx62m/Wr25w3zjuSfElKB8tGgmbtCSJ3N0cmpWqOfpbw+bK0 hFl3fhPQZ8Es0bYuBuOp6BRWydAOwlkKh/nXN51mR1reQarEEZW05CW+5W2dEhbOzQoI=; 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 1ufHmo-0005n5-I2; Fri, 25 Jul 2025 12:44:30 +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 1ufHmn-0005my-5E for openvpn-devel@lists.sourceforge.net; Fri, 25 Jul 2025 12:44:29 +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=ydEPlabHa6ICXnyKgvFwBDVXY+WLAo+EMYfunz+kz+4=; b=SOG8jQW43+h9OunYmoHUQ+Kx1c bwKTyR76IEwUqVhwh4DMoO5Vw/HkLkaqI0fItjA90OKGe2S4Zid+wfkHaT92iOTkJ5nhaIuueUzlI WS5WAG+8Yi4x6g2CDyWasFiMA+tZDBuHp8HOfyMPD+SlVkr6rum4ejO6JR/+PI96fylw=; 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=ydEPlabHa6ICXnyKgvFwBDVXY+WLAo+EMYfunz+kz+4=; b=LVqFR5QXnO2isGECw+Vdk+w5/O CyddXWhPVxs4t449VbEEqtWgjrpNsTihUlOCip/REsMWLXDiS5GbNOfs9XdPqb5TgWRCdN4JQU70C 5uh6WIWywUXFWBRKHhHsYaLY0tBeO3jDq4ii+J8AxAdZNm2vVGjNcFUwCTVnaOJhquqc=; Received: from [193.149.48.143] (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 1ufHml-0004rO-Py for openvpn-devel@lists.sourceforge.net; Fri, 25 Jul 2025 12:44:29 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 56PCiF5I020701 for ; Fri, 25 Jul 2025 14:44:15 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 56PCiFo3020700 for openvpn-devel@lists.sourceforge.net; Fri, 25 Jul 2025 14:44:15 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 25 Jul 2025 14:44:09 +0200 Message-ID: <20250725124415.20645-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.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 Most of the are actually the same ones copied to every single plugin. Some drive-by fixes of other warnings and some conversion cleanups that had no warnings because they were suppressed by casts. 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: 1ufHml-0004rO-Py Subject: [Openvpn-devel] [PATCH v1] plugins: Clean up -Wconversion warnings 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?1838622937471754625?= X-GMAIL-MSGID: =?utf-8?q?1838622937471754625?= From: Frank Lichtenheld Most of the are actually the same ones copied to every single plugin. Some drive-by fixes of other warnings and some conversion cleanups that had no warnings because they were suppressed by casts. Change-Id: Id61df43bd79fc794a55e107daa0218c8441c2b2c Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering --- 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/+/1111 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/sample/sample-plugins/client-connect/sample-client-connect.c b/sample/sample-plugins/client-connect/sample-client-connect.c index 18c2c6f..5194270 100644 --- a/sample/sample-plugins/client-connect/sample-client-connect.c +++ b/sample/sample-plugins/client-connect/sample-client-connect.c @@ -86,9 +86,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { @@ -309,7 +308,7 @@ /* do mighty complicated work that will really take time here... */ plugin_log(PLOG_NOTE, MODULE, "in async/deferred handler, sleep(%d)", seconds); - sleep(seconds); + sleep((unsigned int)seconds); /* write config options to openvpn */ int ret = write_cc_options_file(name, envp); diff --git a/sample/sample-plugins/defer/multi-auth.c b/sample/sample-plugins/defer/multi-auth.c index 38db07f..c458346 100644 --- a/sample/sample-plugins/defer/multi-auth.c +++ b/sample/sample-plugins/defer/multi-auth.c @@ -124,9 +124,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { @@ -170,7 +169,7 @@ /* Require a minimum OpenVPN Plugin API */ OPENVPN_EXPORT int -openvpn_plugin_min_version_required_v1() +openvpn_plugin_min_version_required_v1(void) { return OPENVPN_PLUGIN_VERSION_MIN; } @@ -349,9 +348,9 @@ */ /* do mighty complicated work that will really take time here... */ - plog(context, PLOG_NOTE, "in async/deferred handler, usleep(%d)", - context->test_deferred_auth*1000); - usleep(context->test_deferred_auth*1000); + useconds_t wait_time = (useconds_t)context->test_deferred_auth*1000; + plog(context, PLOG_NOTE, "in async/deferred handler, usleep(%u)", wait_time); + usleep(wait_time); /* now signal success state to openvpn */ int fd = open(auth_control_file, O_WRONLY); diff --git a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c index cc256dd..f1f8868 100644 --- a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +++ b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c @@ -69,9 +69,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { diff --git a/sample/sample-plugins/log/log.c b/sample/sample-plugins/log/log.c index 82595cf..b304f16 100644 --- a/sample/sample-plugins/log/log.c +++ b/sample/sample-plugins/log/log.c @@ -52,9 +52,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { diff --git a/sample/sample-plugins/log/log_v3.c b/sample/sample-plugins/log/log_v3.c index c90cc3d..a024027 100644 --- a/sample/sample-plugins/log/log_v3.c +++ b/sample/sample-plugins/log/log_v3.c @@ -55,9 +55,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { diff --git a/sample/sample-plugins/simple/base64.c b/sample/sample-plugins/simple/base64.c index 6855966..e1cc791 100644 --- a/sample/sample-plugins/simple/base64.c +++ b/sample/sample-plugins/simple/base64.c @@ -59,9 +59,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { @@ -175,7 +174,7 @@ /* test the BASE64 encode function */ char *buf = NULL; - int r = ovpn_base64_encode(clcert_cn, strlen(clcert_cn), &buf); + int r = ovpn_base64_encode(clcert_cn, (int)strlen(clcert_cn), &buf); ovpn_log(PLOG_NOTE, PLUGIN_NAME, "BASE64 encoded '%s' (return value %i): '%s'", clcert_cn, r, buf); diff --git a/sample/sample-plugins/simple/simple.c b/sample/sample-plugins/simple/simple.c index e17f3fa..2c096e2 100644 --- a/sample/sample-plugins/simple/simple.c +++ b/sample/sample-plugins/simple/simple.c @@ -54,9 +54,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c index 8692806..7264f95 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -165,31 +165,30 @@ } } -static int -recv_string(int fd, char *buffer, int len) +static ssize_t +recv_string(int fd, char *buffer, size_t len) { if (len > 0) { - ssize_t size; memset(buffer, 0, len); - size = read(fd, buffer, len); + ssize_t size = read(fd, buffer, len); buffer[len-1] = 0; if (size >= 1) { - return (int)size; + return size; } } return -1; } -static int +static ssize_t send_string(int fd, const char *string) { - const int len = strlen(string) + 1; + const size_t len = strlen(string) + 1; const ssize_t size = write(fd, string, len); if (size == len) { - return (int) size; + return size; } else { @@ -645,27 +644,26 @@ * PAM conversation function */ static int -my_conv(int n, const struct pam_message **msg_array, +my_conv(int num_msg, const struct pam_message **msg_array, struct pam_response **response_array, void *appdata_ptr) { const struct user_pass *up = ( const struct user_pass *) appdata_ptr; struct pam_response *aresp; - int i; int ret = PAM_SUCCESS; *response_array = NULL; - if (n <= 0 || n > PAM_MAX_NUM_MSG) + if (num_msg <= 0 || num_msg > PAM_MAX_NUM_MSG) { return (PAM_CONV_ERR); } - if ((aresp = calloc(n, sizeof *aresp)) == NULL) + if ((aresp = calloc((size_t)num_msg, sizeof *aresp)) == NULL) { return (PAM_BUF_ERR); } /* loop through each PAM-module query */ - for (i = 0; i < n; ++i) + for (int i = 0; i < num_msg; ++i) { const struct pam_message *msg = msg_array[i]; aresp[i].resp_retcode = 0; @@ -683,9 +681,9 @@ { /* use name/value list match method */ const struct name_value_list *list = up->name_value_list; - int j; /* loop through name/value pairs */ + int j; /* checked after loop */ for (j = 0; j < list->len; ++j) { const char *match_name = list->data[j].name; diff --git a/src/plugins/auth-pam/utils.c b/src/plugins/auth-pam/utils.c index a6ccfbf..ab5e17e 100644 --- a/src/plugins/auth-pam/utils.c +++ b/src/plugins/auth-pam/utils.c @@ -79,7 +79,7 @@ while (scratch) { - strncat(temp, searching, scratch-searching); + strncat(temp, searching, (size_t)(scratch-searching)); strcat(temp, replacewith); searching = scratch+strlen(searchfor); @@ -93,9 +93,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { diff --git a/src/plugins/down-root/down-root.c b/src/plugins/down-root/down-root.c index 253adcd..2c0faf4 100644 --- a/src/plugins/down-root/down-root.c +++ b/src/plugins/down-root/down-root.c @@ -88,9 +88,8 @@ { if (envp) { - int i; - const int namelen = strlen(name); - for (i = 0; envp[i]; ++i) + const size_t namelen = strlen(name); + for (int i = 0; envp[i]; ++i) { if (!strncmp(envp[i], name, namelen)) { @@ -108,10 +107,10 @@ /* * Return the length of a string array */ -static int +static size_t string_array_len(const char *array[]) { - int i = 0; + size_t i = 0; if (array) { while (array[i]) @@ -141,14 +140,14 @@ } } -static int +static ssize_t send_control(int fd, int code) { unsigned char c = (unsigned char) code; const ssize_t size = write(fd, &c, sizeof(c)); if (size == sizeof(c)) { - return (int) size; + return size; } else { @@ -281,7 +280,6 @@ openvpn_plugin_open_v1(unsigned int *type_mask, const char *argv[], const char *envp[]) { struct down_root_context *context; - int i = 0; /* * Allocate our context @@ -320,7 +318,7 @@ } /* Ignore argv[0], as it contains just the plug-in file name */ - for (i = 1; i < string_array_len(argv); i++) + for (int i = 1; i < string_array_len(argv); i++) { context->command[i-1] = (char *) argv[i]; }