Skip to content

Commit d63d486

Browse files
committed
Remove assertions that some compiler say are tautological
To avoid the compiler warnings: launch_backend.c:211:39: warning: comparison of constant 16 with expression of type 'BackendType' (aka 'enum BackendType') is always true [-Wtautological-constant-out-of-range-compare] launch_backend.c:233:39: warning: comparison of constant 16 with expression of type 'BackendType' (aka 'enum BackendType') is always true [-Wtautological-constant-out-of-range-compare] The point of the assertions was to fail more explicitly if someone adds a new BackendType to the end of the enum, but forgets to add it to the child_process_kinds array. It was a pretty weak assertion to begin with, because it wouldn't catch if you added a new BackendType in the middle of the enum. So let's just remove it. Per buildfarm member ayu and a few others, spotted by Tom Lane. Discussion: https://www.postgresql.org/message-id/4119680.1710913067@sss.pgh.pa.us
1 parent 9578393 commit d63d486

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/backend/postmaster/launch_backend.c

-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ child_process_kind child_process_kinds[] = {
208208
const char *
209209
PostmasterChildName(BackendType child_type)
210210
{
211-
Assert(child_type >= 0 && child_type < lengthof(child_process_kinds));
212211
return child_process_kinds[child_type].name;
213212
}
214213

@@ -230,7 +229,6 @@ postmaster_child_launch(BackendType child_type,
230229
{
231230
pid_t pid;
232231

233-
Assert(child_type >= 0 && child_type < lengthof(child_process_kinds));
234232
Assert(IsPostmasterEnvironment && !IsUnderPostmaster);
235233

236234
#ifdef EXEC_BACKEND

src/include/miscadmin.h

+3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ extern void SwitchBackToLocalLatch(void);
326326

327327
/*
328328
* MyBackendType indicates what kind of a backend this is.
329+
*
330+
* If you add entries, please also update the child_process_kinds array in
331+
* launch_backend.c.
329332
*/
330333
typedef enum BackendType
331334
{

0 commit comments

Comments
 (0)