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

Commit8110728

Browse files
committed
Change return type of ExceptionalCondition to void and mark it noreturn
In ancient times, it was thought that this wouldn't work because ofTrapMacro/AssertMacro, but changing those to use a comma operatorappears to work without compiler warnings.
1 parent2227bb9 commit8110728

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

‎src/backend/utils/error/assert.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121

2222
/*
2323
* ExceptionalCondition - Handles the failure of an Assert()
24-
*
25-
* Note: this can't actually return, but we declare it as returning int
26-
* because the TrapMacro() macro might get wonky otherwise.
2724
*/
28-
int
25+
void
2926
ExceptionalCondition(constchar*conditionName,
3027
constchar*errorType,
3128
constchar*fileName,
@@ -55,6 +52,4 @@ ExceptionalCondition(const char *conditionName,
5552
#endif
5653

5754
abort();
58-
59-
return0;
6055
}

‎src/backend/utils/error/elog.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,15 +1507,9 @@ pg_re_throw(void)
15071507
errfinish(0);
15081508
}
15091509

1510-
/*We mustn't return... */
1510+
/*Doesn't return... */
15111511
ExceptionalCondition("pg_re_throw tried to return","FailedAssertion",
15121512
__FILE__,__LINE__);
1513-
1514-
/*
1515-
* Since ExceptionalCondition isn't declared noreturn because of
1516-
* TrapMacro(), we need this to keep gcc from complaining.
1517-
*/
1518-
abort();
15191513
}
15201514

15211515

‎src/include/postgres.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,14 @@ extern PGDLLIMPORT bool assert_enabled;
655655
/*
656656
*TrapMacro is the same as Trap but it's intended for use in macros:
657657
*
658-
*#define foo(x) (AssertMacro(x != 0) && bar(x))
658+
*#define foo(x) (AssertMacro(x != 0), bar(x))
659659
*
660660
*Isn't CPP fun?
661661
*/
662662
#defineTrapMacro(condition,errorType) \
663663
((bool) ((! assert_enabled) || ! (condition) || \
664664
(ExceptionalCondition(CppAsString(condition), (errorType), \
665-
__FILE__, __LINE__))))
665+
__FILE__, __LINE__), 0)))
666666

667667
#ifndefUSE_ASSERT_CHECKING
668668
#defineAssert(condition)
@@ -683,8 +683,8 @@ extern PGDLLIMPORT bool assert_enabled;
683683
Trap(!(condition), "BadState")
684684
#endif/* USE_ASSERT_CHECKING */
685685

686-
externintExceptionalCondition(constchar*conditionName,
686+
externvoidExceptionalCondition(constchar*conditionName,
687687
constchar*errorType,
688-
constchar*fileName,intlineNumber);
688+
constchar*fileName,intlineNumber) __attribute__((noreturn));
689689

690690
#endif/* POSTGRES_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp