@@ -460,13 +460,18 @@ ncui_signal_cb(int sig)
460460 * possible (and in fact very common) to receive a signal while we're in the
461461 * middle of processing one.
462462 */
463- signal (SIGWINCH , SIG_IGN );
463+ struct sigaction sa = { .sa_handler = SIG_IGN };
464+
465+ sigemptyset (& sa .sa_mask );
466+ sigaction (SIGWINCH , & sa , NULL );
464467
465468 ncui_get_term_size (& y , & x );
466469 resizeterm (y , x );
467470 ncui_redraw ();
468471
469- signal (SIGWINCH , ncui_signal_cb );
472+ sa = (struct sigaction ){ .sa_handler = ncui_signal_cb };
473+ sigemptyset (& sa .sa_mask );
474+ sigaction (SIGWINCH , & sa , NULL );
470475}
471476
472477
@@ -582,12 +587,12 @@ ncui_status_update(bool update)
582587static void
583588ncui_update_time_str (void )
584589{
585- struct tm * tmp ;
590+ struct tm tm_buf ;
586591 time_t t ;
587592
588593 t = time (NULL );
589- tmp = localtime (& t );
590- strftime (btc -> ui -> timeStr , sizeof btc -> ui -> timeStr , "%T" , tmp );
594+ localtime_r (& t , & tm_buf );
595+ strftime (btc -> ui -> timeStr , sizeof btc -> ui -> timeStr , "%T" , & tm_buf );
591596}
592597
593598
@@ -1739,7 +1744,6 @@ ncui_blocklist_update(void)
17391744 ASSERT (mutex_islocked (btcui -> lock ));
17401745
17411746 while (btcui -> blockConsIdx != btcui -> blockProdIdx ) {
1742- char hashStr [80 ];
17431747 uint256 * hash ;
17441748 uint32 timestamp ;
17451749 int height ;
@@ -1752,7 +1756,6 @@ ncui_blocklist_update(void)
17521756 height = btcui -> blocks [btcui -> blockConsIdx ].height ;
17531757 timestamp = btcui -> blocks [btcui -> blockConsIdx ].timestamp ;
17541758
1755- uint256_snprintf_reverse (hashStr , sizeof hashStr , hash );
17561759 ts = print_time_local_short (timestamp );
17571760 orphan = last != -1 && height != last + 1 ;
17581761
@@ -1766,7 +1769,7 @@ ncui_blocklist_update(void)
17661769 mvwaddch (win , 0 , 8 , ACS_VLINE );
17671770 mvwprintw (win , 0 , 10 , "%s" , ts );
17681771 mvwaddch (win , 0 , 26 , ACS_VLINE );
1769- mvwprintw (win , 0 , 28 , "%s" , hashStr );
1772+ mvwprintw (win , 0 , 28 , "%s" , uint256_to_str ( hash ) );
17701773 free (ts );
17711774 panel -> num_lines = MIN (panel -> max_lines , panel -> num_lines + 1 );
17721775 last = height ;
@@ -2121,12 +2124,10 @@ ncui_dashboard_latest_blocks(WINDOW *win,
21212124 uint256 * hash = & btcui -> blocks [idx ].hash ;
21222125 int height = btcui -> blocks [idx ].height ;
21232126 time_t timestamp = btcui -> blocks [idx ].timestamp ;
2124- char hashStr [80 ];
21252127 char * ts ;
21262128 bool orphan ;
21272129
21282130 ts = print_time_local (timestamp , "%T" );
2129- uint256_snprintf_reverse (hashStr , sizeof hashStr , hash );
21302131
21312132 orphan = last != -1 && height != last - 1 && (last - height ) < 100 ;
21322133 wattron (win , orphan ? PAIR_RED : PAIR_YELLOW );
@@ -2136,7 +2137,7 @@ ncui_dashboard_latest_blocks(WINDOW *win,
21362137 mvwprintw (win , y , 10 , "%s" , ts );
21372138 mvwaddch (win , y , 19 , ACS_VLINE );
21382139 wattron (win , A_DIM );
2139- mvwprintw (win , y , 21 , "%s" , hashStr );
2140+ mvwprintw (win , y , 21 , "%s" , uint256_to_str ( hash ) );
21402141 wattroff (win , A_DIM );
21412142 y ++ ;
21422143 free (ts );
@@ -2390,12 +2391,9 @@ ncui_dashboard_header(WINDOW *win,
23902391 mvwprintw (win , y , 1 , "block: " );
23912392
23922393 if (btcui -> numBlocks > 0 ) {
2393- char hashStr [80 ];
23942394
2395- uint256_snprintf_reverse (hashStr , sizeof hashStr ,
2396- & btcui -> blocks [btcui -> blockProdIdx ].hash );
23972395 wattron (win ,A_BOLD );
2398- mvwprintw (win , y , 10 , "%s" , hashStr );
2396+ mvwprintw (win , y , 10 , "%s" , uint256_to_str ( & btcui -> blocks [ btcui -> blockProdIdx ]. hash ) );
23992397 wattroff (win ,A_BOLD );
24002398 }
24012399 y ++ ;
@@ -2601,7 +2599,11 @@ ncui_init(void)
26012599 ncui = safe_calloc (1 , sizeof * ncui );
26022600 btc -> ui = ncui ;
26032601
2604- signal (SIGWINCH , ncui_signal_cb );
2602+ {
2603+ struct sigaction sa = { .sa_handler = ncui_signal_cb };
2604+ sigemptyset (& sa .sa_mask );
2605+ sigaction (SIGWINCH , & sa , NULL );
2606+ }
26052607 ncui_ncurses_init ();
26062608 panic_register_cb (ncui_on_panic_cb , NULL );
26072609 ncui_panel_init ();
0 commit comments