server/server: Fix build on FreeBSD

On FreeBSD, sig_atomic_t is of type 'long' rather than 'int'. Remove
the assert() instead of replacing it with a more complex, size-agnostic
check that would handle both 'int' and 'long'. Since the signal number
comes from the operating system, an explicit range check is unnecessary.

Checkpatch-ignore: COMMIT_LOG_LONG_LINE

Build error on FreeBSD:

../src/server/server.c:616:39: error: result of comparison of constant 9223372036854775807 with expression of type 'int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  616 |                 assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
      |                                                 ~~~ ^  ~~~~~~~~~~~~~~
/usr/include/assert.h:55:21: note: expanded from macro 'assert'
   55 | #define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
      |                           ^
../src/server/server.c:616:14: error: result of comparison of constant -9223372036854775808 with expression of type 'int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  616 |                 assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
      |                        ~~~ ^  ~~~~~~~~~~~~~~
/usr/include/assert.h:55:21: note: expanded from macro 'assert'
   55 | #define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \

Change-Id: I6cf9242ab8206184bff9390ef0245843261656bd
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9477
Reviewed-by: Anatoly P <kupokupokupopo@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
Marc Schink
2026-02-26 10:14:34 +01:00
committed by Antonio Borneo
parent 22e1e1b33e
commit e4c49d8605

View File

@@ -613,7 +613,6 @@ static void sig_handler(int sig)
/* store only first signal that hits us */
if (shutdown_openocd == CONTINUE_MAIN_LOOP) {
shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE;
assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
last_signal = sig;
LOG_DEBUG("Terminating on Signal %d", sig);
} else