Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp440956rwl; Wed, 4 Jan 2023 22:43:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSLY+E97iSnKALeXZ4Jo9s+ny4VW0K9kusufzacHvevGBZSNYOOjKpR2u4zvNXUKKrW6R6 X-Received: by 2002:a17:906:944c:b0:7c0:bd68:ce30 with SMTP id z12-20020a170906944c00b007c0bd68ce30mr42815595ejx.54.1672901005828; Wed, 04 Jan 2023 22:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672901005; cv=none; d=google.com; s=arc-20160816; b=Yd7R2WbW7fkK5geHy87FWK57X037a8/GVxzREFY6mbTobSKfQz2isD5sQIZNT7CGfO fNCINcu4Nic/xaozuGXWjapiwjAb6zWsLZAEeOV7CP8r/ZArzuvR7gddNbB1IGG9Sb2Q yBvu2YXb/mz6vvEDBK8T17XbDUt/w/ZGIgJOe8oHXO1j2rlk0P0yfENLYyB0gG5u8J06 ytlvhgcvFj0MwzA9S0HKVS699AaLne1pR42VaT9mL52IZ0805x84pdk+wxqIB83TEkGE v8Cc8QPg2IlbzMXrd1yYxyRgPNOtLB2kZiF/iJBpntr6aLgiJvhciE4dPWs/XnyTBEVs mczQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=4zOuJFHo/Lk99gmttgAEnkbKIMG3/p1fbDVScN55McY=; b=thm+rXgq+6bGU9K7L65VX9jFCP+Q/Wrg2uT8mBS6iQBbQhUF0CPjODJYCAmpQac7OW XenJtIKtb48PX7qTAnADSpVzNR0sDIFkJZUIXqSRIdn+WerHgz2p5zTW2hxaIhXhp0Nb PfMUMy1TGgiqcVpMev8CBRIiOys1Enx+Hv5P0bVKYfHpF0yL8g4dpEKoRmV6qZnQE4mh vLNonkZCZxB4fz0l9ddF/R8ELD65EUMEKrLNsowUQA36fTHbd10RssUZltmz9iom7/J3 +USlC9aWLDDaCoqAm+JvjnW3MoxVD2XvrSvLOlHZf5mRPuRIBIA7iagemzRnjP1IkJ3F UvkQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020aa7c0c8000000b0046c786d3711si28525779edp.51.2023.01.04.22.43.12; Wed, 04 Jan 2023 22:43:25 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbjAEGYB (ORCPT + 55 others); Thu, 5 Jan 2023 01:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjAEGXw (ORCPT ); Thu, 5 Jan 2023 01:23:52 -0500 X-Greylist: delayed 314 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 04 Jan 2023 22:23:51 PST Received: from mail.nfschina.com (unknown [42.101.60.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3026251334; Wed, 4 Jan 2023 22:23:50 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 20E631A00A03; Thu, 5 Jan 2023 14:18:46 +0800 (CST) X-Virus-Scanned: amavisd-new at nfschina.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b3-uxC-P4cjZ; Thu, 5 Jan 2023 14:18:45 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 4B7FE1A0074C; Thu, 5 Jan 2023 14:18:45 +0800 (CST) From: Li zeming To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] filesystems: Simplify if conditional statements Date: Thu, 5 Jan 2023 14:18:31 +0800 Message-Id: <20230105061831.3516-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NONE 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 When the * p pointer is null, assign a value to res; otherwise, do not execute the content in the conditional statement block. Signed-off-by: Li zeming --- fs/filesystems.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/filesystems.c b/fs/filesystems.c index 58b9067b2391..1839dcd6cfbd 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -71,7 +71,7 @@ static struct file_system_type **find_filesystem(const char *name, unsigned len) int register_filesystem(struct file_system_type * fs) { - int res = 0; + int res = -EBUSY; struct file_system_type ** p; if (fs->parameters && @@ -83,10 +83,10 @@ int register_filesystem(struct file_system_type * fs) return -EBUSY; write_lock(&file_systems_lock); p = find_filesystem(fs->name, strlen(fs->name)); - if (*p) - res = -EBUSY; - else + if (!*p) { + res = 0; *p = fs; + } write_unlock(&file_systems_lock); return res; } -- 2.18.2