diff mbox series

[PATCHv2] slirp: Fix spurious error report when sending directly

Message ID 20180531203110.17203-1-samuel.thibault@ens-lyon.org
State New
Headers show
Series [PATCHv2] slirp: Fix spurious error report when sending directly | expand

Commit Message

Samuel Thibault May 31, 2018, 8:31 p.m. UTC
Move check to where it actually is useful, and reduce scope of 'len'
variable along the way.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---

Difference from v1:
- move check instead of initializing len.

 slirp/socket.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

no-reply@patchew.org May 31, 2018, 8:35 p.m. UTC | #1
Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180531203110.17203-1-samuel.thibault@ens-lyon.org
Subject: [Qemu-devel] [PATCHv2] slirp: Fix spurious error report when sending directly

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180531203110.17203-1-samuel.thibault@ens-lyon.org -> patchew/20180531203110.17203-1-samuel.thibault@ens-lyon.org
Switched to a new branch 'test'
6f4cceab40 slirp: Fix spurious error report when sending directly

=== OUTPUT BEGIN ===
Checking PATCH 1/1: slirp: Fix spurious error report when sending directly...
ERROR: code indent should never use tabs
#21: FILE: slirp/socket.c:343:
+^Iint n;$

ERROR: code indent should never use tabs
#30: FILE: slirp/socket.c:362:
+^I^Iint len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;$

ERROR: code indent should never use tabs
#39: FILE: slirp/socket.c:378:
+^I^Iif (n != len) {$

WARNING: line over 80 characters
#40: FILE: slirp/socket.c:379:
+			DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));

ERROR: code indent should never use tabs
#40: FILE: slirp/socket.c:379:
+^I^I^IDEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));$

ERROR: code indent should never use tabs
#41: FILE: slirp/socket.c:380:
+^I^I}$

total: 5 errors, 1 warnings, 34 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Philippe Mathieu-Daudé May 31, 2018, 11:02 p.m. UTC | #2
On 05/31/2018 05:31 PM, Samuel Thibault wrote:
> Move check to where it actually is useful, and reduce scope of 'len'
> variable along the way.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Thanks!

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
> 
> Difference from v1:
> - move check instead of initializing len.
> 
>  slirp/socket.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/slirp/socket.c b/slirp/socket.c
> index e2a71c9b04..08fe98907d 100644
> --- a/slirp/socket.c
> +++ b/slirp/socket.c
> @@ -340,7 +340,7 @@ sosendoob(struct socket *so)
>  	struct sbuf *sb = &so->so_rcv;
>  	char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
>  
> -	int n, len;
> +	int n;
>  
>  	DEBUG_CALL("sosendoob");
>  	DEBUG_ARG("so = %p", so);
> @@ -359,7 +359,7 @@ sosendoob(struct socket *so)
>  		 * send it all
>  		 */
>  		uint32_t urgc = so->so_urgc;
> -		len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
> +		int len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
>  		if (len > urgc) {
>  			len = urgc;
>  		}
> @@ -374,13 +374,13 @@ sosendoob(struct socket *so)
>  			len += n;
>  		}
>  		n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
> -	}
> -
>  #ifdef DEBUG
> -	if (n != len) {
> -		DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
> -	}
> +		if (n != len) {
> +			DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
> +		}
>  #endif
> +	}
> +
>  	if (n < 0) {
>  		return n;
>  	}
>
diff mbox series

Patch

diff --git a/slirp/socket.c b/slirp/socket.c
index e2a71c9b04..08fe98907d 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -340,7 +340,7 @@  sosendoob(struct socket *so)
 	struct sbuf *sb = &so->so_rcv;
 	char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
 
-	int n, len;
+	int n;
 
 	DEBUG_CALL("sosendoob");
 	DEBUG_ARG("so = %p", so);
@@ -359,7 +359,7 @@  sosendoob(struct socket *so)
 		 * send it all
 		 */
 		uint32_t urgc = so->so_urgc;
-		len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
+		int len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
 		if (len > urgc) {
 			len = urgc;
 		}
@@ -374,13 +374,13 @@  sosendoob(struct socket *so)
 			len += n;
 		}
 		n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
-	}
-
 #ifdef DEBUG
-	if (n != len) {
-		DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
-	}
+		if (n != len) {
+			DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
+		}
 #endif
+	}
+
 	if (n < 0) {
 		return n;
 	}