diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-06-24 11:44:45 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-06-24 11:44:45 +0200 |
commit | 8f07ac3d5056d115e7befe2391b0a73ec06c02c9 (patch) | |
tree | 246e1a542fae19663a029c8a425c60dbffad4874 | |
parent | 24faaa2a26c813ef83129fb7539017692e6f6966 (diff) |
disable gcc FD diagnostics when they clearly fail around fork() and dup2()
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 29 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_batch-withdraw.c | 18 |
2 files changed, 33 insertions, 14 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index ce35f5adf..4165111a9 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -2371,9 +2371,17 @@ run_fake_client (void) pid_t cld; char ports[6]; int fd; - - if (0 == strcmp (input_filename, - "-")) + bool use_stdin; + + /* Duping to STDIN and fork() mess up gcc's analysis + badly, disable diagnostics. */ +#pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#pragma GCC diagnostic ignored "-Wanalyzer-fd-double-close" +#pragma GCC diagnostic ignored "-Wanalyzer-fd-use-after-close" + use_stdin = (0 == strcmp (input_filename, + "-")); + if (use_stdin) fd = STDIN_FILENO; else fd = open (input_filename, @@ -2394,10 +2402,12 @@ run_fake_client (void) serve_port); if (0 == (cld = fork ())) { - if (STDIN_FILENO != fd) + if (! use_stdin) { - GNUNET_break (0 == close (0)); - GNUNET_break (0 == dup2 (fd, 0)); + GNUNET_break (0 == close (STDIN_FILENO)); + GNUNET_break (STDIN_FILENO == + dup2 (fd, + STDIN_FILENO)); GNUNET_break (0 == close (fd)); } if ( (0 != execlp ("nc", @@ -2420,10 +2430,13 @@ run_fake_client (void) _exit (1); } /* parent process */ - if (0 != strcmp (input_filename, - "-")) + if (! use_stdin) GNUNET_break (0 == close (fd)); return cld; +#pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#pragma GCC diagnostic pop +#pragma GCC diagnostic pop } diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c index 2b80c2fc4..b743e4e2a 100644 --- a/src/exchange/taler-exchange-httpd_batch-withdraw.c +++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c @@ -265,11 +265,10 @@ check_request_idempotent (const struct BatchWithdrawContext *wc, if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - if (GNUNET_DB_STATUS_HARD_ERROR == qs) - *mret = TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "get_withdraw_info"); + *mret = TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "get_withdraw_info"); return true; /* well, kind-of */ } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -689,7 +688,6 @@ parse_planchets (const struct TEH_RequestContext *rc, const json_t *planchets) { struct TEH_KeyStateHandle *ksh; - MHD_RESULT mret; for (unsigned int i = 0; i<wc->planchets_length; i++) { @@ -735,6 +733,8 @@ parse_planchets (const struct TEH_RequestContext *rc, ksh = TEH_keys_get_state (); if (NULL == ksh) { + MHD_RESULT mret; + if (! check_request_idempotent (wc, &mret)) { @@ -758,6 +758,8 @@ parse_planchets (const struct TEH_RequestContext *rc, if (NULL == dk) { + MHD_RESULT mret; + if (! check_request_idempotent (wc, &mret)) { @@ -769,6 +771,8 @@ parse_planchets (const struct TEH_RequestContext *rc, } if (GNUNET_TIME_absolute_is_past (dk->meta.expire_withdraw.abs_time)) { + MHD_RESULT mret; + /* This denomination is past the expiration time for withdraws */ if (! check_request_idempotent (wc, &mret)) @@ -793,6 +797,8 @@ parse_planchets (const struct TEH_RequestContext *rc, } if (dk->recoup_possible) { + MHD_RESULT mret; + /* This denomination has been revoked */ if (! check_request_idempotent (wc, &mret)) |