Skip to content

Commit bfd3f37

Browse files
committed
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.
1 parent 48a1fb2 commit bfd3f37

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/backend/regex/regc_lex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ lexescape(struct vars * v)
846846
if (ISERR())
847847
FAILW(REG_EESCAPE);
848848
/* ugly heuristic (first test is "exactly 1 digit?") */
849-
if (v->now - save == 0 || ((int) c > 0 && (int) c <= v->nsubexp))
849+
if (v->now == save || ((int) c > 0 && (int) c <= v->nsubexp))
850850
{
851851
NOTE(REG_UBACKREF);
852852
RETV(BACKREF, (chr) c);

src/backend/utils/adt/tsrank.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ getWeights(ArrayType *win)
395395
int i;
396396
float4 *arrdata;
397397

398-
if (win == 0)
398+
if (win == NULL)
399399
return weights;
400400

401401
if (ARR_NDIM(win) != 1)

src/backend/utils/fmgr/dfmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ find_in_dynamic_libpath(const char *basename)
616616
(errcode(ERRCODE_INVALID_NAME),
617617
errmsg("zero-length component in parameter \"dynamic_library_path\"")));
618618

619-
if (piece == 0)
619+
if (piece == NULL)
620620
len = strlen(p);
621621
else
622622
len = piece - p;

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
576576
{
577577
size_t res;
578578

579-
if (th->zFH != 0)
579+
if (th->zFH != NULL)
580580
res = GZWRITE((void *) buf, 1, len, th->zFH);
581581
else
582582
res = fwrite(buf, 1, len, th->nFH);

src/port/dirmod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pgsymlink(const char *oldpath, const char *newpath)
246246
else
247247
strcpy(nativeTarget, oldpath);
248248

249-
while ((p = strchr(p, '/')) != 0)
249+
while ((p = strchr(p, '/')) != NULL)
250250
*p++ = '\\';
251251

252252
len = strlen(nativeTarget) * sizeof(WCHAR);

src/timezone/zic.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ associate(void)
810810
* Note, though, that if there's no rule, a '%s' in the format is
811811
* a bad thing.
812812
*/
813-
if (strchr(zp->z_format, '%') != 0)
813+
if (strchr(zp->z_format, '%') != NULL)
814814
error(_("%s in ruleless zone"));
815815
}
816816
}
@@ -1111,9 +1111,9 @@ inzsub(char **fields, int nfields, int iscont)
11111111
z.z_filename = filename;
11121112
z.z_linenum = linenum;
11131113
z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UTC offset"), TRUE);
1114-
if ((cp = strchr(fields[i_format], '%')) != 0)
1114+
if ((cp = strchr(fields[i_format], '%')) != NULL)
11151115
{
1116-
if (*++cp != 's' || strchr(cp, '%') != 0)
1116+
if (*++cp != 's' || strchr(cp, '%') != NULL)
11171117
{
11181118
error(_("invalid abbreviation format"));
11191119
return FALSE;
@@ -1438,9 +1438,9 @@ rulesub(struct rule * rp, const char *loyearp, const char *hiyearp,
14381438
}
14391439
else
14401440
{
1441-
if ((ep = strchr(dp, '<')) != 0)
1441+
if ((ep = strchr(dp, '<')) != NULL)
14421442
rp->r_dycode = DC_DOWLEQ;
1443-
else if ((ep = strchr(dp, '>')) != 0)
1443+
else if ((ep = strchr(dp, '>')) != NULL)
14441444
rp->r_dycode = DC_DOWGEQ;
14451445
else
14461446
{
@@ -2826,7 +2826,7 @@ mkdirs(char *argname)
28262826
if (argname == NULL || *argname == '\0')
28272827
return 0;
28282828
cp = name = ecpyalloc(argname);
2829-
while ((cp = strchr(cp + 1, '/')) != 0)
2829+
while ((cp = strchr(cp + 1, '/')) != NULL)
28302830
{
28312831
*cp = '\0';
28322832
#ifdef WIN32

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