From patchwork Sun Sep 7 21:12:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4396 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:b149:b0:671:5a2c:6455 with SMTP id s9csp746615maw; Sun, 7 Sep 2025 14:13:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX7kthwvsS5zJ/KkHyu75uRgwnRj50lGenPkMQM2NZwh4xz2vV8CZapjKMYCNpBc2MHmLc5ZkWRGwY=@openvpn.net X-Google-Smtp-Source: AGHT+IHNUjmycoEDm+Qug0R/CU7ostorGespQ0BSoVu1FbNlGtP+BlIJjLV6Si4mpZ8lqs2gprmF X-Received: by 2002:a05:6808:14c5:b0:439:1192:c278 with SMTP id 5614622812f47-43b29b0a1a4mr2989632b6e.44.1757279595960; Sun, 07 Sep 2025 14:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1757279595; cv=none; d=google.com; s=arc-20240605; b=TY1iVCs+CCJtMpxX+D54HXA12Nt2yTvKIbDce4W5G1kfdK+ozxcytI3X6GqJaj1PT6 T1HgCmmZ5rWKe4y02LZhCIEDffIiG7tsQOjYRhMCQ8uM/gfSWqQ6/hFVC1e5/j5g4V7F n0wLFC7DA5Oq7uAhYWdh1Wv3+2xiziOQ1pj0wAx/O5seWHYmj/T75qkIWoCGUHjFNuia //oxzpBnDi1iRq7EnQn+ifq6aan8VUQww0w6cF7RFjgLYnGcdCj8o8DfPpEZREtoAj1Q fFirq8r3LNSdS84Oj+6i1XuGsAZLlnS6Q2lUelgEwGG/8JhLr6cesk2d/XHkrFYid3RN HZtA== 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=kPWMcbPpUAiNozxAOo0kNuGtd0WBcT1374bPAXzBAHg=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=NE2LQng0AKUZw7lgZnddjVGWzYvGvYju4BHYa5/tnwwbYIuV9KvFXGYAktWKPia4+v 4PyIJuoS8RQaq9Kj2W4PmLr0FLpKLF/rPzqj4+KTmQCKCIisMkW5iNIXbMhqUD3EOIzh pYUpOPjkWjhoPWPSelNKY9/0+7GsmAHr6Qz0z8ZORfoak1wYUwX9DpnBYQtmq4gjPw0B jEl6Gndc9E/c3KBj2A3cppMTN50rmiKO9oIO89iHwig2MfSR1kcvyv4AO24qtlXY89UB wV8EtF2tGBB3o0UPwaQxZ2e7Dw0+rXPDmp35GEnIaBwfOEjEQiBNuXFb+l7bYicdT+rj W5PA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=isDUe+9J; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YiyqbDDf; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="aPH/etk+"; 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-319b60cf78asi3950743fac.295.2025.09.07.14.13.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Sep 2025 14:13:15 -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=isDUe+9J; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YiyqbDDf; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="aPH/etk+"; 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=kPWMcbPpUAiNozxAOo0kNuGtd0WBcT1374bPAXzBAHg=; b=isDUe+9J3LHHGCqX6OmW0mF7yD Ua/Ykg7ntNtCb9DxKB/6m6gPHugIUwEYK1FFI/rFN1xPOdcGZYsC3iTjsCccS0MuaWFR/3a48WoVm nugupO/hNUZC2SIvM55fti2T2A7GCyua3Fzu9W7Ha+Ovloq7q3Vj+F2FhFfxXUQgpQNY=; 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 1uvMh7-0005Eo-UZ; Sun, 07 Sep 2025 21:13:06 +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 1uvMh6-0005Ec-VE for openvpn-devel@lists.sourceforge.net; Sun, 07 Sep 2025 21:13:05 +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=v0uUAEd+zz1MyRZN0Mo97+/KEC/PLdDr3NitnSb5OGk=; b=YiyqbDDfadh7KfKWIsPVFIw8Ng 84c4E4Tfilus8JJCjsTAPc2ozyvlTSHY5vstyp9GVg43GlbH90oBSXYdBPVkfBLJiqqbjyybtEo7X NWgviHOvDvj5tI+Gj2c6Efisqt5cQfv99xka7pFrJiiXZc20r+I3EP/e7Y66jGXCGPn8=; 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=v0uUAEd+zz1MyRZN0Mo97+/KEC/PLdDr3NitnSb5OGk=; b=aPH/etk+Yv+D7Yh5N8UN5rQBe0 jgH9S7mJpjC+nmVFQ1reYQN9qyrm+w/Id9ZpiVjwm7XKxSSmLA7ngYTQkQlRBM5Vr13mlMA97Jued GI2FLbhpRGn794s4dusjM0BpjsDySfNoxqWWjUwJCE926sQ3Km0uVfp3srlh9wEAcmLo=; 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 1uvMh6-0007zR-Lh for openvpn-devel@lists.sourceforge.net; Sun, 07 Sep 2025 21:13:05 +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 587LCqBU023939 for ; Sun, 7 Sep 2025 23:12:52 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 587LCqO4023938 for openvpn-devel@lists.sourceforge.net; Sun, 7 Sep 2025 23:12:52 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 7 Sep 2025 23:12:46 +0200 Message-ID: <20250907211252.23924-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: OpenVPN's ASSERT() macro will do a bit more than the standard-libc assert() call, namely print out which function and what expression failed, before calling _exit(1). Also, it can not be accidentially [...] 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: 1uvMh6-0007zR-Lh Subject: [Openvpn-devel] [PATCH v1] replace assert() calls with ASSERT() 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?1842641209396469171?= X-GMAIL-MSGID: =?utf-8?q?1842641209396469171?= OpenVPN's ASSERT() macro will do a bit more than the standard-libc assert() call, namely print out which function and what expression failed, before calling _exit(1). Also, it can not be accidentially compiled-away (-DNDEBUG). Use of ASSERT() generally only advised in cases of "this must not happen, but if it does, it's a programming or state corruption error that we must know about". Use of assert() is lacking the extra debug info, and as such, not advised at all. Change-Id: I6480d6f741c2368a0d951004b91167d5943f8f9d Signed-off-by: Gert Doering Acked-by: mandree --- 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/+/1171 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): mandree diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 931f9f6..65303cd 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -100,7 +100,7 @@ in->sin_len = sizeof(*in); data = nvlist_get_binary(nvl, "address", &len); - assert(len == sizeof(in->sin_addr)); + ASSERT(len == sizeof(in->sin_addr)); memcpy(&in->sin_addr, data, sizeof(in->sin_addr)); in->sin_port = nvlist_get_number(nvl, "port"); break; @@ -114,7 +114,7 @@ in6->sin6_len = sizeof(*in6); data = nvlist_get_binary(nvl, "address", &len); - assert(len == sizeof(in6->sin6_addr)); + ASSERT(len == sizeof(in6->sin6_addr)); memcpy(&in6->sin6_addr, data, sizeof(in6->sin6_addr)); in6->sin6_port = nvlist_get_number(nvl, "port"); diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 39ea8e4..2821cd4 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -319,7 +319,7 @@ static unsigned int management_callback_remote_entry_count(void *arg) { - assert(arg); + ASSERT(arg); struct context *c = (struct context *)arg; struct connection_list *l = c->options.connection_list; @@ -329,8 +329,8 @@ static bool management_callback_remote_entry_get(void *arg, unsigned int index, char **remote) { - assert(arg); - assert(remote); + ASSERT(arg); + ASSERT(remote); struct context *c = (struct context *)arg; struct connection_list *l = c->options.connection_list; diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0616a17..6858a69 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3486,9 +3486,9 @@ { /* Copy --dhcp-options to tuntap_options */ struct dhcp_options *dhcp = &dns->from_dhcp; - assert(sizeof(dhcp->dns) == sizeof(tt->dns)); - assert(sizeof(dhcp->dns6) == sizeof(tt->dns6)); - assert(sizeof(dhcp->domain_search_list) == sizeof(tt->domain_search_list)); + ASSERT(sizeof(dhcp->dns) == sizeof(tt->dns)); + ASSERT(sizeof(dhcp->dns6) == sizeof(tt->dns6)); + ASSERT(sizeof(dhcp->domain_search_list) == sizeof(tt->domain_search_list)); tt->domain = dhcp->domain; tt->dns_len = dhcp->dns_len;