Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1216934pxb; Thu, 16 Sep 2021 02:26:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAd7Ghj6vZsjoD5f0mEsCNuY+2+ssHkEyx0prDrqUuFia5PghM5XKWNO12ZnLWgt+18i8A X-Received: by 2002:a50:8589:: with SMTP id a9mr5278250edh.124.1631784362089; Thu, 16 Sep 2021 02:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631784362; cv=none; d=google.com; s=arc-20160816; b=E/qOSuAvinDxxSgg1vTsXk/hdN5jb3q3MIFS2BpyBhjFXwb1jJiy+d4Rt4V58pSDvO C19ephes4jFrbebSmMuDG315rAt+SjtAd6GcyAQ9t49nE83vhiXiLq4Rl94XiZiggf7K Iqh3avZvSmz5Iu35Ugrt6FAAJPPvfWWKeuOGgBmgV5SpGPhG2WF26gplUbpk9nkO3PbM UIsyByMGJ3ijfL/akDhdqJYqBf0zQ6U1gZtQkFI1TQJDysxQXfu6jhzu1/kvSdG5Ypr8 TtgC0aKYO1COowj2KxMtK/LidIxweJppV8E65vAm+KAGE7qvOE6kzAcwlyahgZhRne/2 X73A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4TPcnpyqLQpZCcVS6z5JcQDXYGcG9wuLZ7q9cO1olxg=; b=rl8BYBxbt6zGvyZV2T58mR0H5arUHEOuSlepuimH29uTUDy8lGPvwWGjajAz0aQutO rtCdORLXjmWowqfXogMvyWPDsD8kfdz+QoXGQtYqkXM+/ru66D9ZfSvZlTUKhcY5tyfq AWmw41Ti9TKNaMHBkbFuhf9VKe4ZN1Qwu39bNCWF6/mco5uBSjUyprPhomhj17F16Sb/ CKCwXNIbWNQphDnzz1d24X94uKaUvePIugXz6QfBGwit/jtZQNDFZfJoi2R11wU9iKbo 40HMeznNQp/2q5dW3eWHyyDZ1zr89BUKWS7Y0RAHVG4tuuPRP/w/ZTF7EYH4/3knATe3 x8Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si2806243ejj.147.2021.09.16.02.25.37; Thu, 16 Sep 2021 02:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235591AbhIPJZb (ORCPT + 99 others); Thu, 16 Sep 2021 05:25:31 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:16265 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235219AbhIPJZ0 (ORCPT ); Thu, 16 Sep 2021 05:25:26 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4H9BTV3jQFz8tC3; Thu, 16 Sep 2021 17:23:26 +0800 (CST) Received: from dggema762-chm.china.huawei.com (10.1.198.204) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Thu, 16 Sep 2021 17:24:04 +0800 Received: from huawei.com (10.175.127.227) by dggema762-chm.china.huawei.com (10.1.198.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Thu, 16 Sep 2021 17:24:04 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [patch v8 5/7] nbd: clean up return value checking of sock_xmit() Date: Thu, 16 Sep 2021 17:33:48 +0800 Message-ID: <20210916093350.1410403-6-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210916093350.1410403-1-yukuai3@huawei.com> References: <20210916093350.1410403-1-yukuai3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema762-chm.china.huawei.com (10.1.198.204) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check if sock_xmit() return 0 is useless because it'll never return 0, comment it and remove such checkings. Signed-off-by: Yu Kuai --- drivers/block/nbd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 22c91d8901f6..7f9e030e41ce 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -490,7 +490,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, } /* - * Send or receive packet. + * Send or receive packet. Return a positive value on success and + * negtive value on failue, and never return 0. */ static int sock_xmit(struct nbd_device *nbd, int index, int send, struct iov_iter *iter, int msg_flags, int *sent) @@ -616,7 +617,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) result = sock_xmit(nbd, index, 1, &from, (type == NBD_CMD_WRITE) ? MSG_MORE : 0, &sent); trace_nbd_header_sent(req, handle); - if (result <= 0) { + if (result < 0) { if (was_interrupted(result)) { /* If we havne't sent anything we can just return BUSY, * however if we have sent something we need to make @@ -660,7 +661,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) skip = 0; } result = sock_xmit(nbd, index, 1, &from, flags, &sent); - if (result <= 0) { + if (result < 0) { if (was_interrupted(result)) { /* We've already sent the header, we * have no choice but to set pending and @@ -712,7 +713,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) reply.magic = 0; iov_iter_kvec(&to, READ, &iov, 1, sizeof(reply)); result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL); - if (result <= 0) { + if (result < 0) { if (!nbd_disconnected(config)) dev_err(disk_to_dev(nbd->disk), "Receive control failed (result %d)\n", result); @@ -783,7 +784,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) rq_for_each_segment(bvec, req, iter) { iov_iter_bvec(&to, READ, &bvec, 1, bvec.bv_len); result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL); - if (result <= 0) { + if (result < 0) { dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n", result); /* @@ -1229,7 +1230,7 @@ static void send_disconnects(struct nbd_device *nbd) iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request)); mutex_lock(&nsock->tx_lock); ret = sock_xmit(nbd, i, 1, &from, 0, NULL); - if (ret <= 0) + if (ret < 0) dev_err(disk_to_dev(nbd->disk), "Send disconnect failed %d\n", ret); mutex_unlock(&nsock->tx_lock); -- 2.31.1