Skip to content

Commit 1a75c1d

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 8cde7f4 commit 1a75c1d

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
@@ -5019,16 +5019,19 @@ set_random_seed(const char *seed)
50195019
}
50205020
else
50215021
{
5022-
/* parse seed unsigned int value */
5022+
/* parse unsigned-int seed value */
5023+
unsigned long ulseed;
50235024
char garbage;
50245025

5025-
if (sscanf(seed, UINT64_FORMAT "%c", &iseed, &garbage) != 1)
5026+
/* Don't try to use UINT64_FORMAT here; it might not work for sscanf */
5027+
if (sscanf(seed, "%lu%c", &ulseed, &garbage) != 1)
50265028
{
50275029
fprintf(stderr,
50285030
"unrecognized random seed option \"%s\": expecting an unsigned integer, \"time\" or \"rand\"\n",
50295031
seed);
50305032
return false;
50315033
}
5034+
iseed = (uint64) ulseed;
50325035
}
50335036

50345037
if (seed != NULL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy