Message ID | 169755057121.686004.10626568940888538314.stgit@ebuild |
---|---|
State | Changes Requested |
Headers | show |
Series | Fix some of Clang's static analyzer warnings. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/intel-ovs-compilation | success | test: success |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
On Tue, Oct 17, 2023 at 03:49:31PM +0200, Eelco Chaudron wrote: > Signed-off-by: Eelco Chaudron <echaudro@redhat.com> > --- > 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 <horms@ovn.org>
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 <echaudro@redhat.com> > > --- > > 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
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 <echaudro@redhat.com> >>> --- >>> 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
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, &tail); @@ -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; }
Signed-off-by: Eelco Chaudron <echaudro@redhat.com> --- lib/meta-flow.c | 4 ++-- lib/ofp-actions.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-)