Skip to contentSkip to conversation

test: fix misplaced braces in strncmp call

PATCH Applied Bruce Richardson 3 participants 3 messages Nov 19, 2014 – Nov 24, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: fix misplaced braces in strncmp call

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.

---
 app/test/test_devargs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test/test_devargs.c +2 -2
index f0acf8e..dcbdd09 100644
@@ -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();
 
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1416387973-28431-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Acked-by
#2 lore raw

Hi Bruce,

Quoted 21 lines · Bruce Richardson

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.

---
  app/test/test_devargs.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
app/test/test_devargs.c +0 -0
index f0acf8e..dcbdd09 100644
@@ -90,9 +90,9 @@ test_devargs(void)
  		goto fail;

app/test/test_devargs.c test_devargs(void) · line 98

Quoted 10 lines
app/test/test_devargs.c +2 -2
  	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!

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines
Quoted 8 lines

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.

Quoted 6 lines
Quoted 2 lines

Nice catch!

Applied

Thanks

Signature · 1 line
Thomas