src: use '#define's instead of global variables for integer constants

By doing this, it is no longer necessary to invoke `unused_var()` to
squelch compiler warnings about unused variables that are used only in
`assert()` calls. These `assert()` calls are removed by the preprocessor
in release builds, which causes these warnings.
This commit is contained in:
Bert Belder 2020-06-09 21:08:00 +02:00
parent 1c549c3ab7
commit 98decd24e2
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461
3 changed files with 9 additions and 11 deletions

View File

@ -10,7 +10,7 @@
#include "util.h"
#include "win.h"
static const size_t POLL_GROUP__MAX_GROUP_SIZE = 32;
#define POLL_GROUP__MAX_GROUP_SIZE 32
typedef struct poll_group {
port_state_t* port_state;

View File

@ -8,11 +8,11 @@
#include "win.h"
/* clang-format off */
static const long REFLOCK__REF = (long) 0x00000001;
static const long REFLOCK__REF_MASK = (long) 0x0fffffff;
static const long REFLOCK__DESTROY = (long) 0x10000000;
static const long REFLOCK__DESTROY_MASK = (long) 0xf0000000;
static const long REFLOCK__POISON = (long) 0x300dead0;
#define REFLOCK__REF ((long) 0x00000001UL)
#define REFLOCK__REF_MASK ((long) 0x0fffffffUL)
#define REFLOCK__DESTROY ((long) 0x10000000UL)
#define REFLOCK__DESTROY_MASK ((long) 0xf0000000UL)
#define REFLOCK__POISON ((long) 0x300dead0UL)
/* clang-format on */
static HANDLE reflock__keyed_event = NULL;
@ -49,7 +49,6 @@ void reflock_ref(reflock_t* reflock) {
/* Verify that the counter didn't overflow and the lock isn't destroyed. */
assert((state & REFLOCK__DESTROY_MASK) == 0);
unused_var(state);
unused_var(REFLOCK__DESTROY_MASK);
}
void reflock_unref(reflock_t* reflock) {
@ -57,7 +56,6 @@ void reflock_unref(reflock_t* reflock) {
/* Verify that the lock was referenced and not already destroyed. */
assert((state & REFLOCK__DESTROY_MASK & ~REFLOCK__DESTROY) == 0);
unused_var(REFLOCK__DESTROY_MASK);
if (state == REFLOCK__DESTROY)
reflock__signal_event(reflock);

View File

@ -15,9 +15,9 @@
#include "wepoll.h"
#include "ws.h"
static const uint32_t SOCK__KNOWN_EPOLL_EVENTS =
EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM |
EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP;
#define SOCK__KNOWN_EPOLL_EVENTS \
(EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM | \
EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP)
typedef enum sock__poll_status {
SOCK__POLL_IDLE = 0,