diff mbox series

[ovs-dev] sparse: eliminate "duplicate initialization" warning

Message ID 20170828152316.9690-1-lrichard@redhat.com
State Accepted
Headers show
Series [ovs-dev] sparse: eliminate "duplicate initialization" warning | expand

Commit Message

Lance Richardson Aug. 28, 2017, 3:23 p.m. UTC
Sparse version 0.5.1 will be released in the near future. Prepare
for it by eliminating the only new warning (as of 0.5.1-rc5):

ofproto/fail-open.c:134:22: error: Initializer entry defined twice
ofproto/fail-open.c:135:22:   also defined here

MATCH_CATCHALL_INITIALIZER effectively sets all fields of .flow to
zero, which is redundant because according to the C99 semantics for
structure initialization, initializing any single member of a
structure results in all other members being initialized to zero,
and the next line initializes a member of the same structure.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
---
 ofproto/fail-open.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Gregory Rose Aug. 29, 2017, 5:06 p.m. UTC | #1
On 08/28/2017 08:23 AM, Lance Richardson wrote:
> Sparse version 0.5.1 will be released in the near future. Prepare
> for it by eliminating the only new warning (as of 0.5.1-rc5):
>
> ofproto/fail-open.c:134:22: error: Initializer entry defined twice
> ofproto/fail-open.c:135:22:   also defined here
>
> MATCH_CATCHALL_INITIALIZER effectively sets all fields of .flow to
> zero, which is redundant because according to the C99 semantics for
> structure initialization, initializing any single member of a
> structure results in all other members being initialized to zero,
> and the next line initializes a member of the same structure.
>
> Signed-off-by: Lance Richardson <lrichard@redhat.com>
> ---
>   ofproto/fail-open.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
> index 914a51b4b..819bdadc3 100644
> --- a/ofproto/fail-open.c
> +++ b/ofproto/fail-open.c
> @@ -131,7 +131,6 @@ send_bogus_packet_ins(struct fail_open *fo)
>                   .base = {
>                       .packet = dp_packet_data(&b),
>                       .packet_len = dp_packet_size(&b),
> -                    .flow_metadata = MATCH_CATCHALL_INITIALIZER,
>                       .flow_metadata.flow.in_port.ofp_port = OFPP_LOCAL,
>                       .flow_metadata.wc.masks.in_port.ofp_port
>                       = u16_to_ofp(UINT16_MAX),
>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Ben Pfaff Oct. 30, 2017, 11:50 p.m. UTC | #2
On Tue, Aug 29, 2017 at 10:06:54AM -0700, Greg Rose wrote:
> On 08/28/2017 08:23 AM, Lance Richardson wrote:
> >Sparse version 0.5.1 will be released in the near future. Prepare
> >for it by eliminating the only new warning (as of 0.5.1-rc5):
> >
> >ofproto/fail-open.c:134:22: error: Initializer entry defined twice
> >ofproto/fail-open.c:135:22:   also defined here
> >
> >MATCH_CATCHALL_INITIALIZER effectively sets all fields of .flow to
> >zero, which is redundant because according to the C99 semantics for
> >structure initialization, initializing any single member of a
> >structure results in all other members being initialized to zero,
> >and the next line initializes a member of the same structure.
> >
> >Signed-off-by: Lance Richardson <lrichard@redhat.com>
> >---
> >  ofproto/fail-open.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> >diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
> >index 914a51b4b..819bdadc3 100644
> >--- a/ofproto/fail-open.c
> >+++ b/ofproto/fail-open.c
> >@@ -131,7 +131,6 @@ send_bogus_packet_ins(struct fail_open *fo)
> >                  .base = {
> >                      .packet = dp_packet_data(&b),
> >                      .packet_len = dp_packet_size(&b),
> >-                    .flow_metadata = MATCH_CATCHALL_INITIALIZER,
> >                      .flow_metadata.flow.in_port.ofp_port = OFPP_LOCAL,
> >                      .flow_metadata.wc.masks.in_port.ofp_port
> >                      = u16_to_ofp(UINT16_MAX),
> >
> Reviewed-by: Greg Rose <gvrose8192@gmail.com>

Thanks Lance and Greg, I applied this to master and branch-2.8.
diff mbox series

Patch

diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 914a51b4b..819bdadc3 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -131,7 +131,6 @@  send_bogus_packet_ins(struct fail_open *fo)
                 .base = {
                     .packet = dp_packet_data(&b),
                     .packet_len = dp_packet_size(&b),
-                    .flow_metadata = MATCH_CATCHALL_INITIALIZER,
                     .flow_metadata.flow.in_port.ofp_port = OFPP_LOCAL,
                     .flow_metadata.wc.masks.in_port.ofp_port
                     = u16_to_ofp(UINT16_MAX),