From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: Re: [B.A.T.M.A.N.] [PATCH maint] batman-adv: Fix broken capability checks
Date: Fri, 03 Jul 2015 13:40:11 +0200 [thread overview]
Message-ID: <1467513.dHSoo3DKj0@bentobox> (raw)
In-Reply-To: <2779160.PvUSbAU1eu@voltaire>
[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]
On Friday 03 July 2015 19:13:02 Marek Lindner wrote:
> > @@ -299,10 +299,10 @@ struct batadv_orig_node {
> > * (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
> > */
> > enum batadv_orig_capabilities {
> > - BATADV_ORIG_CAPA_HAS_DAT = BIT(0),
> > - BATADV_ORIG_CAPA_HAS_NC = BIT(1),
> > - BATADV_ORIG_CAPA_HAS_TT = BIT(2),
> > - BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
> > + BATADV_ORIG_CAPA_HAS_DAT,
> > + BATADV_ORIG_CAPA_HAS_NC,
> > + BATADV_ORIG_CAPA_HAS_TT,
> > + BATADV_ORIG_CAPA_HAS_MCAST,
> > };
>
> Do we need an initialization of the first element or can we rely on the
> compiler to start with 0 ?
Just discussed this with Marek on IRC. We came to the conclusion that ANSI C
"3.5.2.2 Enumeration specifiers" is enforcing a 0 as first entry (when not
specified otherwise):
If the first enumerator has no = , the value of
its enumeration constant is 0. Each subsequent enumerator with no =
defines its enumeration constant as the value of the constant
expression obtained by adding 1 to the value of the previous
enumeration constant.
But the code should maybe cleaned up to either use "= 0" everywhere or nowhere
in the internal representations.
Places where = 0 is used:
* net/batman-adv/bat_iv_ogm.c:enum batadv_dup_status
* net/batman-adv/main.h:enum batadv_uev_action (maybe not internal?)
* net/batman-adv/main.h:enum batadv_uev_type (maybe not internal?)
* net/batman-adv/types.h:enum batadv_dhcp_recipient
Not used:
* net/batman-adv/gateway_common.h:enum batadv_gw_modes
* net/batman-adv/gateway_common.h:enum batadv_bandwidth_units
* net/batman-adv/hard-interface.h:enum batadv_hard_if_state
* net/batman-adv/hard-interface.h:enum batadv_hard_if_cleanup
* net/batman-adv/main.h:enum batadv_mesh_state
* net/batman-adv/multicast.h:enum batadv_forw_mode
* net/batman-adv/types.h:enum batadv_counters
I don't count packet.h because this is clearly not internal and the packet
definitions should not be accidentally changed just because the enum constant
order is changed.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2015-07-03 11:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-02 4:30 [B.A.T.M.A.N.] [PATCH maint] batman-adv: Fix broken capability checks Linus Lüssing
2015-07-02 20:34 ` Linus Lüssing
2015-07-03 11:13 ` Marek Lindner
2015-07-03 11:40 ` Sven Eckelmann [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467513.dHSoo3DKj0@bentobox \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=mareklindner@neomailbox.ch \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox