mirror of
https://github.com/vim/vim.git
synced 2025-09-05 21:43:39 -04:00
patch 8.2.5141: using "volatile int" in a signal handler might be wrong
Problem: Using "volatile int" in a signal handler might be wrong. Solution: Use "volatile sig_atomic_t".
This commit is contained in:
parent
73171ba434
commit
155f2d1451
@ -8251,9 +8251,9 @@ xsmp_close(void)
|
|||||||
/*
|
/*
|
||||||
* Implement timeout with timer_create() and timer_settime().
|
* Implement timeout with timer_create() and timer_settime().
|
||||||
*/
|
*/
|
||||||
static volatile int timeout_flag = FALSE;
|
static volatile sig_atomic_t timeout_flag = FALSE;
|
||||||
static timer_t timer_id;
|
static timer_t timer_id;
|
||||||
static int timer_created = FALSE;
|
static int timer_created = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback for when the timer expires.
|
* Callback for when the timer expires.
|
||||||
@ -8296,7 +8296,7 @@ stop_timeout(void)
|
|||||||
* This function is not expected to fail, but if it does it will still return a
|
* This function is not expected to fail, but if it does it will still return a
|
||||||
* valid flag pointer; the flag will remain stuck as FALSE .
|
* valid flag pointer; the flag will remain stuck as FALSE .
|
||||||
*/
|
*/
|
||||||
volatile int *
|
volatile sig_atomic_t *
|
||||||
start_timeout(long msec)
|
start_timeout(long msec)
|
||||||
{
|
{
|
||||||
struct itimerspec interval = {
|
struct itimerspec interval = {
|
||||||
@ -8347,17 +8347,16 @@ delete_timer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# else
|
# else // HAVE_TIMER_CREATE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implement timeout with setitimer()
|
* Implement timeout with setitimer()
|
||||||
*/
|
*/
|
||||||
static struct itimerval prev_interval;
|
static struct sigaction prev_sigaction;
|
||||||
static struct sigaction prev_sigaction;
|
static volatile sig_atomic_t timeout_flag = FALSE;
|
||||||
static volatile int timeout_flag = FALSE;
|
static int timer_active = FALSE;
|
||||||
static int timer_active = FALSE;
|
static int timer_handler_active = FALSE;
|
||||||
static int timer_handler_active = FALSE;
|
static volatile sig_atomic_t alarm_pending = FALSE;
|
||||||
static int alarm_pending = FALSE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle SIGALRM for a timeout.
|
* Handle SIGALRM for a timeout.
|
||||||
@ -8383,7 +8382,7 @@ stop_timeout(void)
|
|||||||
if (timer_active)
|
if (timer_active)
|
||||||
{
|
{
|
||||||
timer_active = FALSE;
|
timer_active = FALSE;
|
||||||
ret = setitimer(ITIMER_REAL, &disarm, &prev_interval);
|
ret = setitimer(ITIMER_REAL, &disarm, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
// Should only get here as a result of coding errors.
|
// Should only get here as a result of coding errors.
|
||||||
semsg(_(e_could_not_clear_timeout_str), strerror(errno));
|
semsg(_(e_could_not_clear_timeout_str), strerror(errno));
|
||||||
@ -8398,7 +8397,7 @@ stop_timeout(void)
|
|||||||
semsg(_(e_could_not_reset_handler_for_timeout_str),
|
semsg(_(e_could_not_reset_handler_for_timeout_str),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
timeout_flag = 0;
|
timeout_flag = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8412,7 +8411,7 @@ stop_timeout(void)
|
|||||||
* This function is not expected to fail, but if it does it will still return a
|
* This function is not expected to fail, but if it does it will still return a
|
||||||
* valid flag pointer; the flag will remain stuck as FALSE .
|
* valid flag pointer; the flag will remain stuck as FALSE .
|
||||||
*/
|
*/
|
||||||
volatile int *
|
volatile sig_atomic_t *
|
||||||
start_timeout(long msec)
|
start_timeout(long msec)
|
||||||
{
|
{
|
||||||
struct itimerval interval = {
|
struct itimerval interval = {
|
||||||
@ -8461,7 +8460,7 @@ start_timeout(long msec)
|
|||||||
timer_handler_active = TRUE;
|
timer_handler_active = TRUE;
|
||||||
|
|
||||||
// Set up the interval timer once the alarm handler is in place.
|
// Set up the interval timer once the alarm handler is in place.
|
||||||
ret = setitimer(ITIMER_REAL, &interval, &prev_interval);
|
ret = setitimer(ITIMER_REAL, &interval, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
// Should only get here as a result of coding errors.
|
// Should only get here as a result of coding errors.
|
||||||
|
@ -8334,9 +8334,9 @@ static int timer_active = FALSE;
|
|||||||
* deleted. Ping-ponging between the two flags prevents this causing 'fake'
|
* deleted. Ping-ponging between the two flags prevents this causing 'fake'
|
||||||
* timeouts.
|
* timeouts.
|
||||||
*/
|
*/
|
||||||
static int timeout_flags[2];
|
static sig_atomic_t timeout_flags[2];
|
||||||
static int timeout_flag_idx = 0;
|
static int timeout_flag_idx = 0;
|
||||||
static int *timeout_flag = &timeout_flags[0];
|
static sig_atomic_t *timeout_flag = &timeout_flags[0];
|
||||||
|
|
||||||
|
|
||||||
static void CALLBACK
|
static void CALLBACK
|
||||||
@ -8378,7 +8378,7 @@ stop_timeout(void)
|
|||||||
* This function is not expected to fail, but if it does it still returns a
|
* This function is not expected to fail, but if it does it still returns a
|
||||||
* valid flag pointer; the flag will remain stuck at zero.
|
* valid flag pointer; the flag will remain stuck at zero.
|
||||||
*/
|
*/
|
||||||
volatile int *
|
volatile sig_atomic_t *
|
||||||
start_timeout(long msec)
|
start_timeout(long msec)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
@ -87,6 +87,6 @@ int xsmp_handle_requests(void);
|
|||||||
void xsmp_init(void);
|
void xsmp_init(void);
|
||||||
void xsmp_close(void);
|
void xsmp_close(void);
|
||||||
void stop_timeout(void);
|
void stop_timeout(void);
|
||||||
volatile int *start_timeout(long msec);
|
volatile sig_atomic_t *start_timeout(long msec);
|
||||||
void delete_timer(void);
|
void delete_timer(void);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -85,5 +85,5 @@ int get_conpty_fix_type(void);
|
|||||||
void resize_console_buf(void);
|
void resize_console_buf(void);
|
||||||
char *GetWin32Error(void);
|
char *GetWin32Error(void);
|
||||||
void stop_timeout(void);
|
void stop_timeout(void);
|
||||||
volatile int *start_timeout(long msec);
|
volatile sig_atomic_t *start_timeout(long msec);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_RELTIME
|
#ifdef FEAT_RELTIME
|
||||||
static int dummy_timeout_flag = 0;
|
static sig_atomic_t dummy_timeout_flag = 0;
|
||||||
static volatile int *timeout_flag = &dummy_timeout_flag;
|
static volatile sig_atomic_t *timeout_flag = &dummy_timeout_flag;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
5141,
|
||||||
/**/
|
/**/
|
||||||
5140,
|
5140,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user