diff mbox

[dpdk-dev] test: fix misplaced braces in strncmp call

Message ID 1416387973-28431-1-git-send-email-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Bruce Richardson Nov. 19, 2014, 9:06 a.m. UTC
This patch fixes two occurances where a call to strncmp had the closing
brace in the wrong place. Changing this form:
	if (strncmp(X,Y,sizeof(X) != 0))
which does a comparison of length 1, to
	if (strncmp(X,Y,sizeof(X)) != 0)
which does the correct length comparison and then compares the result to
zero in the "if" part, as the author presumably originally intended.

Reported-by: Larry Wang <liang-min.wang@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/test_devargs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Olivier Matz Nov. 19, 2014, 10:20 a.m. UTC | #1
Hi Bruce,

On 11/19/2014 10:06 AM, Bruce Richardson wrote:
> This patch fixes two occurances where a call to strncmp had the closing
> brace in the wrong place. Changing this form:
> 	if (strncmp(X,Y,sizeof(X) != 0))
> which does a comparison of length 1, to
> 	if (strncmp(X,Y,sizeof(X)) != 0)
> which does the correct length comparison and then compares the result to
> zero in the "if" part, as the author presumably originally intended.
>
> Reported-by: Larry Wang <liang-min.wang@intel.com>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   app/test/test_devargs.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
> index f0acf8e..dcbdd09 100644
> --- a/app/test/test_devargs.c
> +++ b/app/test/test_devargs.c
> @@ -90,9 +90,9 @@ test_devargs(void)
>   		goto fail;
>   	devargs = TAILQ_FIRST(&devargs_list);
>   	if (strncmp(devargs->virtual.drv_name, "eth_ring1",
> -			sizeof(devargs->virtual.drv_name) != 0))
> +			sizeof(devargs->virtual.drv_name)) != 0)
>   		goto fail;
> -	if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args) != 0))
> +	if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args)) != 0)
>   		goto fail;
>   	free_devargs_list();
>
>

Nice catch!

Acked-by: Olivier Matz <olivier.matz@6wind.com>
Thomas Monjalon Nov. 24, 2014, 3:54 p.m. UTC | #2
> > This patch fixes two occurances where a call to strncmp had the closing
> > brace in the wrong place. Changing this form:
> > 	if (strncmp(X,Y,sizeof(X) != 0))
> > which does a comparison of length 1, to
> > 	if (strncmp(X,Y,sizeof(X)) != 0)
> > which does the correct length comparison and then compares the result to
> > zero in the "if" part, as the author presumably originally intended.
> >
> > Reported-by: Larry Wang <liang-min.wang@intel.com>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Nice catch!
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
 
Applied

Thanks
diff mbox

Patch

diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
index f0acf8e..dcbdd09 100644
--- a/app/test/test_devargs.c
+++ b/app/test/test_devargs.c
@@ -90,9 +90,9 @@  test_devargs(void)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strncmp(devargs->virtual.drv_name, "eth_ring1",
-			sizeof(devargs->virtual.drv_name) != 0))
+			sizeof(devargs->virtual.drv_name)) != 0)
 		goto fail;
-	if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args) != 0))
+	if (strncmp(devargs->args, "k1=val,k2=val2", sizeof(devargs->args)) != 0)
 		goto fail;
 	free_devargs_list();