diff mbox series

[ovs-dev,v2,3/5] ofp-table: Fix count_common_prefix_run() function.

Message ID 169807095205.1031379.14112323533605146662.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 fail test: fail

Commit Message

Eelco Chaudron Oct. 23, 2023, 2:22 p.m. UTC
It appears that an issue existed in the count_common_prefix_run()
function from the beginning. This problem came to light while
addressing 'Dead assignment' warnings identified by the Clang
static analyzer.

Instead of updating the extra_prefix_len with the current (next)
value, the next value was inadvertently updated with extra_prefix_len.
This patch rectifies this behavior.

Fixes: 95a5454c5110 ("ofp-print: Abbreviate lists of fields in table features output.")
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/ofp-table.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Oct. 25, 2023, 9:56 a.m. UTC | #1
On Mon, Oct 23, 2023 at 04:22:32PM +0200, Eelco Chaudron wrote:
> It appears that an issue existed in the count_common_prefix_run()
> function from the beginning. This problem came to light while
> addressing 'Dead assignment' warnings identified by the Clang
> static analyzer.
> 
> Instead of updating the extra_prefix_len with the current (next)
> value, the next value was inadvertently updated with extra_prefix_len.
> This patch rectifies this behavior.
> 
> Fixes: 95a5454c5110 ("ofp-print: Abbreviate lists of fields in table features output.")
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>

Thanks Eelco,

I agree with the reasoning in the commit message.

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/lib/ofp-table.c b/lib/ofp-table.c
index a956754f2..f9bd3b7f9 100644
--- a/lib/ofp-table.c
+++ b/lib/ofp-table.c
@@ -1416,7 +1416,7 @@  count_common_prefix_run(const char *ids[], size_t n,
         if (!next) {
             break;
         } else if (next < extra_prefix_len) {
-            next = extra_prefix_len;
+            extra_prefix_len = next;
         }
         i++;
     }