Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp494783pxb; Wed, 18 Aug 2021 07:09:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh9zBfYwxVzUfDxv13SdzkddZEppdptVJJAVCyX+ShEn7NGgJBARJrDPf1X+IH8TFXdIVg X-Received: by 2002:a02:9147:: with SMTP id b7mr8276007jag.39.1629295794705; Wed, 18 Aug 2021 07:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629295794; cv=none; d=google.com; s=arc-20160816; b=aiXjUbvOvZqzQ/tQrltH5SzONmz+Ky+sO35d2Z1/2dvT3XrxgshORnle4sigsMRyH2 WoTtHkfcQPOEvyCzASv7d+zNTs94FFM4Lw/iHvwEQR/hv9gy3tvs0RUq6ND+vqfjmloQ 5tqKn/MzyY4NjuQZPGZre4yDQFGW5B4Tw+XTbJ2dYybuPoKQwB5oWrj8eC4+UYk39qIF 2Bfa1ec1oOY7bPK82bUiqqCKqqrQ+7otO3cBRdMkDnPqrEbptxnJR4IlUJbTs+GKANWt fyaVDMXW7noH9JQ7+CuwgEnxoxAgEs+t3iRp11kGkI3iedRSPLVvW5uJKiR/yVfnX9aZ AyKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cibSNcvbBNy3d99J0xcybasLYRaPm2YAac4xI0ywMu8=; b=kaAHBYuguA3NrjtYWdbtWRRG4ENLp1/xhNTW7mNtJLrTHICou0T48YF6vfwu5VqoWF sd89lv3ZWk0fAUBBHcUWFFbZEOyxz0Lzf51uUmVnrTU6fg5N1f8L34IHlflz9OjywbuC b0Xi02L5gjAlI8vyofCZ3tC15ILPvFyz95WOBweHnpNQDrhsBmAYEWcw4VfWW50mOX6o cT/p73twilRnRIbP2SF54lvURKenJScr7VN9Hc/ldClmiq3kNZoUN8HskyD16fvQjaAA rhTnLA4gtC5eoDOS1cMBTerlT1H3sbJoRgsBjxv/nBv4kVN42x3jkYLIg8JF4ZnJzfYE on6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=dlWPccbA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si5169363jar.3.2021.08.18.07.09.39; Wed, 18 Aug 2021 07:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=dlWPccbA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235121AbhHROKF (ORCPT + 99 others); Wed, 18 Aug 2021 10:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237786AbhHROKE (ORCPT ); Wed, 18 Aug 2021 10:10:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16A94C061764; Wed, 18 Aug 2021 07:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=cibSNcvbBNy3d99J0xcybasLYRaPm2YAac4xI0ywMu8=; b=dlWPccbA45UR38UUdOxp+hXJ6w k6xHpfeWjanPnLTGesnuRrC3bHSxpNX/PaH/BecYbfmTwtflh1+SKGdZcgHlwoOUWnfwS+QJEWLAJ 2UgSTJSSgmxNuzobdkYK0nSL66Q8eB8PvsYAHQfv0aMC4zwVMQ1/CuOVNrOIfkeYz2TfGj5wGB3jV T+xRI+oCQZB+H+vTJw0TYgFzT4yy6pSb4ScX+H8xP5achbWhvZia0Zom9WSkg0NOnclkRFfaaGAXT MSOQPRxTqS4K6//RXhEwyAaeum4IKnrAYqqhdz5p0InvM23dKMsNFoXwhDrvd7WdAOelONE+lX613 KEDaOecA==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMEZ-003uKw-LT; Wed, 18 Aug 2021 14:08:35 +0000 From: Christoph Hellwig To: Gabriel Krisman Bertazi Cc: Shreeya Patel , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH 01/11] ext4: simplify ext4_sb_read_encoding Date: Wed, 18 Aug 2021 16:06:41 +0200 Message-Id: <20210818140651.17181-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818140651.17181-1-hch@lst.de> References: <20210818140651.17181-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Return the encoding table as the return value instead of as an argument, and don't bother with the encoding flags as the caller can handle that trivially. Signed-off-by: Christoph Hellwig --- fs/ext4/super.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dfa09a277b56..a68be582bba5 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2021,24 +2021,17 @@ static const struct ext4_sb_encodings { {EXT4_ENC_UTF8_12_1, "utf8", "12.1.0"}, }; -static int ext4_sb_read_encoding(const struct ext4_super_block *es, - const struct ext4_sb_encodings **encoding, - __u16 *flags) +static const struct ext4_sb_encodings * +ext4_sb_read_encoding(const struct ext4_super_block *es) { __u16 magic = le16_to_cpu(es->s_encoding); int i; for (i = 0; i < ARRAY_SIZE(ext4_sb_encoding_map); i++) if (magic == ext4_sb_encoding_map[i].magic) - break; - - if (i >= ARRAY_SIZE(ext4_sb_encoding_map)) - return -EINVAL; + return &ext4_sb_encoding_map[i]; - *encoding = &ext4_sb_encoding_map[i]; - *flags = le16_to_cpu(es->s_encoding_flags); - - return 0; + return NULL; } #endif @@ -4303,10 +4296,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { const struct ext4_sb_encodings *encoding_info; struct unicode_map *encoding; - __u16 encoding_flags; + __u16 encoding_flags = le16_to_cpu(es->s_encoding_flags); - if (ext4_sb_read_encoding(es, &encoding_info, - &encoding_flags)) { + encoding_info = ext4_sb_read_encoding(es); + if (!encoding_info) { ext4_msg(sb, KERN_ERR, "Encoding requested by superblock is unknown"); goto failed_mount; -- 2.30.2