diff mbox series

[ovs-dev,v2,2/5] general: Fix Clang's static analyzer 'Dead assignment' warnings.

Message ID 169807094481.1031379.3782128425635686671.stgit@ebuild
State Accepted
Delegated to: Simon Horman
Headers show
Series Fix some of Clang's static analyzer warnings. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Eelco Chaudron Oct. 23, 2023, 2:22 p.m. UTC
This patch addresses a 'Dead assignment' warning by designating
the variable as OVS_UNUSED. We opted for this approach instead
of comparing it to the sizeof(struct ...) method because of
concerns related to code clarity.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/ofp-monitor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Oct. 25, 2023, 9:53 a.m. UTC | #1
On Mon, Oct 23, 2023 at 04:22:24PM +0200, Eelco Chaudron wrote:
> This patch addresses a 'Dead assignment' warning by designating
> the variable as OVS_UNUSED. We opted for this approach instead
> of comparing it to the sizeof(struct ...) method because of
> concerns related to code clarity.
> 
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>

Thanks,

I confirmed that this addresses warnings generated by clang-tidy.
And I agree this is a reasonable approach.

Acked-by: Simon Horman <horms@ovn.org>
diff mbox series

Patch

diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index c27733a52..29b0c5965 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -962,7 +962,7 @@  ofputil_decode_flow_update(struct ofputil_flow_update *update,
             return 0;
         } else if (update->event == OFPFME_PAUSED
                    || update->event == OFPFME_RESUMED) {
-            struct ofp_flow_update_paused *ofup;
+            struct ofp_flow_update_paused *ofup OVS_UNUSED;
 
             if (length != sizeof *ofup) {
                 goto bad_len;