public inbox for [email protected]  
help / color / mirror / Atom feed
BUG: test_bloomfilter error message reports wrong variable and wrong format specifier
2+ messages / 2 participants
[nested] [flat]

* BUG: test_bloomfilter error message reports wrong variable and wrong format specifier
@ 2026-03-24 12:31 Jianghua Yang <[email protected]>
  2026-03-24 14:34 ` Re: BUG: test_bloomfilter error message reports wrong variable and wrong format specifier Nathan Bossart <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Jianghua Yang @ 2026-03-24 12:31 UTC (permalink / raw)
  To: [email protected]

Hi,

  I found a small bug in
src/test/modules/test_bloomfilter/test_bloomfilter.c, line 128.

  The current code:

  int64   nelements = PG_GETARG_INT64(1);
  int     tests = PG_GETARG_INT32(3);

  if (tests <= 0)
      elog(ERROR, "invalid number of tests: %d", tests);

  if (nelements < 0)
      elog(ERROR, "invalid number of elements: %d", tests);

  The second elog has two issues:

  1. It checks nelements but prints tests. For example, with
  nelements = -1 and tests = 1, the error message would be
  "invalid number of elements: 1" — which is misleading when debugging.
  2. nelements is int64, so the format specifier should be
  INT64_FORMAT rather than %d. Using %d for int64 is
  undefined behavior on 32-bit platforms.

  The fix:

  if (nelements < 0)
      elog(ERROR, "invalid number of elements: " INT64_FORMAT, nelements);

  A patch is attached.

  Regards,
  Jianghua Yang


Attachments:

  [application/octet-stream] v1-0001-Fix-wrong-variable-and-format-specifier-in-test_b.patch (1.2K, 3-v1-0001-Fix-wrong-variable-and-format-specifier-in-test_b.patch)
  download | inline diff:
From 2277fdd00175e6158b6863c3c57a5bf73082333c Mon Sep 17 00:00:00 2001
From: Jianghua Yang <[email protected]>
Date: Mon, 23 Mar 2026 18:29:49 -0700
Subject: [PATCH v1] Fix wrong variable and format specifier in
 test_bloomfilter error message

When checking for an invalid number of elements, the error message
incorrectly reported the value of the 'tests' variable instead of
'nelements'.  Additionally, 'nelements' is of type int64, so the
format specifier should be INT64_FORMAT rather than %d.

Author: Jianghua Yang <[email protected]>
---
 src/test/modules/test_bloomfilter/test_bloomfilter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/modules/test_bloomfilter/test_bloomfilter.c b/src/test/modules/test_bloomfilter/test_bloomfilter.c
index 4e072183604..df41066138c 100644
--- a/src/test/modules/test_bloomfilter/test_bloomfilter.c
+++ b/src/test/modules/test_bloomfilter/test_bloomfilter.c
@@ -125,7 +125,7 @@ test_bloomfilter(PG_FUNCTION_ARGS)
 		elog(ERROR, "invalid number of tests: %d", tests);
 
 	if (nelements < 0)
-		elog(ERROR, "invalid number of elements: %d", tests);
+		elog(ERROR, "invalid number of elements: " INT64_FORMAT, nelements);
 
 	for (i = 0; i < tests; i++)
 	{
-- 
2.50.1 (Apple Git-155)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG: test_bloomfilter error message reports wrong variable and wrong format specifier
  2026-03-24 12:31 BUG: test_bloomfilter error message reports wrong variable and wrong format specifier Jianghua Yang <[email protected]>
@ 2026-03-24 14:34 ` Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Nathan Bossart @ 2026-03-24 14:34 UTC (permalink / raw)
  To: Jianghua Yang <[email protected]>; +Cc: [email protected]

On Tue, Mar 24, 2026 at 05:31:55AM -0700, Jianghua Yang wrote:
>   A patch is attached.

Committed, thanks.

-- 
nathan





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-03-24 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-24 12:31 BUG: test_bloomfilter error message reports wrong variable and wrong format specifier Jianghua Yang <[email protected]>
2026-03-24 14:34 ` Nathan Bossart <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox