Re: [ovs-dev] [PATCH 1/4] general: Fix Clang's static analyzer 'Dead initialization' warnings.

2023-10-18 Thread Eelco Chaudron



On 18 Oct 2023, at 12:46, Simon Horman wrote:

> On Wed, Oct 18, 2023 at 12:39:51PM +0200, Simon Horman wrote:
>> On Tue, Oct 17, 2023 at 03:49:31PM +0200, Eelco Chaudron wrote:
>>> Signed-off-by: Eelco Chaudron 
>>> ---
>>>  lib/meta-flow.c   |4 ++--
>>>  lib/ofp-actions.c |8 +---
>>>  2 files changed, 7 insertions(+), 5 deletions(-)
>>
>> Thanks Eelco,
>>
>> I agree that these initialisations are unnecessary.
>> Although I am unsure how to get clang to emit warnings about them.
>
> Of course shortly after writing the above I figured out that
> I can use something like:
>
> $ clang-tidy lib/meta-flow.c -- -I. -I./include

Never used clang-tidy, but looks interesting ;)
I use the following from the testing document:

 $ ./configure CC=clang
 $ make clang-analyze

It does give you a nice flow on how clang came to the conclusion.

//Eelco

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 1/4] general: Fix Clang's static analyzer 'Dead initialization' warnings.

2023-10-18 Thread Simon Horman
On Wed, Oct 18, 2023 at 12:39:51PM +0200, Simon Horman wrote:
> On Tue, Oct 17, 2023 at 03:49:31PM +0200, Eelco Chaudron wrote:
> > Signed-off-by: Eelco Chaudron 
> > ---
> >  lib/meta-flow.c   |4 ++--
> >  lib/ofp-actions.c |8 +---
> >  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> Thanks Eelco,
> 
> I agree that these initialisations are unnecessary.
> Although I am unsure how to get clang to emit warnings about them.

Of course shortly after writing the above I figured out that
I can use something like:

$ clang-tidy lib/meta-flow.c -- -I. -I./include
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 1/4] general: Fix Clang's static analyzer 'Dead initialization' warnings.

2023-10-18 Thread Simon Horman
On Tue, Oct 17, 2023 at 03:49:31PM +0200, Eelco Chaudron wrote:
> Signed-off-by: Eelco Chaudron 
> ---
>  lib/meta-flow.c   |4 ++--
>  lib/ofp-actions.c |8 +---
>  2 files changed, 7 insertions(+), 5 deletions(-)

Thanks Eelco,

I agree that these initialisations are unnecessary.
Although I am unsure how to get clang to emit warnings about them.

Acked-by: Simon Horman 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 1/4] general: Fix Clang's static analyzer 'Dead initialization' warnings.

2023-10-17 Thread Eelco Chaudron
Signed-off-by: Eelco Chaudron 
---
 lib/meta-flow.c   |4 ++--
 lib/ofp-actions.c |8 +---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 474344194..aa7cf1fcb 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -2751,8 +2751,8 @@ static char *
 mf_from_integer_string(const struct mf_field *mf, const char *s,
uint8_t *valuep, uint8_t *maskp)
 {
+const char *err_str;
 char *tail;
-const char *err_str = "";
 int err;
 
 err = parse_int_string(s, valuep, mf->n_bytes, );
@@ -2785,8 +2785,8 @@ syntax_error:
 static char *
 mf_from_packet_type_string(const char *s, ovs_be32 *packet_type)
 {
+const char *err_str;
 char *tail;
-const char *err_str = "";
 int err;
 
 if (*s != '(') {
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index d7e5f542a..da7b1dd31 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -4230,10 +4230,12 @@ encode_DELETE_FIELD(const struct ofpact_delete_field 
*delete_field,
 enum ofp_version ofp_version OVS_UNUSED,
 struct ofpbuf *out)
 {
-struct nx_action_delete_field *nadf = put_NXAST_DELETE_FIELD(out);
-size_t size = out->size;
+size_t size;
 
-out->size = size - sizeof nadf->pad;
+put_NXAST_DELETE_FIELD(out);
+size = out->size;
+
+out->size = size - MEMBER_SIZEOF(struct nx_action_delete_field, pad);
 nx_put_mff_header(out, delete_field->field, 0, false);
 out->size = size;
 }

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev