Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4549101ioo; Tue, 31 May 2022 06:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz341P6c6tOMSbch8EnN2UaK18JqfaMFDwQKODQpXmVKuNi27kSQzsoClrEICjPc3UF7fIS X-Received: by 2002:a17:906:7949:b0:6ff:27a9:f024 with SMTP id l9-20020a170906794900b006ff27a9f024mr22247939ejo.277.1654005278295; Tue, 31 May 2022 06:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654005278; cv=none; d=google.com; s=arc-20160816; b=dNPSey3m9howybdw2EZKoz07t9nFuVnnSkApf93EJlA0SJZ+d1ow7ZWbs/N659058m 6dQ5IA4pk4qvrjIycF1BOpQdzGR8KkrAL03B9nhWKrofVIBkRNoIGN27aLFkaAAWjeiX BV9Pl1FF/w67F1JlWIXiumA0jWA5df6ks0fep/kbt2v/axfnJR9CVKtpfC22G2eXetrs d7LdmRpgZWBYsJxNjQi/BYylgnsMyv/mw+I6o3r2E0FnR9Lcs21fKUiH8j9cV9pV8cCs GeXROKudzR6TCNel3a0jfZLxEOzFu8UxDFjl9WwUmdwv4Q23nVXkAFqm6joAaCfftVVH MesA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=8VawmhTG+GHXT/MqMClG55CYn/p1qfgGoNeayV4I14I=; b=khEH7ZdZL+VcnTbgMdJt4MAz1Gb9ZMDHjxisWZaGeLPOkiFIpNGdxMWgO13u+nNi5a Wth7VgSj5pm5vQbzgDrnyAlkMsIzvD11G3pwIEkF54UDABgtiyFfSN+i2BjAICOJX14T KPaZAVVUpYE8zupeqOriYMfH3ikP3Ld/YPh8IahlATAOr1C0zIAexWpR/5PzMdMpGgEW /1LkChuBxZAhF5TfGH7gKxdAnojJ7nb+SxLmsgds7ngXbAeu4gtMXPe1tRY1ErdGmr4/ v+u8Y6LVA+Y09gLoFb/gs3qj9ftM+mNUpqjFrUUjx1B+DStZogvdpQjbvtzwh84/3voO WTBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FppLj4+t; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a0564021e9500b0042aab55adb3si11274114edf.355.2022.05.31.06.53.48; Tue, 31 May 2022 06:54:38 -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; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FppLj4+t; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241791AbiE3RLc (ORCPT + 99 others); Mon, 30 May 2022 13:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234576AbiE3RL2 (ORCPT ); Mon, 30 May 2022 13:11:28 -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 5D13652E77; Mon, 30 May 2022 10:11:27 -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 F329C1F86; Mon, 30 May 2022 17:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1653930655; bh=8VawmhTG+GHXT/MqMClG55CYn/p1qfgGoNeayV4I14I=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=FppLj4+tXN0lfjH0ZLbXyWZlpqsHu4M6HQkX8W5yhH79I9PSoeMTVxIYzm7xlCOss Rc4HfZIOf62fcCL9mateBBiSLrBMMeULR1cvY3KU99IDX/gdXOgZLPS/9oAKXBuZ0Y pSMhTGFE25hCSX83f5CSwiCOKd6+hfqLO84cYQlw= 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 20:11:24 +0300 Message-ID: <075d601a-1d79-acbd-2d03-92a1a73cf9c7@paragon-software.com> Date: Mon, 30 May 2022 20:11:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 1/3] fs/ntfs3: Refactoring of indx_find function Content-Language: en-US To: Joe Perches , CC: , References: <75a1215a-eda2-d0dc-b962-0334356eef7c@paragon-software.com> <0f9648cc-66af-077c-88e6-8650fd78f44c@paragon-software.com> <94dd870e498e89e0998dee4dd0dbaaa4b4497929.camel@perches.com> From: Konstantin Komarov In-Reply-To: <94dd870e498e89e0998dee4dd0dbaaa4b4497929.camel@perches.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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 Hello. Thanks for your input. It's nice to have a clear typical return value, so I've updated patch. On 5/27/22 19:07, Joe Perches wrote: > On Fri, 2022-05-27 at 17:21 +0300, Almaz Alexandrovich wrote: >> This commit makes function a bit more readable > > trivia: > >> diff --git 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 happed. */ >> + return -EINVAL; > > s/happed/happen/ > >> for (;;) { >> node = NULL; >> if (*diff >= 0 || !de_has_vcn_ex(e)) { >> *entry = e; >> - goto out; >> + return 0; >> } > > might be nicer with a break; or a while like > > while (*diff < 0 && de_has_vcn_ex(e)) { > node = NULL; > > >> /* 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; > > and a return 0; > > or > *entry = e; > return 0; > > so it appears that the function has a typical return value. >