From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bx7-0001sr-CH for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:30:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bx6-0006mw-JT for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:30:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bx6-0006mM-E8 for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:30:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B59797EAB8 for ; Tue, 1 Nov 2016 16:30:19 +0000 (UTC) From: Paolo Bonzini Date: Tue, 1 Nov 2016 17:29:33 +0100 Message-Id: <1478017783-7703-21-git-send-email-pbonzini@redhat.com> In-Reply-To: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> References: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 20/30] nbd: Refactor conversion to errno to silence checkpatch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Eric Blake Checkpatch complains that 'return EINVAL' is usually wrong (since we tend to favor 'return -EINVAL'). But it is a false positive for nbd_errno_to_system_errno(). Since NBD may add future defined wire values, refactor the code to keep checkpatch happy. Signed-off-by: Eric Blake Message-Id: <1476469998-28592-14-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- nbd/client.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index b29963b..7bdce53 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -23,23 +23,31 @@ static int nbd_errno_to_system_errno(int err) { + int ret; switch (err) { case NBD_SUCCESS: - return 0; + ret = 0; + break; case NBD_EPERM: - return EPERM; + ret = EPERM; + break; case NBD_EIO: - return EIO; + ret = EIO; + break; case NBD_ENOMEM: - return ENOMEM; + ret = ENOMEM; + break; case NBD_ENOSPC: - return ENOSPC; + ret = ENOSPC; + break; default: TRACE("Squashing unexpected error %d to EINVAL", err); /* fallthrough */ case NBD_EINVAL: - return EINVAL; + ret = EINVAL; + break; } + return ret; } /* Definitions for opaque data types */ -- 2.7.4