Skip to content

Commit 7e5569f

Browse files
committed
Fix unportable code in pgbench.
The buildfarm points out that UINT64_FORMAT might not work with sscanf; it's calibrated for our printf implementation, which might not agree with the platform-supplied sscanf. Fall back to just accepting an unsigned long, which is already more than the documentation promises. Oversight in e6c3ba7; back-patch to v11, as that was.
1 parent 76097b4 commit 7e5569f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,16 +4742,19 @@ set_random_seed(const char *seed)
47424742
}
47434743
else
47444744
{
4745-
/* parse seed unsigned int value */
4745+
/* parse unsigned-int seed value */
4746+
unsigned long ulseed;
47464747
char garbage;
47474748

4748-
if (sscanf(seed, UINT64_FORMAT "%c", &iseed, &garbage) != 1)
4749+
/* Don't try to use UINT64_FORMAT here; it might not work for sscanf */
4750+
if (sscanf(seed, "%lu%c", &ulseed, &garbage) != 1)
47494751
{
47504752
fprintf(stderr,
47514753
"unrecognized random seed option \"%s\": expecting an unsigned integer, \"time\" or \"rand\"\n",
47524754
seed);
47534755
return false;
47544756
}
4757+
iseed = (uint64) ulseed;
47554758
}
47564759

47574760
if (seed != NULL)

0 commit comments

Comments
 (0)