From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 107925A061F; Thu, 07 Nov 2024 19:43:31 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 4/6] util: Define small and big thresholds for socket buffers as unsigned long long Date: Thu, 7 Nov 2024 19:43:29 +0100 Message-ID: <20241107184331.3164784-5-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241107184331.3164784-1-sbrivio@redhat.com> References: <20241107184331.3164784-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: K4JML7W2EP6TKFIDON4OEVEEVGXCFAWW X-Message-ID-Hash: K4JML7W2EP6TKFIDON4OEVEEVGXCFAWW X-MailFrom: sbrivio@passt.top 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: On 32-bit architectures, clang-tidy reports: /home/pi/passt/tcp.c:728:11: error: performing an implicit widening conversion to type 'uint64_t' (aka 'unsigned long long') of a multiplication performed in type 'unsigned long' [bugprone-implicit-widening-of-multiplication-result,-warnings-as-errors] 728 | if (v >= SNDBUF_BIG) | ^ /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) | ^ /home/pi/passt/tcp.c:728:11: note: make conversion explicit to silence this warning 728 | if (v >= SNDBUF_BIG) | ^ /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) | ^~~~~~~~~~~~~~~~~ /home/pi/passt/tcp.c:728:11: note: perform multiplication in a wider type 728 | if (v >= SNDBUF_BIG) | ^ /home/pi/passt/util.h:158:22: note: expanded from macro 'SNDBUF_BIG' 158 | #define SNDBUF_BIG (4UL * 1024 * 1024) | ^~~~~~~~~~ /home/pi/passt/tcp.c:730:15: error: performing an implicit widening conversion to type 'uint64_t' (aka 'unsigned long long') of a multiplication performed in type 'unsigned long' [bugprone-implicit-widening-of-multiplication-result,-warnings-as-errors] 730 | else if (v > SNDBUF_SMALL) | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^ /home/pi/passt/tcp.c:730:15: note: make conversion explicit to silence this warning 730 | else if (v > SNDBUF_SMALL) | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^~~~~~~~~~~~ /home/pi/passt/tcp.c:730:15: note: perform multiplication in a wider type 730 | else if (v > SNDBUF_SMALL) | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^~~~~ /home/pi/passt/tcp.c:731:17: error: performing an implicit widening conversion to type 'uint64_t' (aka 'unsigned long long') of a multiplication performed in type 'unsigned long' [bugprone-implicit-widening-of-multiplication-result,-warnings-as-errors] 731 | v -= v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SNDBUF_SMALL) / 2; | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^ /home/pi/passt/tcp.c:731:17: note: make conversion explicit to silence this warning 731 | v -= v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SNDBUF_SMALL) / 2; | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^~~~~~~~~~~~ /home/pi/passt/tcp.c:731:17: note: perform multiplication in a wider type 731 | v -= v * (v - SNDBUF_SMALL) / (SNDBUF_BIG - SNDBUF_SMALL) / 2; | ^ /home/pi/passt/util.h:159:24: note: expanded from macro 'SNDBUF_SMALL' 159 | #define SNDBUF_SMALL (128UL * 1024) | ^~~~~ because, wherever we use those thresholds, we define the other term of comparison as uint64_t. Define the thresholds as unsigned long long as well, to make sure we match types. Signed-off-by: Stefano Brivio --- util.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util.h b/util.h index 582ef57..963f57b 100644 --- a/util.h +++ b/util.h @@ -158,9 +158,9 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, (void *)(arg)); \ } while (0) -#define RCVBUF_BIG (2UL * 1024 * 1024) -#define SNDBUF_BIG (4UL * 1024 * 1024) -#define SNDBUF_SMALL (128UL * 1024) +#define RCVBUF_BIG (2ULL * 1024 * 1024) +#define SNDBUF_BIG (4ULL * 1024 * 1024) +#define SNDBUF_SMALL (128ULL * 1024) #include #include -- 2.43.0