Skip to content

Commit

Permalink
reduce nesting, return early on error
Browse files Browse the repository at this point in the history
  • Loading branch information
tenox7 committed Nov 17, 2023
1 parent a7a464e commit 309698a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ttyplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ void paint_plot(void) {
erase();
gethw();

if (window_big_enough_to_draw()) {
if(!window_big_enough_to_draw()) {
show_window_size_error();
sigprocmask(SIG_BLOCK, &sigmsk, NULL);
refresh();
sigprocmask(SIG_UNBLOCK, &sigmsk, NULL);
return;
}

plotheight=height-4;
plotwidth=width-4;
if(plotwidth>=(int)((sizeof(values1)/sizeof(double))-1))
Expand Down Expand Up @@ -214,9 +221,6 @@ if (window_big_enough_to_draw()) {
draw_axes(height, plotheight, plotwidth, max, hardmin, unit);

mvaddstr(0, (width/2)-(strlen(title)/2), title);
} else {
show_window_size_error();
}

move(0,0);
sigprocmask(SIG_BLOCK, &sigmsk, NULL);
Expand Down

0 comments on commit 309698a

Please sign in to comment.