Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261511

Re: [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack

From Geert Uytterhoeven <geert@linux-m68k.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack
Date 2015-11-03 15:00 +0100
Message-ID <qqKhX-3qa-7@gated-at.bofh.it> (permalink)
References <qqryF-8gz-17@gated-at.bofh.it> <qqzZg-56X-3@gated-at.bofh.it> <qqGHp-1jJ-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Nov 3, 2015 at 11:03 AM, Nikolay Aleksandrov
<nikolay@cumulusnetworks.com> 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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next] net/core: generic support for disabling netdev features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-02 19:00 +0100
  Re: [PATCH net-next] net/core: generic support for disabling netdev  features down stack Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-02 19:10 +0100
    Re: [PATCH net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-02 23:00 +0100
  [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 04:00 +0100
    Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack David Miller <davem@davemloft.net> - 2015-11-03 05:50 +0100
    Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 11:10 +0100
      Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Geert Uytterhoeven <geert@linux-m68k.org> - 2015-11-03 15:00 +0100
        Re: [PATCH v2 net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 15:00 +0100
          Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 15:10 +0100
            Re: [PATCH v2 net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 17:10 +0100
    [PATCH net-next] net/core: fix for_each_netdev_feature Jarod Wilson <jarod@redhat.com> - 2015-11-03 16:20 +0100
      Re: [PATCH net-next] net/core: fix for_each_netdev_feature Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 16:50 +0100
      Re: [PATCH net-next] net/core: fix for_each_netdev_feature David Miller <davem@davemloft.net> - 2015-11-03 17:40 +0100
    [PATCH net-next] net/core: ensure features get disabled on new lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 21:40 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-03 22:20 +0100
        Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 23:20 +0100
          Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-04 00:10 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 22:30 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Michal Kubecek <mkubecek@suse.cz> - 2015-11-03 23:00 +0100
        Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 23:00 +0100
      [PATCH v2 net-next] net/core: ensure features get disabled on new lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-04 05:10 +0100
        Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs David Miller <davem@davemloft.net> - 2015-11-05 04:00 +0100
          Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs Florian Fainelli <f.fainelli@gmail.com> - 2015-11-13 01:30 +0100
            Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs Jiri Pirko <jiri@resnulli.us> - 2015-11-13 11:30 +0100
              Re: [PATCH v2 net-next] net/core: ensure features get disabled on new  lower devs Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-13 12:00 +0100
                Re: [PATCH v2 net-next] net/core: ensure features get disabled on new  lower devs Laura Abbott <labbott@redhat.com> - 2015-11-13 23:40 +0100

csiph-web