From nobody Sun May 15 22:02:44 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BAB211B3545A; Sun, 15 May 2022 22:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L1bwN4s7Gz3Bqm; Sun, 15 May 2022 22:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652652164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FUBAZtlBUsZ/DxYq+UYaiaKXGKYc4oQhvIm4Wp+jNr4=; b=FoyStc4MFxJvrBFG/7+FLBB8R3aXBuf6mNB7n0zKWntkXboAoItp+rexG6s9qAJqNReYDV fiP0V5a0NCYUGIDooe7bKthL9slikusuAwOq/D8uTOrdFSr5i5U41+QybLZ4GuOzKt75+Z rv6Ag6d4XH3KhBSIgwFu9hDlmFq+ln7YW4mZTFiZhOuqPgp0x0DOjXx1fvbAVH1h54Hz5G 4yBlGe5k53Pz5ACmWCpv7c0vHdwebD68V6a+PsbTrOIXsBUoi7mZIujy+WE0iOh/1GT6f/ Urr7iHTsSMr2+xlEnuFQDct+mEANZWMPRD7UUdIIbSlNN6B7Cexpb5EGrVJ+Og== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7CAC913FA3; Sun, 15 May 2022 22:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24FM2iPc092025; Sun, 15 May 2022 22:02:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24FM2it8092024; Sun, 15 May 2022 22:02:44 GMT (envelope-from git) Date: Sun, 15 May 2022 22:02:44 GMT Message-Id: <202205152202.24FM2it8092024@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 187d7e982132 - main - Reduce code nesting in readsuper(). List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 187d7e982132d0c971c16348118381076654ec37 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652652164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FUBAZtlBUsZ/DxYq+UYaiaKXGKYc4oQhvIm4Wp+jNr4=; b=J97852PfrpFZ7AkuubYjuAVs8bbnz+L78rKe5nN9npaQqFju8JsxWdiie41pfUTQq5mou+ n0Ln1kIH4kpGG2yPUV8P5Zxsw3eqe8olYZlEYRk9lEO/xW09j18WaHJr8hh9eWfmKDUmtA H6IhfHpmLzmPmNcWUoXrynMILbXjNph2rJZNu7HdkI/0lvveXkg72twC8wpTNyM30epLsi DRXXHKf3PAopb55pSJfAiEBkEc+JNkM7h9SVz9qeqYY6uWvvxYiZmHrpsqpCYjj+/L31Fu wIkMjYZnDgDF4V+3Q7G5RHaI0dzCa0ibM7GRqY3nKW6YOEy2zVQ7Tgxg+EAEyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652652164; a=rsa-sha256; cv=none; b=qtWgdaYVT4Q638YhR9W1ilC5xTXuOQ3CwweOuNXHNZ7SJZm635mhDKqIeJM4OWjo2BHAOP Y+ULw9j7cPvWvU7URptrl2K3duHY3VmFoCoOSznQl7l3JnE2sDb//YVJoeS48sSRfRIHMY hdNN+gpQkTEfetvVk7y+xypEuo+H9Qsguy48I4BGIXCLdtuDJoTbVdY5aa4yGqeuW0jipv iPkiV3cmH5VvGkJIsBher3dLFweXqZPNmjGhGnygWnB85SPig1pHHuNqTgAmenobEVPZga WiqYsMVHKQnBOEbQIvMY2l8KJ9hcjiJELM5xcHNTBWpuiI/VWSUiHbHmtaKp1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=187d7e982132d0c971c16348118381076654ec37 commit 187d7e982132d0c971c16348118381076654ec37 Author: Kirk McKusick AuthorDate: 2022-05-15 22:01:14 +0000 Commit: Kirk McKusick CommitDate: 2022-05-15 22:02:24 +0000 Reduce code nesting in readsuper(). No functional change. --- sys/ufs/ffs/ffs_subr.c | 87 +++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 45fc3aa2cb25..01e9f45e1205 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -253,7 +253,7 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, fs = *fsp; if (fs->fs_magic == FS_BAD_MAGIC) return (EINVAL); - if (((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk || + if (!(((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk || sblockloc <= SBLOCK_UFS1)) || (fs->fs_magic == FS_UFS2_MAGIC && (isaltsblk || sblockloc == fs->fs_sblockloc))) && @@ -261,54 +261,53 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, fs->fs_bsize >= MINBSIZE && fs->fs_bsize <= MAXBSIZE && fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE) && - fs->fs_sbsize <= SBLOCKSIZE) { - /* - * If the filesystem has been run on a kernel without - * metadata check hashes, disable them. - */ - if ((fs->fs_flags & FS_METACKHASH) == 0) - fs->fs_metackhash = 0; - /* - * Clear any check-hashes that are not maintained - * by this kernel. Also clear any unsupported flags. - */ - fs->fs_metackhash &= CK_SUPPORTED; - fs->fs_flags &= FS_SUPPORTED; - if (fs->fs_ckhash != (ckhash = ffs_calc_sbhash(fs))) { - if (chkhash == STDSB_NOMSG) - return (EINTEGRITY); - if (chkhash == STDSB_NOHASHFAIL_NOMSG) - return (0); + fs->fs_sbsize <= SBLOCKSIZE)) + return (ENOENT); + /* + * If the filesystem has been run on a kernel without + * metadata check hashes, disable them. + */ + if ((fs->fs_flags & FS_METACKHASH) == 0) + fs->fs_metackhash = 0; + /* + * Clear any check-hashes that are not maintained + * by this kernel. Also clear any unsupported flags. + */ + fs->fs_metackhash &= CK_SUPPORTED; + fs->fs_flags &= FS_SUPPORTED; + if (fs->fs_ckhash != (ckhash = ffs_calc_sbhash(fs))) { + if (chkhash == STDSB_NOMSG) + return (EINTEGRITY); + if (chkhash == STDSB_NOHASHFAIL_NOMSG) + return (0); #ifdef _KERNEL - res = uprintf("Superblock check-hash failed: recorded " - "check-hash 0x%x != computed check-hash 0x%x%s\n", - fs->fs_ckhash, ckhash, - chkhash == STDSB_NOHASHFAIL ? " (Ignored)" : ""); + res = uprintf("Superblock check-hash failed: recorded " + "check-hash 0x%x != computed check-hash 0x%x%s\n", + fs->fs_ckhash, ckhash, + chkhash == STDSB_NOHASHFAIL ? " (Ignored)" : ""); #else - res = 0; + res = 0; #endif - /* - * Print check-hash failure if no controlling terminal - * in kernel or always if in user-mode (libufs). - */ - if (res == 0) - printf("Superblock check-hash failed: recorded " - "check-hash 0x%x != computed check-hash " - "0x%x%s\n", fs->fs_ckhash, ckhash, - chkhash == STDSB_NOHASHFAIL ? - " (Ignored)" : ""); - if (chkhash == STDSB) - return (EINTEGRITY); - /* chkhash == STDSB_NOHASHFAIL */ - return (0); - } - /* Have to set for old filesystems that predate this field */ - fs->fs_sblockactualloc = sblockloc; - /* Not yet any summary information */ - fs->fs_si = NULL; + /* + * Print check-hash failure if no controlling terminal + * in kernel or always if in user-mode (libufs). + */ + if (res == 0) + printf("Superblock check-hash failed: recorded " + "check-hash 0x%x != computed check-hash " + "0x%x%s\n", fs->fs_ckhash, ckhash, + chkhash == STDSB_NOHASHFAIL ? + " (Ignored)" : ""); + if (chkhash == STDSB) + return (EINTEGRITY); + /* chkhash == STDSB_NOHASHFAIL */ return (0); } - return (ENOENT); + /* Have to set for old filesystems that predate this field */ + fs->fs_sblockactualloc = sblockloc; + /* Not yet any summary information */ + fs->fs_si = NULL; + return (0); } /*