Skip to content

Commit

Permalink
signals: suppress -Wsign-conversion on macOS
Browse files Browse the repository at this point in the history
On macOS, we get:
```
signals.c: In function 'signals_init':
signals.c:76:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   76 |                 sigaddset(&hooked_signals, sigs[i]);
      |                 ^~~~~~~~~
signals.c:81:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   81 |                 sigaddset(&hooked_signals, message_progress_sigs[i]);
      |                 ^~~~~~~~~
signals.c:86:9: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   86 |         sigaddset(&hooked_signals, SIGTSTP);
      |         ^~~~~~~~~
```

We use `int` for `hooked_signals` but we can't just cast to whatever
`sigset_t` is because `sigset_t` is an opaque type. It's an unsigned int
on macOS. On macOS, `sigaddset` is implemented as a macro.

Just suppress -Wsign-conversion for `signals_init` for macOS given
there's no real nice way of fixing this.
  • Loading branch information
thesamesam committed Apr 11, 2024
1 parent bfb711b commit e5b5dec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/xz/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ signal_handler(int sig)
}


#ifdef __APPLE__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
extern void
signals_init(void)
{
Expand Down Expand Up @@ -127,6 +131,9 @@ signals_init(void)

return;
}
#ifdef __APPLE__
# pragma GCC diagnostic pop
#endif


#ifndef __VMS
Expand Down

0 comments on commit e5b5dec

Please sign in to comment.