Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cce5387

Browse files
macdiceCommitfest Bot
authored and
Commitfest Bot
committed
pgbench: Rationalize types in parseScriptWeight().
This function wants to parse a 64 bit number, but complain if it's out of range for int, and include the number in the error message. OK, but long is not always bigger than int, so it won't work the same on all systems (and the cast to long long in the error message won't really make it longer). Parse an int64 with strtoi64(), and print it out with PRId64, so now it will behave the same everywhere.
1 parent 80ad850 commit cce5387

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6201,7 +6201,7 @@ parseScriptWeight(const char *option, char **script)
62016201
if ((sep = strrchr(option, WSEP)))
62026202
{
62036203
int namelen = sep - option;
6204-
long wtmp;
6204+
int64 wtmp;
62056205
char *badp;
62066206

62076207
/* generate the script name */
@@ -6211,12 +6211,12 @@ parseScriptWeight(const char *option, char **script)
62116211

62126212
/* process digits of the weight spec */
62136213
errno = 0;
6214-
wtmp = strtol(sep + 1, &badp, 10);
6214+
wtmp = strtoi64(sep + 1, &badp, 10);
62156215
if (errno != 0 || badp == sep + 1 || *badp != '\0')
62166216
pg_fatal("invalid weight specification: %s", sep);
62176217
if (wtmp > INT_MAX || wtmp < 0)
6218-
pg_fatal("weight specification out of range (0 .. %d): %lld",
6219-
INT_MAX, (long long) wtmp);
6218+
pg_fatal("weight specification out of range (0 .. %d): %" PRId64,
6219+
INT_MAX, wtmp);
62206220
weight = wtmp;
62216221
}
62226222
else

0 commit comments

Comments
 (0)