From patchwork Thu Jan 5 06:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li zeming X-Patchwork-Id: 39353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp149809wrt; Wed, 4 Jan 2023 22:26:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZ5bWW/hPZqQOc6n9qlok3usA2rYoqHv5t8oIAEDYn6/QulUjD/Vs+VS5qLzfCv8pW3Wf2 X-Received: by 2002:a17:907:209c:b0:7c1:41bb:70ac with SMTP id pv28-20020a170907209c00b007c141bb70acmr42919147ejb.64.1672900008817; Wed, 04 Jan 2023 22:26:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672900008; cv=none; d=google.com; s=arc-20160816; b=O2XosXntfA2/blocTsfGPMlzr4ghe/F7ZKhBMEWzNACKJ0IFiMa6HQv5xpVOfK1b6t rBltMEGOulBIU4bdtV6Gyz97b4P3n3mGfXuvX8jboNj4dalBYJjWXA2Ja1crV0CZcACw EhjSp3njnFIvkRUGJNFyFpjXqJDgv/07rp4xJalcJp61RCfw/Tisp/FEq/P9ioYx+vNG Nv+qaAPkAgvKeqCqcTEbzpJVWnoayVli1+N6L927eOA6Ug8/0Vg1nkImydO008u9TbR4 hQighSzKMM1y0LVd1PGqxeW1nJUxFavVVy+8y1QwLMmBMM8tP/6kxP/UrF3KA5wBwd7L +99g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc3-20020a170907074300b007825337afeesi31911085ejb.273.2023.01.04.22.26.24; Wed, 04 Jan 2023 22:26:48 -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 + 99 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754162799374763812?= X-GMAIL-MSGID: =?utf-8?q?1754162799374763812?= 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; }