diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-29 15:51:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-29 15:51:52 -0400 |
commit | bfd3f37be309c3647844aed937e6a66aad5fd3cb (patch) | |
tree | 5bc39a02df05c848eb88e300a25ef83af4cd43b6 /src | |
parent | 48a1fb23900d73e7d9cb2dc0408c745cd03597a7 (diff) | |
download | postgresql-bfd3f37be309c3647844aed937e6a66aad5fd3cb.tar.gz postgresql-bfd3f37be309c3647844aed937e6a66aad5fd3cb.zip |
Fix comparisons of pointers with zero to compare with NULL instead.
Per C standard, these are semantically the same thing; but saying NULL
when you mean NULL is good for readability.
Marti Raudsepp, per results of INRIA's Coccinelle.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/regex/regc_lex.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/tsrank.c | 2 | ||||
-rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 2 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_backup_tar.c | 2 | ||||
-rw-r--r-- | src/port/dirmod.c | 2 | ||||
-rw-r--r-- | src/timezone/zic.c | 12 |
6 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c index da3ff0bf384..3360cfb0e9f 100644 --- a/src/backend/regex/regc_lex.c +++ b/src/backend/regex/regc_lex.c @@ -846,7 +846,7 @@ lexescape(struct vars * v) if (ISERR()) FAILW(REG_EESCAPE); /* ugly heuristic (first test is "exactly 1 digit?") */ - if (v->now - save == 0 || ((int) c > 0 && (int) c <= v->nsubexp)) + if (v->now == save || ((int) c > 0 && (int) c <= v->nsubexp)) { NOTE(REG_UBACKREF); RETV(BACKREF, (chr) c); diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index d61bcdd4266..b0417de1262 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -395,7 +395,7 @@ getWeights(ArrayType *win) int i; float4 *arrdata; - if (win == 0) + if (win == NULL) return weights; if (ARR_NDIM(win) != 1) diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 566ac46bd7a..d08fdddde2f 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -616,7 +616,7 @@ find_in_dynamic_libpath(const char *basename) (errcode(ERRCODE_INVALID_NAME), errmsg("zero-length component in parameter \"dynamic_library_path\""))); - if (piece == 0) + if (piece == NULL) len = strlen(p); else len = piece - p; diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index d7e4c463dd8..006f7dab72e 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -576,7 +576,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th) { size_t res; - if (th->zFH != 0) + if (th->zFH != NULL) res = GZWRITE((void *) buf, 1, len, th->zFH); else res = fwrite(buf, 1, len, th->nFH); diff --git a/src/port/dirmod.c b/src/port/dirmod.c index a8b8a904df9..7ab3c9a0271 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -246,7 +246,7 @@ pgsymlink(const char *oldpath, const char *newpath) else strcpy(nativeTarget, oldpath); - while ((p = strchr(p, '/')) != 0) + while ((p = strchr(p, '/')) != NULL) *p++ = '\\'; len = strlen(nativeTarget) * sizeof(WCHAR); diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 00ca6faab41..8a95d6ac3f7 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -810,7 +810,7 @@ associate(void) * Note, though, that if there's no rule, a '%s' in the format is * a bad thing. */ - if (strchr(zp->z_format, '%') != 0) + if (strchr(zp->z_format, '%') != NULL) error(_("%s in ruleless zone")); } } @@ -1111,9 +1111,9 @@ inzsub(char **fields, int nfields, int iscont) z.z_filename = filename; z.z_linenum = linenum; z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UTC offset"), TRUE); - if ((cp = strchr(fields[i_format], '%')) != 0) + if ((cp = strchr(fields[i_format], '%')) != NULL) { - if (*++cp != 's' || strchr(cp, '%') != 0) + if (*++cp != 's' || strchr(cp, '%') != NULL) { error(_("invalid abbreviation format")); return FALSE; @@ -1438,9 +1438,9 @@ rulesub(struct rule * rp, const char *loyearp, const char *hiyearp, } else { - if ((ep = strchr(dp, '<')) != 0) + if ((ep = strchr(dp, '<')) != NULL) rp->r_dycode = DC_DOWLEQ; - else if ((ep = strchr(dp, '>')) != 0) + else if ((ep = strchr(dp, '>')) != NULL) rp->r_dycode = DC_DOWGEQ; else { @@ -2826,7 +2826,7 @@ mkdirs(char *argname) if (argname == NULL || *argname == '\0') return 0; cp = name = ecpyalloc(argname); - while ((cp = strchr(cp + 1, '/')) != 0) + while ((cp = strchr(cp + 1, '/')) != NULL) { *cp = '\0'; #ifdef WIN32 |