0001-Cleanup-Simplify-comparisons-a-b-0-to-a-b.patch
text/x-patch
Filename: 0001-Cleanup-Simplify-comparisons-a-b-0-to-a-b.patch
Type: text/x-patch
Part: 0
Message:
[PATCH] More Coccinelli cleanups
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: Simplify comparisons (a - b == 0) to (a == b)
| File | + | − |
|---|---|---|
| contrib/pgcrypto/crypt-des.c | 2 | 2 |
| src/backend/access/gin/gindatapage.c | 2 | 2 |
| src/backend/regex/regc_lex.c | 1 | 1 |
| src/timezone/zic.c | 1 | 1 |
From aadcc5c31df00e940a89abf392e7c71b54e00b6a Mon Sep 17 00:00:00 2001
From: Marti Raudsepp <marti@juffo.org>
Date: Sat, 30 Oct 2010 01:27:06 +0300
Subject: [PATCH 1/2] Cleanup: Simplify comparisons (a - b == 0) to (a == b)
This change was done using Coccinelle using the following spatch:
virtual org,diff
@@
expression a, b;
@@
(
- a - b == 0
+ a == b
|
- a - b != 0
+ a != b
)
Marti Raudsepp
---
contrib/pgcrypto/crypt-des.c | 4 ++--
src/backend/access/gin/gindatapage.c | 4 ++--
src/backend/regex/regc_lex.c | 2 +-
src/timezone/zic.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c
index 1f49743..fc3c0e3 100644
--- a/contrib/pgcrypto/crypt-des.c
+++ b/contrib/pgcrypto/crypt-des.c
@@ -669,7 +669,7 @@ px_crypt_des(const char *key, const char *setting)
* zeros.
*/
q = (uint8 *) keybuf;
- while (q - (uint8 *) keybuf - 8)
+ while (q - (uint8 *) keybuf != 8)
{
if ((*q++ = *key << 1))
key++;
@@ -702,7 +702,7 @@ px_crypt_des(const char *key, const char *setting)
* And XOR with the next 8 characters of the key.
*/
q = (uint8 *) keybuf;
- while (q - (uint8 *) keybuf - 8 && *key)
+ while (q - (uint8 *) keybuf != 8 && *key)
*q++ ^= *key++ << 1;
if (des_setkey((char *) keybuf))
diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c
index f74373c..d0873ce 100644
--- a/src/backend/access/gin/gindatapage.c
+++ b/src/backend/access/gin/gindatapage.c
@@ -285,7 +285,7 @@ GinDataPageAddItem(Page page, void *data, OffsetNumber offset)
else
{
ptr = GinDataPageGetItem(page, offset);
- if (maxoff + 1 - offset != 0)
+ if (maxoff + 1 != offset)
memmove(ptr + GinSizeOfItem(page), ptr, (maxoff - offset + 1) * GinSizeOfItem(page));
}
memcpy(ptr, data, GinSizeOfItem(page));
@@ -494,7 +494,7 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
else
{
ptr = vector + (off - 1) * sizeofitem;
- if (maxoff + 1 - off != 0)
+ if (maxoff + 1 != off)
memmove(ptr + sizeofitem, ptr, (maxoff - off + 1) * sizeofitem);
if (GinPageIsLeaf(lpage))
{
diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c
index da3ff0b..3360cfb 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/timezone/zic.c b/src/timezone/zic.c
index 8a95d6a..694b45a 100644
--- a/src/timezone/zic.c
+++ b/src/timezone/zic.c
@@ -2780,7 +2780,7 @@ newabbr(const char *string)
while (isascii((unsigned char) *cp) &&
isalpha((unsigned char) *cp))
++cp;
- if (cp - string == 0)
+ if (cp == string)
wp = _("time zone abbreviation lacks alphabetic at start");
if (noise && cp - string > 3)
wp = _("time zone abbreviation has more than 3 alphabetics");
--
1.7.3.2