From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id C24A95A0051 for ; Thu, 06 Jun 2024 12:10:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1717668601; bh=adkVNUv5KkNQA+7C+a+KGmAr/lT7LRQfOafUiciaHcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ttj7nDsbRy6BlXTybqJtXlCaDeG335uItb3vxXD4K7z1oJfZKB9kP65SuuBhyqu3Y RVYm0oE8DAyJ6I0YkCimwWxmEWwlNv9f5u9p850KjFO8C0C3DG/SRcxz0yrrZZ5dkB iXaLRRpYd7fLfwEDHqCTAwXSF8/WzrM+yPetLDFCxWh3tSyJhVTMR8ntbRdHXdXqST 0pl0lEbcUxDtRt7HNCqMS+BqAoJIhEkTaG4RwA6VLzqvNKSEz71KZYq8KDZicNCtGf ZltGRjlTfGSE9wkI2dSzX7EDRDaQNj9XsDggXhYzhygN5jrCocoxNbsmp5wInYpJH1 SBxWuOOXgA8NQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Vw0ST3VMZz4wyj; Thu, 6 Jun 2024 20:10:01 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 2/9] udp: Make rport calculation more local Date: Thu, 6 Jun 2024 20:09:42 +1000 Message-ID: <20240606100949.1250958-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606100949.1250958-1-david@gibson.dropbear.id.au> References: <20240606100949.1250958-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FRQYXRPYPEFNM53R5QJQ2RI3SHQEU5PU X-Message-ID-Hash: FRQYXRPYPEFNM53R5QJQ2RI3SHQEU5PU X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: cppcheck 2.14.1 complains about the rport variable not being in as small as scope as it could be. It's also only used once, so we might as well just open code the calculation for it. Signed-off-by: David Gibson --- udp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/udp.c b/udp.c index 3abafc99..61e106a9 100644 --- a/udp.c +++ b/udp.c @@ -277,10 +277,9 @@ static void udp_invert_portmap(struct udp_fwd_ports *fwd) "Forward and reverse delta arrays must have same size"); for (i = 0; i < ARRAY_SIZE(fwd->f.delta); i++) { in_port_t delta = fwd->f.delta[i]; - in_port_t rport = i + delta; if (delta) - fwd->rdelta[rport] = NUM_PORTS - delta; + fwd->rdelta[i + delta] = NUM_PORTS - delta; } } -- 2.45.2