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

Commitd97b14d

Browse files
committed
Silence compiler warnings
Rearrange a bit of code to ensure that 'mode' in LWLockRelease isobviously always set, which seems a bit cleaner and avoids a compilerwarning (thanks to Robert for the suggestion!).In GetCachedPlan(), initialize 'plan' to silence a compiler warning, butalso add an Assert() to make sure we don't ever actually fall throughwith 'plan' still being set to NULL, since we are about to dereferenceit.Neither of these appear to be live bugs but at least gcc5.4.0-6ubuntu1~16.04.4 doesn't quite have the smarts to realize that.Discussion:https://www.postgresql.org/message-id/20161129152102.GR13284%40tamriel.snowman.net
1 parent0645dac commitd97b14d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,15 +1780,14 @@ LWLockRelease(LWLock *lock)
17801780
* be the latest-acquired lock; so search array backwards.
17811781
*/
17821782
for (i=num_held_lwlocks;--i >=0;)
1783-
{
17841783
if (lock==held_lwlocks[i].lock)
1785-
{
1786-
mode=held_lwlocks[i].mode;
17871784
break;
1788-
}
1789-
}
1785+
17901786
if (i<0)
17911787
elog(ERROR,"lock %s %d is not held",T_NAME(lock),T_ID(lock));
1788+
1789+
mode=held_lwlocks[i].mode;
1790+
17921791
num_held_lwlocks--;
17931792
for (;i<num_held_lwlocks;i++)
17941793
held_lwlocks[i]=held_lwlocks[i+1];

‎src/backend/utils/cache/plancache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ CachedPlan *
11281128
GetCachedPlan(CachedPlanSource*plansource,ParamListInfoboundParams,
11291129
booluseResOwner)
11301130
{
1131-
CachedPlan*plan;
1131+
CachedPlan*plan=NULL;
11321132
List*qlist;
11331133
boolcustomplan;
11341134

@@ -1210,6 +1210,8 @@ GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams,
12101210
}
12111211
}
12121212

1213+
Assert(plan!=NULL);
1214+
12131215
/* Flag the plan as in use by caller */
12141216
if (useResOwner)
12151217
ResourceOwnerEnlargePlanCacheRefs(CurrentResourceOwner);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp