OSDN Git Service

curl_trace(): eliminate switch fallthrough
authorJeff King <peff@peff.net>
Thu, 21 Sep 2017 06:23:24 +0000 (02:23 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Sep 2017 03:49:55 +0000 (12:49 +0900)
Our trace handler is called by curl with a curl_infotype
variable to interpret its data field. For most types we
print the data and then break out of the switch. But for
CURLINFO_TEXT, we print data and then fall through to the
"default" case, which does the exact same thing (nothing!)
that breaking out of the switch would.

This is probably a leftover from an early iteration of the
patch where the code after the switch _did_ do something
interesting that was unique to the non-text case arms.
But in its current form, this fallthrough is merely
confusing (and causes gcc's -Wimplicit-fallthrough to
complain).

Let's make CURLINFO_TEXT like the other case arms, and push
the default arm to the end where it's more obviously a
catch-all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c

diff --git a/http.c b/http.c
index 9e40a46..713525f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -638,9 +638,7 @@ static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size,
        switch (type) {
        case CURLINFO_TEXT:
                trace_printf_key(&trace_curl, "== Info: %s", data);
-       default:                /* we ignore unknown types by default */
-               return 0;
-
+               break;
        case CURLINFO_HEADER_OUT:
                text = "=> Send header";
                curl_dump_header(text, (unsigned char *)data, size, DO_FILTER);
@@ -665,6 +663,9 @@ static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size,
                text = "<= Recv SSL data";
                curl_dump_data(text, (unsigned char *)data, size);
                break;
+
+       default:                /* we ignore unknown types by default */
+               return 0;
        }
        return 0;
 }