Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd527fda

Browse files
committed
Fix more strcmp() calls using boolean-like comparisons for result checks
Such calls can confuse the reader as strcmp() uses an integer as result.The places patched here have been spotted by Thomas Munro, David Rowleyand myself.Author: Michael PaquierReviewed-by: David RowleyDiscussion:https://postgr.es/m/20190411021946.GG2728@paquier.xyz
1 parent798070e commitd527fda

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

‎contrib/spi/refint.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,12 @@ check_foreign_key(PG_FUNCTION_ARGS)
473473
nv=SPI_getvalue(newtuple,tupdesc,fn);
474474
type=SPI_gettype(tupdesc,fn);
475475

476-
if ((strcmp(type,"text")&&strcmp(type,"varchar")&&
477-
strcmp(type,"char")&&strcmp(type,"bpchar")&&
478-
strcmp(type,"date")&&strcmp(type,"timestamp"))==0)
476+
if (strcmp(type,"text")==0||
477+
strcmp(type,"varchar")==0||
478+
strcmp(type,"char")==0||
479+
strcmp(type,"bpchar")==0||
480+
strcmp(type,"date")==0||
481+
strcmp(type,"timestamp")==0)
479482
is_char_type=1;
480483
#ifdefDEBUG_QUERY
481484
elog(DEBUG4,"check_foreign_key Debug value %s type %s %d",

‎src/backend/commands/lockcmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
219219
* skipped.
220220
*/
221221
if (relid==context->viewoid&&
222-
(!strcmp(rte->eref->aliasname,"old")|| !strcmp(rte->eref->aliasname,"new")))
222+
(strcmp(rte->eref->aliasname,"old")==0||
223+
strcmp(rte->eref->aliasname,"new")==0))
223224
continue;
224225

225226
/* Currently, we only allow plain tables or views to be locked. */

‎src/backend/tsearch/spell.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,8 @@ NISortDictionary(IspellDict *Conf)
17491749
naffix=0;
17501750
for (i=0;i<Conf->nspell;i++)
17511751
{
1752-
if (i==0
1753-
||strcmp(Conf->Spell[i]->p.flag,Conf->Spell[i-1]->p.flag))
1752+
if (i==0||
1753+
strcmp(Conf->Spell[i]->p.flag,Conf->Spell[i-1]->p.flag)!=0)
17541754
naffix++;
17551755
}
17561756

@@ -1764,8 +1764,8 @@ NISortDictionary(IspellDict *Conf)
17641764
curaffix=-1;
17651765
for (i=0;i<Conf->nspell;i++)
17661766
{
1767-
if (i==0
1768-
||strcmp(Conf->Spell[i]->p.flag,Conf->AffixData[curaffix]))
1767+
if (i==0||
1768+
strcmp(Conf->Spell[i]->p.flag,Conf->AffixData[curaffix])!=0)
17691769
{
17701770
curaffix++;
17711771
Assert(curaffix<naffix);

‎src/test/modules/test_rls_hooks/test_rls_hooks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ test_rls_hooks_permissive(CmdType cmdtype, Relation relation)
7575
ParseState*qual_pstate;
7676
RangeTblEntry*rte;
7777

78-
if (strcmp(RelationGetRelationName(relation),"rls_test_permissive")
79-
&&strcmp(RelationGetRelationName(relation),"rls_test_both"))
78+
if (strcmp(RelationGetRelationName(relation),"rls_test_permissive")!=0&&
79+
strcmp(RelationGetRelationName(relation),"rls_test_both")!=0)
8080
returnNIL;
8181

8282
qual_pstate=make_parsestate(NULL);
@@ -140,8 +140,8 @@ test_rls_hooks_restrictive(CmdType cmdtype, Relation relation)
140140
RangeTblEntry*rte;
141141

142142

143-
if (strcmp(RelationGetRelationName(relation),"rls_test_restrictive")
144-
&&strcmp(RelationGetRelationName(relation),"rls_test_both"))
143+
if (strcmp(RelationGetRelationName(relation),"rls_test_restrictive")!=0&&
144+
strcmp(RelationGetRelationName(relation),"rls_test_both")!=0)
145145
returnNIL;
146146

147147
qual_pstate=make_parsestate(NULL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp