diff options
author | Fujii Masao <fujii@postgresql.org> | 2015-07-02 10:35:38 +0900 |
---|---|---|
committer | Fujii Masao <fujii@postgresql.org> | 2015-07-02 10:35:38 +0900 |
commit | fb174687f7a730edcf301949785a6ac0dbfd70d0 (patch) | |
tree | aeacb3bcf839aefba61500c8fee43e6fb38627a0 /src/bin/pg_resetxlog/pg_resetxlog.c | |
parent | 1e24cf645d24aab3ea39a9d259897fd0cae4e4b6 (diff) | |
download | postgresql-fb174687f7a730edcf301949785a6ac0dbfd70d0.tar.gz postgresql-fb174687f7a730edcf301949785a6ac0dbfd70d0.zip |
Make use of xlog_internal.h's macros in WAL-related utilities.
Commit 179cdd09 added macros to check if a filename is a WAL segment
or other such file. However there were still some instances of the
strlen + strspn combination to check for that in WAL-related utilities
like pg_archivecleanup. Those checks can be replaced with the macros.
This patch makes use of the macros in those utilities and
which would make the code a bit easier to read.
Back-patch to 9.5.
Michael Paquier
Diffstat (limited to 'src/bin/pg_resetxlog/pg_resetxlog.c')
-rw-r--r-- | src/bin/pg_resetxlog/pg_resetxlog.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 6ffe795348d..e19a72b4c16 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -261,7 +261,7 @@ main(int argc, char *argv[]) break; case 'l': - if (strspn(optarg, "01234567890ABCDEFabcdef") != 24) + if (strspn(optarg, "01234567890ABCDEFabcdef") != XLOG_FNAME_LEN) { fprintf(stderr, _("%s: invalid argument for option %s\n"), progname, "-l"); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); @@ -976,8 +976,7 @@ KillExistingXLOG(void) while (errno = 0, (xlde = readdir(xldir)) != NULL) { - if (strlen(xlde->d_name) == 24 && - strspn(xlde->d_name, "0123456789ABCDEF") == 24) + if (IsXLogFileName(xlde->d_name)) { snprintf(path, MAXPGPATH, "%s/%s", XLOGDIR, xlde->d_name); if (unlink(path) < 0) @@ -1027,9 +1026,9 @@ KillExistingArchiveStatus(void) while (errno = 0, (xlde = readdir(xldir)) != NULL) { - if (strspn(xlde->d_name, "0123456789ABCDEF") == 24 && - (strcmp(xlde->d_name + 24, ".ready") == 0 || - strcmp(xlde->d_name + 24, ".done") == 0)) + if (strspn(xlde->d_name, "0123456789ABCDEF") == XLOG_FNAME_LEN && + (strcmp(xlde->d_name + XLOG_FNAME_LEN, ".ready") == 0 || + strcmp(xlde->d_name + XLOG_FNAME_LEN, ".done") == 0)) { snprintf(path, MAXPGPATH, "%s/%s", ARCHSTATDIR, xlde->d_name); if (unlink(path) < 0) |