aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_resetwal/pg_resetwal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_resetwal/pg_resetwal.c')
-rw-r--r--src/bin/pg_resetwal/pg_resetwal.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index e7ef2b8bd0c..9bebc2a9958 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -55,6 +55,7 @@
#include "common/logging.h"
#include "common/restricted_token.h"
#include "common/string.h"
+#include "fe_utils/option_utils.h"
#include "getopt_long.h"
#include "pg_getopt.h"
#include "storage/large_object.h"
@@ -290,13 +291,16 @@ main(int argc, char *argv[])
break;
case 1:
- errno = 0;
- set_wal_segsize = strtol(optarg, &endptr, 10) * 1024 * 1024;
- if (endptr == optarg || *endptr != '\0' || errno != 0)
- pg_fatal("argument of --wal-segsize must be a number");
- if (!IsValidWalSegSize(set_wal_segsize))
- pg_fatal("argument of --wal-segsize must be a power of 2 between 1 and 1024");
- break;
+ {
+ int wal_segsize_mb;
+
+ if (!option_parse_int(optarg, "--wal-segsize", 1, 1024, &wal_segsize_mb))
+ exit(1);
+ set_wal_segsize = wal_segsize_mb * 1024 * 1024;
+ if (!IsValidWalSegSize(set_wal_segsize))
+ pg_fatal("argument of %s must be a power of 2 between 1 and 1024", "--wal-segsize");
+ break;
+ }
default:
/* getopt_long already emitted a complaint */