From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 3/4] curl_trace(): eliminate switch fallthrough
Date: Thu, 21 Sep 2017 02:23:24 -0400 [thread overview]
Message-ID: <20170921062324.ehlfvyng7e62eoti@sigill.intra.peff.net> (raw)
In-Reply-To: <20170921062043.la2f3pjsnojirzyw@sigill.intra.peff.net>
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>
---
http.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/http.c b/http.c
index 9e40a465fd..713525f38e 100644
--- 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;
}
--
2.14.1.1051.g8c9143ec35
next prev parent reply other threads:[~2017-09-21 6:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 6:20 [PATCH 0/4] appeasing -Wimplicit-fallthrough Jeff King
2017-09-21 6:21 ` [PATCH 1/4] cat-file: handle NULL object_context.path Jeff King
2017-09-22 0:58 ` Jonathan Nieder
2017-09-21 6:22 ` [PATCH 2/4] test-line-buffer: simplify command parsing Jeff King
2017-09-22 3:47 ` Junio C Hamano
2017-09-21 6:23 ` Jeff King [this message]
2017-09-21 6:25 ` [PATCH 4/4] consistently use "fallthrough" comments in switches Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170921062324.ehlfvyng7e62eoti@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).