Fix GCC 10 warning with flag '-Wint-in-bool-context'#6537
Conversation
| else if(data->state.httpreq == HTTPREQ_POST_MIME || | ||
| data->state.httpreq == HTTPREQ_POST_FORM) { | ||
| if(Curl_mime_rewind(mimepart)) { | ||
| if(Curl_mime_rewind(mimepart) != CURLE_OK) { |
There was a problem hiding this comment.
I find this curious. What makes this particular condition a boolean context ? Surely we have the exact same construct in hundreds of places in the code. Also: why is this a warning/error in the first place?
There was a problem hiding this comment.
A slightly better fix would probably be:
diff --git a/lib/transfer.c b/lib/transfer.c
index f9cdcd1d8..2f29b29d8 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -433,13 +433,14 @@ CURLcode Curl_readrewind(struct Curl_easy *data)
}
if(data->set.postfields)
; /* do nothing */
else if(data->state.httpreq == HTTPREQ_POST_MIME ||
data->state.httpreq == HTTPREQ_POST_FORM) {
- if(Curl_mime_rewind(mimepart)) {
+ CURLcode result = Curl_mime_rewind(mimepart);
+ if(result) {
failf(data, "Cannot rewind mime/post data");
- return CURLE_SEND_FAIL_REWIND;
+ return result;
}
}
else {
if(data->set.seek_func) {
int err;There was a problem hiding this comment.
This also makes me wonder. So far we have used the ARM GCC 9.2.1 compiler and there were no warnings.
Without changing the compilation flags, we changed the compiler to ARM GCC 10.2.1 and a warning popped up.
I don't know what has changed between these versions ...
We use curl with HTTP protocol support only (by the way with CURL_DISABLE_MIME flag).
Hence, this is only one place of the warning.
I applied your patch and it works - no warnings! Which does not change the fact that it is a very interesting case.
…nd function execution
|
thanks! |
Avoid warning compiler: enum constant in boolean context