forked from Imagelibrary/rtems
psignalclearsignals.c: Eliminate used before initialized warning
There were independent checks at lock/unlock time on whether the signal clearing logic executed in a critical section. Refactored so the two checks are now one. Closes #5239
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 1989-2007.
|
* COPYRIGHT (c) 1989-2025.
|
||||||
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -50,21 +50,19 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _POSIX_signals_Clear_signals
|
* Having a helper makes the flow analysis easier and avoids
|
||||||
|
* seeing "maybe used uninitialized" for queue_context.
|
||||||
*/
|
*/
|
||||||
|
static bool _POSIX_signals_Clear_signals_helper(
|
||||||
bool _POSIX_signals_Clear_signals(
|
|
||||||
POSIX_API_Control *api,
|
POSIX_API_Control *api,
|
||||||
int signo,
|
int signo,
|
||||||
siginfo_t *info,
|
siginfo_t *info,
|
||||||
bool is_global,
|
bool is_global,
|
||||||
bool check_blocked,
|
bool check_blocked
|
||||||
bool do_signals_acquire_release
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
sigset_t signals_unblocked;
|
sigset_t signals_unblocked;
|
||||||
Thread_queue_Context queue_context;
|
|
||||||
bool do_callout;
|
bool do_callout;
|
||||||
POSIX_signals_Siginfo_node *psiginfo;
|
POSIX_signals_Siginfo_node *psiginfo;
|
||||||
|
|
||||||
@@ -84,11 +82,6 @@ bool _POSIX_signals_Clear_signals(
|
|||||||
/* XXX is this right for siginfo type signals? */
|
/* XXX is this right for siginfo type signals? */
|
||||||
/* XXX are we sure they can be cleared the same way? */
|
/* XXX are we sure they can be cleared the same way? */
|
||||||
|
|
||||||
if ( do_signals_acquire_release ) {
|
|
||||||
_Thread_queue_Context_initialize( &queue_context );
|
|
||||||
_POSIX_signals_Acquire( &queue_context );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_global ) {
|
if ( is_global ) {
|
||||||
if ( mask & (_POSIX_signals_Pending & signals_unblocked) ) {
|
if ( mask & (_POSIX_signals_Pending & signals_unblocked) ) {
|
||||||
if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
|
if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
|
||||||
@@ -119,9 +112,44 @@ bool _POSIX_signals_Clear_signals(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( do_signals_acquire_release ) {
|
|
||||||
_POSIX_signals_Release( &queue_context );
|
|
||||||
}
|
|
||||||
|
|
||||||
return do_callout;
|
return do_callout;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* _POSIX_signals_Clear_signals
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool _POSIX_signals_Clear_signals(
|
||||||
|
POSIX_API_Control *api,
|
||||||
|
int signo,
|
||||||
|
siginfo_t *info,
|
||||||
|
bool is_global,
|
||||||
|
bool check_blocked,
|
||||||
|
bool do_signals_acquire_release
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool retval;
|
||||||
|
Thread_queue_Context queue_context;
|
||||||
|
|
||||||
|
if ( do_signals_acquire_release ) {
|
||||||
|
_Thread_queue_Context_initialize( &queue_context );
|
||||||
|
_POSIX_signals_Acquire( &queue_context );
|
||||||
|
retval = _POSIX_signals_Clear_signals_helper(
|
||||||
|
api,
|
||||||
|
signo,
|
||||||
|
info,
|
||||||
|
is_global,
|
||||||
|
check_blocked
|
||||||
|
);
|
||||||
|
_POSIX_signals_Release( &queue_context );
|
||||||
|
} else {
|
||||||
|
retval = _POSIX_signals_Clear_signals_helper(
|
||||||
|
api,
|
||||||
|
signo,
|
||||||
|
info,
|
||||||
|
is_global,
|
||||||
|
check_blocked
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user