Message ID | 20170613110824.27786-2-philipp.psurek@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Simon Wunderlich |
Headers |
Return-Path: <b.a.t.m.a.n-bounces@lists.open-mesh.org> X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 1F03382154; Tue, 13 Jun 2017 13:10:10 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cT9XtnDy"; dkim-atps=neutral Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by open-mesh.org (Postfix) with ESMTPS id 7C3BC82129 for <b.a.t.m.a.n@lists.open-mesh.org>; Tue, 13 Jun 2017 13:09:16 +0200 (CEST) Received: by mail-wr0-x241.google.com with SMTP id e23so29045976wre.3 for <b.a.t.m.a.n@lists.open-mesh.org>; Tue, 13 Jun 2017 04:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FryEmA0hpOo6uMriLpYShmBZZ9OvTSWlNnNquEV4J5A=; b=cT9XtnDyoxY/kqZxZbmfBGarlAToH5BpcrbvdwynURjPmyGjEmg9AJEX/aOD4U28qn RZNuiIaoyHCXYVc9SPyfSMFpeYStyplXGAP3n0mhQAV/IJ+G7FqteGamWv0hFk3Iq8dJ GNsRgCME1ItgkuH4+osTmNz3QRZhHdWYdcJdKm4iY4uKfLD23FxC9tYozLmjtCKqkEJI BOiwC94CXiAiQvL/3gzlRuKi0RZK7fnJSwV/wGb+I2D+4UcAzq+EdUwwVGlZxJ9WuAPF 3LFwVmGKHuEASI3SbO3As4NlTgZFKOzFd4n3U3BU23yd8VWG7b0kGiJ6ivTlNOloPjWs 9vhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FryEmA0hpOo6uMriLpYShmBZZ9OvTSWlNnNquEV4J5A=; b=L1hsUuUm7FOKBzAIw0xJEpRmOXIAZYRpZmUv9e/WrYScX0ra7PzG9VaOFXWWBB+9ak 3v2gGR5jPg2oHo/h7ct+56Rnh3b3D1UEchySwgPVj1LdNMrfPzarCiCoSa2UCMlgHXq9 fk/RpujAHg98T6TRRRq310iJYyJW41PyYhPWccISkZjK4uypd57ooycfbbyAGCXkELZi xVtBRYtvmw0pMM6z0xN9HCo+83QZkL6n6bAyNYANvde7/DQua6EALY/wj45gtL0mhWId J3W2os4DkUtHec4wFoQxnPBk/hKzkJeEGXYsfv9d56evMB+Nl1t6TC1Go7wJxQZ4I3Ed 99ZA== X-Gm-Message-State: AODbwcCfA2+yvzCfQGrRDuEI8aV01PMzgJ0CO1BNfQYML9SinpgjrZTz quhJq6Zx4emmxiw7 X-Received: by 10.28.2.67 with SMTP id 64mr10561728wmc.101.1497352153449; Tue, 13 Jun 2017 04:09:13 -0700 (PDT) Received: from soli.hausnetz (dslb-088-077-242-209.088.077.pools.vodafone-ip.de. [88.77.242.209]) by smtp.gmail.com with ESMTPSA id r78sm12632312wrb.37.2017.06.13.04.09.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 04:09:12 -0700 (PDT) From: Philipp Psurek <philipp.psurek@gmail.com> To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 13 Jun 2017 13:08:24 +0200 Message-Id: <20170613110824.27786-2-philipp.psurek@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170613110824.27786-1-philipp.psurek@gmail.com> References: <20170613103916.27299-1-philipp.psurek@gmail.com> <20170613110824.27786-1-philipp.psurek@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [B.A.T.M.A.N.] [PATCH] batctl: suppress implicit-fallthrough compiler warning X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n.lists.open-mesh.org> List-Unsubscribe: <https://lists.open-mesh.org/mm/options/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=unsubscribe> List-Archive: <http://lists.open-mesh.org/pipermail/b.a.t.m.a.n/> List-Post: <mailto:b.a.t.m.a.n@lists.open-mesh.org> List-Help: <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=help> List-Subscribe: <https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=subscribe> Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" <b.a.t.m.a.n-bounces@lists.open-mesh.org> |
Commit Message
Philipp Psurek
June 13, 2017, 11:08 a.m. UTC
GCC 7.1.0 complains about an intended fallthrough.
“__attribute__ ((fallthrough))” in this part of code would suppress this
warning. Because older GCC compiler don’t understand this statement attribute
and because there is already a comment in the source containing
“falls?[ \t-]*thr(ough|u)” we can suppress the warning with the
“-Wimplicit-fallthrough=2” warning option. Unintended fallthroughs without a
comment would trigger this warning again.
To avoid compiler recognition in the Makefile a simply change of the comment
is sufficient to suppress the warning. For some reason only stand alone
comments mentioned in [1] are recognized so the comment has to be split up into
two parts.
[1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough_003d
Signed-off-by: Philipp Psurek <philipp.psurek@gmail.com>
---
tp_meter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tuesday, June 13, 2017 1:08:24 PM CEST Philipp Psurek wrote: > GCC 7.1.0 complains about an intended fallthrough. > “__attribute__ ((fallthrough))” in this part of code would suppress this > warning. Because older GCC compiler don’t understand this statement > attribute and because there is already a comment in the source containing > “falls?[ \t-]*thr(ough|u)” we can suppress the warning with the > “-Wimplicit-fallthrough=2” warning option. Unintended fallthroughs without a > comment would trigger this warning again. > > To avoid compiler recognition in the Makefile a simply change of the comment > is sufficient to suppress the warning. For some reason only stand alone > comments mentioned in [1] are recognized so the comment has to be split up > into two parts. > > [1] > https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#index-Wim > plicit-fallthrough_003d > > Signed-off-by: Philipp Psurek <philipp.psurek@gmail.com> Thank you for your persistence and testing! I've adopted your patch, but put the second part of the comment into the following case to avoid the ugliness. I didn't test with gcc 7.1 but hope that should work. Please check here: https://git.open-mesh.org/batctl.git/blobdiff/ 620226bf8cff30e6dd966c8fe922b2d4cddf843b.. 50ee3c45feeda6d8c04ee127097badf99f78a26e:/tp_meter.c Thank you! Simon
On Dienstag, 13. Juni 2017 13:46:04 CEST Simon Wunderlich wrote: [...] > I've adopted your patch, but put the second part of the comment into the > following case to avoid the ugliness. I didn't test with gcc 7.1 but hope that > should work. Please check here: > > https://git.open-mesh.org/batctl.git/blobdiff/ > 620226bf8cff30e6dd966c8fe922b2d4cddf843b.. > 50ee3c45feeda6d8c04ee127097badf99f78a26e:/tp_meter.c The other option would have been to change it to: /* fall through - print the partial result */ At least the documentation allows non-escape chars after the "fall through" marker when a "-" was added between them. I've removed the "and" in this example because it looked weird. Kind regards, Sven
On Dienstag, 13. Juni 2017 13:53:01 CEST Sven Eckelmann wrote:
> At least the documentation allows non-escape chars after the "fall through"
Sry, I meant "non-newline"/"non-return" chars.
Kind regards,
Sven
Am Dienstag, den 13.06.2017, 13:53 +0200 schrieb Sven Eckelmann: > The other option would have been to change it to: > > /* fall through - print the partial result */ Thank you Sven for pointing this out. This one works perfectly! Regex understanding 4TW ;-) Thank you Simon for restyling the patch. Batctl compiles now without any warnings with GCC 7.1.0. I’m surprised how far it has come: the compiler inspects comments now … Thank you all for B.A.T.M.A.N.-Advanced Best regards, Philipp
diff --git a/tp_meter.c b/tp_meter.c index 918fb79..eb67ba1 100644 --- a/tp_meter.c +++ b/tp_meter.c @@ -500,7 +500,7 @@ int tp_meter(char *mesh_iface, int argc, char **argv) break; case BATADV_TP_REASON_CANCEL: printf("CANCEL received: test aborted\n"); - /* fall through and print the partial result */ + /* fall through *//* and print the partial result */ case BATADV_TP_REASON_COMPLETE: if (result.test_time > 0) { throughput = result.total_bytes * 1000;