0001-Cleanup-Compare-pointers-to-NULL-instead-of-0.patch
text/x-patch
Filename: 0001-Cleanup-Compare-pointers-to-NULL-instead-of-0.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Cleanup: Compare pointers to NULL instead of 0
| File | + | − |
|---|---|---|
| src/backend/utils/adt/tsrank.c | 1 | 1 |
| src/backend/utils/fmgr/dfmgr.c | 1 | 1 |
| src/bin/pg_dump/pg_backup_tar.c | 1 | 1 |
| src/port/dirmod.c | 1 | 1 |
| src/timezone/zic.c | 6 | 6 |
From 0e939e93935995e9d47f04698903ae427834c257 Mon Sep 17 00:00:00 2001
From: Marti Raudsepp <marti@juffo.org>
Date: Fri, 29 Oct 2010 18:59:44 +0300
Subject: [PATCH] Cleanup: Compare pointers to NULL instead of 0
Most of these were discovered with Coccinelle (badzero.cocci from
coccicheck)
Marti Raudsepp
---
src/backend/utils/adt/tsrank.c | 2 +-
src/backend/utils/fmgr/dfmgr.c | 2 +-
src/bin/pg_dump/pg_backup_tar.c | 2 +-
src/port/dirmod.c | 2 +-
src/timezone/zic.c | 12 ++++++------
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index d61bcdd..b0417de 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 566ac46..d08fddd 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 d7e4c46..006f7da 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 a8b8a90..7ab3c9a 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 00ca6fa..8a95d6a 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
--
1.7.3.2