diff options
| author | Peter Eisentraut | 2024-10-01 13:30:24 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2024-10-01 13:30:24 +0000 |
| commit | 10b721821d6d6e27e594549cf105476dc28514c8 (patch) | |
| tree | 52d7fba71044f7c2edcb41fe222777f6500c189d /src/include | |
| parent | fc1b2ce0ee9c9745c5c562b692e021344a3f719a (diff) | |
Use macro to define the number of enum values
Refactoring in the interest of code consistency, a follow-up to 2e068db56e31.
The argument against inserting a special enum value at the end of the enum
definition is that a switch statement might generate a compiler warning unless
it has a default clause.
Aleksander Alekseev, reviewed by Michael Paquier, Dean Rasheed, Peter Eisentraut
Discussion: https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/storage/pmsignal.h | 4 | ||||
| -rw-r--r-- | src/include/storage/procsignal.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/include/storage/pmsignal.h b/src/include/storage/pmsignal.h index 87ac91848bc..e5be0f121c2 100644 --- a/src/include/storage/pmsignal.h +++ b/src/include/storage/pmsignal.h @@ -40,10 +40,10 @@ typedef enum PMSIGNAL_BACKGROUND_WORKER_CHANGE, /* background worker state change */ PMSIGNAL_START_WALRECEIVER, /* start a walreceiver */ PMSIGNAL_ADVANCE_STATE_MACHINE, /* advance postmaster's state machine */ - - NUM_PMSIGNALS /* Must be last value of enum! */ } PMSignalReason; +#define NUM_PMSIGNALS (PMSIGNAL_ADVANCE_STATE_MACHINE+1) + /* * Reasons why the postmaster would send SIGQUIT to its children. */ diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h index f94c11a9a84..221073def38 100644 --- a/src/include/storage/procsignal.h +++ b/src/include/storage/procsignal.h @@ -47,10 +47,10 @@ typedef enum PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, PROCSIG_RECOVERY_CONFLICT_LAST = PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, - - NUM_PROCSIGNALS /* Must be last! */ } ProcSignalReason; +#define NUM_PROCSIGNALS (PROCSIG_RECOVERY_CONFLICT_LAST + 1) + typedef enum { PROCSIGNAL_BARRIER_SMGRRELEASE, /* ask smgr to close files */ |
