Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1209358rwe; Thu, 25 Aug 2022 18:38:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TQtQQA45wPFyqxuhwhcqF5xmSQKPQLVoxE+lEvTOaZBe72PuaJNV8/2mDsdqqnSJS10mK X-Received: by 2002:a17:906:fd84:b0:730:acee:d067 with SMTP id xa4-20020a170906fd8400b00730aceed067mr4108600ejb.206.1661477904924; Thu, 25 Aug 2022 18:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661477904; cv=none; d=google.com; s=arc-20160816; b=PGjCA3F+THoZ5U1BBosZGZAXMBev5dc8bMzO8JAewmMSdWJdFDfD5qMpgOros75H7L NQpORx/1TBHMdcyMWLbhSnp5XZe0tTGLwXWyNOtMR0EWT1BIQ/EkhtXECMy5fJtIcH0a PBYrDyybI4K5opc81lbRQF+T53eiCoMQIU0EwVJTug2XoGUkymCPnZoiA6YnBXfXhVKT WUZYuglb82nJyuot6kE9JmUGg9f1trYNelNfxdCnCAL8Q44E09iYSsU3RNquK9EHb8Lg OegV9M2KTPQ2xEu2Wx49jYQ4HH+4a7W0zUw6TiA3nXlis7xNKmU43xj02vekwRNTpHv4 1ZNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject; bh=YrhxEW0p1mbJJArZnHAP8lrbweYxibtdrXKI+DkaQCw=; b=uWSSRM2cSg7j9J8Dr402NLtX3e46G7fzUtSuE691Ey0sVKG9OulDYT511La7/xxWNW vC5MBPJcgYw9X5H5tSPOhoNLw6o66d4k7x3G2N60Z96zxhXjG18rQZG4HcJ1DOistwc3 Etp8v364sMwYyEjBLpAbCDwqP56Gm/x2qUV27FBJWMOlbe4HHtVQA8ko3H9SXxcJNqvZ oHU2vCRiBMnLNtNX9aBYgesx3jiJBctwLr8YyS78XwDmUobllRivxPhbSy6qY3J/Xg79 LSKE/jTmGf439vgkR4hEm95+awE7Xfi9HjuNZXDvadZgpTNhpBsNEI2h336Zh5zLv9Pp nhgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ke19-20020a17090798f300b0073c5e27e109si397240ejc.307.2022.08.25.18.37.56; Thu, 25 Aug 2022 18:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244045AbiHZBLm (ORCPT + 99 others); Thu, 25 Aug 2022 21:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243910AbiHZBLj (ORCPT ); Thu, 25 Aug 2022 21:11:39 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB28FC6CC1; Thu, 25 Aug 2022 18:11:37 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MDMFG0RkJzGprF; Fri, 26 Aug 2022 09:09:54 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 09:11:35 +0800 Received: from [10.174.178.31] (10.174.178.31) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 09:11:34 +0800 Subject: Re: [Linux-cachefs] [PATCH v3] cachefiles: fix error return code in cachefiles_ondemand_copen() To: Dan Carpenter , JeffleXu , , , , References: <20220818125038.2247720-1-sunke32@huawei.com> <3700079.1661336363@warthog.procyon.org.uk> <20220825133620.GB2071@kadam> From: Sun Ke Message-ID: Date: Fri, 26 Aug 2022 09:11:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.31] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/8/25 21:58, Gao Xiang 写道: > On Thu, Aug 25, 2022 at 04:36:20PM +0300, Dan Carpenter wrote: >> I spent a long time looking at this as well... It's really inscrutable >> code. It would be more readable if we just spelled things out in the >> most pedantic way possible: >> > > Yeah, the following code looks much better. Ke, would you mind > sending a version like below instead? OK, I will update it. > > Thanks, > Gao Xiang > >> diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c >> index 1fee702d5529..7e1586bd5cf3 100644 >> --- a/fs/cachefiles/ondemand.c >> +++ b/fs/cachefiles/ondemand.c >> @@ -158,9 +158,13 @@ int cachefiles_ondemand_copen(struct cachefiles_cache *cache, char *args) >> >> /* fail OPEN request if daemon reports an error */ >> if (size < 0) { >> - if (!IS_ERR_VALUE(size)) >> - size = -EINVAL; >> - req->error = size; >> + if (!IS_ERR_VALUE(size)) { >> + req->error = -EINVAL; >> + ret = -EINVAL; >> + } else { >> + req->error = size; >> + ret = 0; >> + } >> goto out; >> } >> >> >> -- >> Linux-cachefs mailing list >> Linux-cachefs@redhat.com >> https://listman.redhat.com/mailman/listinfo/linux-cachefs > . >