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

Commit43ef6ab

Browse files
committed
Improve unreachability recognition in elog() macro.
Some experimentation with an older version of gcc showed that it is ableto determine whether "if (elevel_ >= ERROR)" is compile-time constantif elevel_ is declared "const", but otherwise not so much. We hadaccounted for that in ereport() but were too miserly with braces tomake it so in elog(). I don't know how many currently-interestingcompilers have the same quirk, but in case it will save some codespace, let's make sure that elog() is on the same footing as ereport()for this purpose.Back-patch to 9.3 where we introduced pg_unreachable() calls intoelog/ereport.
1 parentbca6eeb commit43ef6ab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎src/include/utils/elog.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,13 @@ extern intgetinternalerrposition(void);
216216
#else/* !HAVE__BUILTIN_CONSTANT_P */
217217
#defineelog(elevel, ...) \
218218
do { \
219-
intelevel_; \
220219
elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \
221-
elevel_ = (elevel); \
222-
elog_finish(elevel_, __VA_ARGS__); \
223-
if (elevel_ >= ERROR) \
224-
pg_unreachable(); \
220+
{ \
221+
const int elevel_ = (elevel); \
222+
elog_finish(elevel_, __VA_ARGS__); \
223+
if (elevel_ >= ERROR) \
224+
pg_unreachable(); \
225+
} \
225226
} while(0)
226227
#endif/* HAVE__BUILTIN_CONSTANT_P */
227228
#else/* !HAVE__VA_ARGS */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp