Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754375AbbKCNwt (ORCPT ); Tue, 3 Nov 2015 08:52:49 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34113 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330AbbKCNwp (ORCPT ); Tue, 3 Nov 2015 08:52:45 -0500 MIME-Version: 1.0 In-Reply-To: <5638865D.2000804@cumulusnetworks.com> References: <1446486818-26166-1-git-send-email-jarod@redhat.com> <1446519359-21400-1-git-send-email-jarod@redhat.com> <5638865D.2000804@cumulusnetworks.com> Date: Tue, 3 Nov 2015 14:52:44 +0100 X-Google-Sender-Auth: pOGSuuUyTZoKXnsmLUzeOSOYQxM Message-ID: Subject: Re: [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack From: Geert Uytterhoeven To: Nikolay Aleksandrov Cc: Jarod Wilson , "linux-kernel@vger.kernel.org" , "David S. Miller" , Eric Dumazet , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Jiri Pirko , Nikolay Aleksandrov , Michal Kubecek , Alexander Duyck , "netdev@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1975 Lines: 59 On Tue, Nov 3, 2015 at 11:03 AM, Nikolay Aleksandrov wrote: > On 11/03/2015 03:55 AM, Jarod Wilson wrote: > [snip] >> >> +#define for_each_netdev_feature(mask_addr, feature) \ >> + int bit; \ >> + for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT) \ >> + feature = __NETIF_F_BIT(bit); >> + > ^ > This is broken, it will not work for more than a single feature. Indeed it is. This is used as: for_each_netdev_feature(&upper_disables, feature) { ... } which expands to: int bit; for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT) feature = __NETIF_F_BIT(bit); { ... } Note the assignment to "feature" happens outside the {}-delimited block. And the block is always executed once. Interestingly, arm-unknown-linux-gnueabi-gcc 4.9.0 warns about this in some of my configs, but not in all of them: net/core/dev.c: In function '__netdev_update_features': net/core/dev.c:6302:16: warning: 'feature' may be used uninitialized in this function [-Wmaybe-uninitialized] features &= ~feature; ^ net/core/dev.c:6295:20: note: 'feature' was declared here netdev_features_t feature; ^ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/