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

Commitcdddd5d

Browse files
committed
Add compiler hints to PLy_elog()
Decorate PLy_elog() in a similar way as elog(), to give compilers andstatic analyzers hints in which cases it does not return.Reviewed-by: John Naylor <jcnaylor@gmail.com>
1 parenteaedf0d commitcdddd5d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎src/pl/plpython/plpy_elog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static bool set_string_attr(PyObject *obj, char *attrname, char *str);
4444
* in the context.
4545
*/
4646
void
47-
PLy_elog(intelevel,constchar*fmt,...)
47+
PLy_elog_impl(intelevel,constchar*fmt,...)
4848
{
4949
char*xmsg;
5050
char*tbmsg;

‎src/pl/plpython/plpy_elog.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@ extern PyObject *PLy_exc_error;
1010
externPyObject*PLy_exc_fatal;
1111
externPyObject*PLy_exc_spi_error;
1212

13-
externvoidPLy_elog(intelevel,constchar*fmt,...)pg_attribute_printf(2,3);
13+
/*
14+
* PLy_elog()
15+
*
16+
* See comments at elog() about the compiler hinting.
17+
*/
18+
#ifdefHAVE__VA_ARGS
19+
#ifdefHAVE__BUILTIN_CONSTANT_P
20+
#definePLy_elog(elevel, ...) \
21+
do { \
22+
PLy_elog_impl(elevel, __VA_ARGS__); \
23+
if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \
24+
pg_unreachable(); \
25+
} while(0)
26+
#else/* !HAVE__BUILTIN_CONSTANT_P */
27+
#definePLy_elog(elevel, ...) \
28+
do { \
29+
const int elevel_ = (elevel); \
30+
PLy_elog_impl(elevel_, __VA_ARGS__); \
31+
if (elevel_ >= ERROR) \
32+
pg_unreachable(); \
33+
} while(0)
34+
#endif/* HAVE__BUILTIN_CONSTANT_P */
35+
#else/* !HAVE__VA_ARGS */
36+
#definePLy_elog PLy_elog_impl
37+
#endif/* HAVE__VA_ARGS */
38+
39+
externvoidPLy_elog_impl(intelevel,constchar*fmt,...)pg_attribute_printf(2,3);
1440

1541
externvoidPLy_exception_set(PyObject*exc,constchar*fmt,...)pg_attribute_printf(2,3);
1642

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp