]> granicus.if.org Git - libevent/commitdiff
Fix -Werror=implicit-fallthrough (fixes gcc-7)
authorAzat Khuzhin <a3at.mail@gmail.com>
Sun, 29 Jan 2017 14:23:14 +0000 (17:23 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Sun, 29 Jan 2017 14:58:31 +0000 (17:58 +0300)
Fixes: #447
bufferevent_filter.c
evdns.c
event.c
util-internal.h

index d47f9452bbd2a5213ae628eb56ec3140f459fd38..b5efd5c04a5c03f5b65d92cd29780e2a8a61db44 100644 (file)
@@ -612,9 +612,12 @@ be_filter_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op,
                        bevf->underlying->be_ops->ctrl) {
                    return (bevf->underlying->be_ops->ctrl)(bevf->underlying, op, data);
                }
+               EVUTIL_FALLTHROUGH;
 
        case BEV_CTRL_GET_FD:
+               EVUTIL_FALLTHROUGH;
        case BEV_CTRL_CANCEL_ALL:
+               EVUTIL_FALLTHROUGH;
        default:
                return -1;
        }
diff --git a/evdns.c b/evdns.c
index e9dbc35c60662ccda395d21d95997193840b4b57..400429257f527f11c0e0cec657eb404e4dfe6f77 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -2265,10 +2265,11 @@ evdns_request_transmit(struct request *req) {
                nameserver_write_waiting(req->ns, 1);
                return 1;
        case 2:
-               /* failed to transmit the request entirely. */
+               /* failed to transmit the request entirely. we can fallthrough since
+                * we'll set a timeout, which will time out, and make us retransmit the
+                * request anyway. */
                retcode = 1;
-               /* fall through: we'll set a timeout, which will time out,
-                * and make us retransmit the request anyway. */
+               EVUTIL_FALLTHROUGH;
        default:
                /* all ok */
                log(EVDNS_LOG_DEBUG,
diff --git a/event.c b/event.c
index 503003e249a29909465e05421ed865c772e4648c..7230d1abeb7bb06eee9afa20faca0bd03da68009 100644 (file)
--- a/event.c
+++ b/event.c
@@ -2960,6 +2960,7 @@ event_callback_activate_nolock_(struct event_base *base,
        switch (evcb->evcb_flags & (EVLIST_ACTIVE|EVLIST_ACTIVE_LATER)) {
        default:
                EVUTIL_ASSERT(0);
+               EVUTIL_FALLTHROUGH;
        case EVLIST_ACTIVE_LATER:
                event_queue_remove_active_later(base, evcb);
                r = 0;
index 38d0f595fb7583d41e4ec788997e68cf1f35c911..54e9fa30d656984a240af29120f0544d748d89e8 100644 (file)
 extern "C" {
 #endif
 
+#if !defined(__has_attribute)
+#define __has_attribute(x) 0
+#endif
+
 /* If we need magic to say "inline", get it for free internally. */
 #ifdef EVENT__inline
 #define inline EVENT__inline
@@ -308,6 +312,12 @@ ev_int32_t evutil_weakrand_range_(struct evutil_weakrand_state *seed, ev_int32_t
 #define EVUTIL_UNLIKELY(p) (p)
 #endif
 
+#if __has_attribute(fallthrough)
+#define EVUTIL_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define EVUTIL_FALLTHROUGH /* fallthrough */
+#endif
+
 /* Replacement for assert() that calls event_errx on failure. */
 #ifdef NDEBUG
 #define EVUTIL_ASSERT(cond) EVUTIL_NIL_CONDITION_(cond)