Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5856138ioo; Wed, 1 Jun 2022 14:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTzUuclTRllYROKALydRi8pWQTJrgaecvoPqBuJcdwdOsSWZsoailK+PP8B05XgxgRpMeO X-Received: by 2002:a17:902:d2cb:b0:164:11ff:e55b with SMTP id n11-20020a170902d2cb00b0016411ffe55bmr1357606plc.111.1654118007309; Wed, 01 Jun 2022 14:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654118007; cv=none; d=google.com; s=arc-20160816; b=Qpm0jg/THLmpJNrFT/PkSiFpsphYr9XJybjTHfuD3IW4ycZhjKu/ZqBL5mnsMu0g+m TY7Vr1xoEYQo0QKRUqISO4Fx+QVgfYoz0M+Yd6fZAZH+sZqjnCYf/rxvjSCTjEN2jPbV JiMQ/Z3b4Yfbubg00fVjDA6yWKYQ5gH0QB5IZNr0Otrl3aUMafB3cyRiivOsGVeu0VKq k5RADZR6EqjBNQhvyhkJ+RnQEb8nqM6PZMaihlahdtRSVVVtXo/M3cklfH7M9p+K+O/s Dz1fC1zm94nQhwbS9CCQeHdvpf9pmUAn8tJ0H3aqSUf74EGw+/LJm1gcPZ+jF/021URA CFbA== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Cckc4s7C+CbZb8jiGkK5ijqtT9L5nMuyVbDLmo2FBhc=; b=0aQmWT74OrpfSAAsROFmxfmv5FEisxyHkysIFvgxzRdnKyBYmmlQchZf5gb4sbQFWQ fwNRMacW6Q2b3UpY83ABPsivJjtpqiqXOls+KV9WAUMn8iYfT3vUgEsu9nAC4gWBO/Fk rd5ZfaSskkdgh8yQGsOyNVjyiE5r3qCsBngnMeCxSvlynRU7zWmd7VcP8JDy2GC1Yohz kMgJRNiyjiL3MKnyyPyJZf8cwvD8iA0I6ObjBzog99Dt0Ve08WX5D9ZPY5mKdnvw0Oco C07MXV8MwCrI4cqRrqTdXI63jhh1OF0my9mP+QrwDKJyETxujZiwMrTR5U+DgDkye9zd k8pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=m6c2uhg8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d30-20020a631d1e000000b003c648ddf7f7si3080523pgd.141.2022.06.01.14.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:13:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=m6c2uhg8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F8A8224463; Wed, 1 Jun 2022 13:04:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239538AbiE3QjL (ORCPT + 99 others); Mon, 30 May 2022 12:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234034AbiE3QjK (ORCPT ); Mon, 30 May 2022 12:39:10 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B0D57178; Mon, 30 May 2022 09:39:08 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 575961F86; Mon, 30 May 2022 16:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1653928716; bh=Cckc4s7C+CbZb8jiGkK5ijqtT9L5nMuyVbDLmo2FBhc=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=m6c2uhg8sJdwJIiVqRJLsBqt71DdVduWZVK7weQHBNFHB8R2WhJcjdnQGOcaQYpJN go5fbpTN06a1oMF/jB8CZ0yUJgeEnp1dOlL/em+omtcQ3mSLPX/BsKueZO7G8mj6Pm rMZkgbk+i1ETqsytXx5ugBN4CjLZeoXQcPrb0728= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 30 May 2022 19:39:06 +0300 Message-ID: Date: Mon, 30 May 2022 19:39:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: [PATCH v2 1/3] fs/ntfs3: Refactoring of indx_find function Content-Language: en-US From: Konstantin Komarov To: CC: , , Joe Perches References: <6afbf4c7-825b-7148-b130-55f720857cb0@paragon-software.com> In-Reply-To: <6afbf4c7-825b-7148-b130-55f720857cb0@paragon-software.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This commit makes function a bit more readable Cc: Joe Perches Signed-off-by: Konstantin Komarov --- fs/ntfs3/index.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 6f81e3a49abf..8468cca5d54d 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1042,19 +1042,16 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni, { int err; struct NTFS_DE *e; - const struct INDEX_HDR *hdr; struct indx_node *node; if (!root) root = indx_get_root(&ni->dir, ni, NULL, NULL); if (!root) { - err = -EINVAL; - goto out; + /* Should not happen. */ + return -EINVAL; } - hdr = &root->ihdr; - /* Check cache. */ e = fnd->level ? fnd->de[fnd->level - 1] : fnd->root_de; if (e && !de_is_last(e) && @@ -1068,39 +1065,35 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni, fnd_clear(fnd); /* Lookup entry that is <= to the search value. */ - e = hdr_find_e(indx, hdr, key, key_len, ctx, diff); + e = hdr_find_e(indx, &root->ihdr, key, key_len, ctx, diff); if (!e) return -EINVAL; fnd->root_de = e; - err = 0; for (;;) { node = NULL; - if (*diff >= 0 || !de_has_vcn_ex(e)) { - *entry = e; - goto out; - } + if (*diff >= 0 || !de_has_vcn_ex(e)) + break; /* Read next level. */ err = indx_read(indx, ni, de_get_vbn(e), &node); if (err) - goto out; + return err; /* Lookup entry that is <= to the search value. */ e = hdr_find_e(indx, &node->index->ihdr, key, key_len, ctx, diff); if (!e) { - err = -EINVAL; put_indx_node(node); - goto out; + return -EINVAL; } fnd_push(fnd, node, e); } -out: - return err; + *entry = e; + return 0; } int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni, -- 2.36.1