refactor: use c99 struct initializers to enhance readability
This commit is contained in:
parent
775db50538
commit
dd55afad68
3 changed files with 18 additions and 18 deletions
|
@ -922,12 +922,10 @@ static int curl_download_internal_sandboxed(alpm_handle_t *handle,
|
||||||
{
|
{
|
||||||
int pid, err = 0, ret = -1, callbacks_fd[2];
|
int pid, err = 0, ret = -1, callbacks_fd[2];
|
||||||
sigset_t oldblock;
|
sigset_t oldblock;
|
||||||
struct sigaction sa_ign, oldint, oldquit;
|
struct sigaction sa_ign = { .sa_handler = SIG_IGN }, oldint, oldquit;
|
||||||
_alpm_sandbox_callback_context callbacks_ctx;
|
_alpm_sandbox_callback_context callbacks_ctx;
|
||||||
|
|
||||||
sigemptyset(&sa_ign.sa_mask);
|
sigemptyset(&sa_ign.sa_mask);
|
||||||
sa_ign.sa_handler = SIG_IGN;
|
|
||||||
sa_ign.sa_flags=0;
|
|
||||||
|
|
||||||
if(pipe(callbacks_fd) != 0) {
|
if(pipe(callbacks_fd) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -590,9 +590,7 @@ void _alpm_reset_signals(void)
|
||||||
#endif
|
#endif
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
struct sigaction def;
|
struct sigaction def = { .sa_handler = SIG_DFL };
|
||||||
def.sa_flags = 0;
|
|
||||||
def.sa_handler = SIG_DFL;
|
|
||||||
sigemptyset(&def.sa_mask);
|
sigemptyset(&def.sa_mask);
|
||||||
for(i = signals; *i; i++) {
|
for(i = signals; *i; i++) {
|
||||||
sigaction(*i, &def, NULL);
|
sigaction(*i, &def, NULL);
|
||||||
|
|
|
@ -40,10 +40,8 @@ static ssize_t xwrite(int fd, const void *buf, size_t count)
|
||||||
|
|
||||||
static void _reset_handler(int signum)
|
static void _reset_handler(int signum)
|
||||||
{
|
{
|
||||||
struct sigaction new_action;
|
struct sigaction new_action = { .sa_handler = SIG_DFL };
|
||||||
sigemptyset(&new_action.sa_mask);
|
sigemptyset(&new_action.sa_mask);
|
||||||
new_action.sa_handler = SIG_DFL;
|
|
||||||
new_action.sa_flags = 0;
|
|
||||||
sigaction(signum, &new_action, NULL);
|
sigaction(signum, &new_action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +74,11 @@ static void soft_interrupt_handler(int signum)
|
||||||
|
|
||||||
void install_soft_interrupt_handler(void)
|
void install_soft_interrupt_handler(void)
|
||||||
{
|
{
|
||||||
struct sigaction new_action;
|
struct sigaction new_action = {
|
||||||
new_action.sa_handler = soft_interrupt_handler;
|
.sa_handler = soft_interrupt_handler,
|
||||||
new_action.sa_flags = SA_RESTART;
|
.sa_flags = SA_RESTART,
|
||||||
|
};
|
||||||
|
|
||||||
sigemptyset(&new_action.sa_mask);
|
sigemptyset(&new_action.sa_mask);
|
||||||
sigaddset(&new_action.sa_mask, SIGINT);
|
sigaddset(&new_action.sa_mask, SIGINT);
|
||||||
sigaddset(&new_action.sa_mask, SIGHUP);
|
sigaddset(&new_action.sa_mask, SIGHUP);
|
||||||
|
@ -118,10 +118,12 @@ static void segv_handler(int signum)
|
||||||
|
|
||||||
void install_segv_handler(void)
|
void install_segv_handler(void)
|
||||||
{
|
{
|
||||||
struct sigaction new_action;
|
struct sigaction new_action = {
|
||||||
new_action.sa_handler = segv_handler;
|
.sa_handler = segv_handler,
|
||||||
|
.sa_flags = SA_RESTART,
|
||||||
|
};
|
||||||
|
|
||||||
sigfillset(&new_action.sa_mask);
|
sigfillset(&new_action.sa_mask);
|
||||||
new_action.sa_flags = SA_RESTART;
|
|
||||||
sigaction(SIGSEGV, &new_action, NULL);
|
sigaction(SIGSEGV, &new_action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +135,11 @@ static void winch_handler(int signum)
|
||||||
|
|
||||||
void install_winch_handler(void)
|
void install_winch_handler(void)
|
||||||
{
|
{
|
||||||
struct sigaction new_action;
|
struct sigaction new_action = {
|
||||||
new_action.sa_handler = winch_handler;
|
.sa_handler = winch_handler,
|
||||||
|
.sa_flags = SA_RESTART,
|
||||||
|
};
|
||||||
|
|
||||||
sigemptyset(&new_action.sa_mask);
|
sigemptyset(&new_action.sa_mask);
|
||||||
new_action.sa_flags = SA_RESTART;
|
|
||||||
sigaction(SIGWINCH, &new_action, NULL);
|
sigaction(SIGWINCH, &new_action, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue