Skip to content

Commit

Permalink
fixed compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmorgner committed Apr 9, 2020
1 parent 78a7c11 commit 5e79a2a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/opensc-notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ static int cancellation_fd[] = {-1, -1};

void sig_handler(int sig) {
run_daemon = 0;
write(cancellation_fd[1], &sig, sizeof sig);
if (-1 == write(cancellation_fd[1], &sig, sizeof sig)) {
fprintf(stderr, "Failed immediate cancellation: %s", strerror(errno));

This comment has been minimized.

Copy link
@saper

saper Apr 14, 2020

Contributor

Small nitpick: According to sigaction(2) (and also signal-safety(7) on Linux) fprintf(3) is not safe when used in the signal handler and may clobber some stdio buffers. write(2) is fine. Would casting output from write to (void) quell the warning as well?

This comment has been minimized.

Copy link
@frankmorgner

frankmorgner Apr 23, 2020

Author Member

Indeed, thanks. 843779f

This comment has been minimized.

Copy link
@lsteube

lsteube Apr 28, 2020

@frankmorgner Compile error is back. This is on Ubuntu 18.04 with

gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

opensc-notify.c:192:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
  (void)write(cancellation_fd[1], &sig, sizeof sig);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This comment has been minimized.

Copy link
@frankmorgner

frankmorgner Apr 28, 2020

Author Member

pushed once more... 7936bde

This comment has been minimized.

Copy link
@saper

saper May 7, 2020

Contributor

These things became very hard these days, thanks for handling this @frankmorgner

}
}

static void *cancellation_proc(void *arg)
Expand Down

0 comments on commit 5e79a2a

Please sign in to comment.