Skip to content

Commit

Permalink
fix invalid usage of stderr and incorrect formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Oct 25, 2020
1 parent 3cdcfbf commit b2fb9db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
wprintw(self->window, " Online: ");
wattroff(self->window, A_BOLD);

wprintw(self->window, "%d/%d \n\n", Friends.num_online, Friends.num_friends);
wprintw(self->window, "%zu/%zu \n\n", Friends.num_online, Friends.num_friends);

if ((y2 - FLIST_OFST) <= 0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/line_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void line_info_print(ToxWindow *self)
}
}

wprintw(win, "\n", line->msg);
wprintw(win, "\n");
break;

case OUT_ACTION_READ:
Expand Down
10 changes: 4 additions & 6 deletions src/toxic.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ static void catch_SIGSEGV(int sig)
{
UNUSED_VAR(sig);

if (!freopen("/dev/tty", "w", stderr)) { // make sure stderr is enabled since we may have disabled it
fprintf(stderr, "Warning: Failed to enable stderr\n");
if (freopen("/dev/tty", "w", stderr)) { // make sure stderr is enabled since we may have disabled it
fprintf(stderr, "Caught SIGSEGV: Aborting toxic session.\n");
}

endwin();
fprintf(stderr, "Caught SIGSEGV: Aborting toxic session.\n");
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -216,12 +215,11 @@ void exit_toxic_err(const char *errmsg, int errcode)
{
free_global_data();

if (!freopen("/dev/tty", "w", stderr)) {
fprintf(stderr, "Warning: Failed to open stderr\n");
if (freopen("/dev/tty", "w", stderr)) {
fprintf(stderr, "Toxic session aborted with error code %d (%s)\n", errcode, errmsg);
}

endwin();
fprintf(stderr, "Toxic session aborted with error code %d (%s)\n", errcode, errmsg);
exit(EXIT_FAILURE);
}

Expand Down

0 comments on commit b2fb9db

Please sign in to comment.