Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1713094 > unrolled thread

[PATCH 0/2] fs-qnx6: Adjustments for qnx6_mmi_fill_super()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-08-16 18:20 +0200
Last post2017-08-16 18:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] fs-qnx6: Adjustments for qnx6_mmi_fill_super() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-16 18:20 +0200
    [PATCH 2/2] fs-qnx6: Less checks in qnx6_mmi_fill_super() after error  detection SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-16 18:20 +0200

#1713094 — [PATCH 0/2] fs-qnx6: Adjustments for qnx6_mmi_fill_super()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-16 18:20 +0200
Subject[PATCH 0/2] fs-qnx6: Adjustments for qnx6_mmi_fill_super()
Message-ID<uf9cZ-Pi-11@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 16 Aug 2017 18:08:02 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an error message for a failed memory allocation
  Less checks in qnx6_mmi_fill_super() after error detection

 fs/qnx6/super_mmi.c | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

-- 
2.14.0

[toc] | [next] | [standalone]


#1713098 — [PATCH 2/2] fs-qnx6: Less checks in qnx6_mmi_fill_super() after error detection

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-16 18:20 +0200
Subject[PATCH 2/2] fs-qnx6: Less checks in qnx6_mmi_fill_super() after error detection
Message-ID<uf9d1-Pi-29@gated-at.bofh.it>
In reply to#1713094
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 16 Aug 2017 18:00:24 +0200

Two pointer checks could be repeated by the qnx6_mmi_fill_super() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete an initialisation for the variables "bh2" and "qsb"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/qnx6/super_mmi.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/fs/qnx6/super_mmi.c b/fs/qnx6/super_mmi.c
index fdcfc99e2db6..eb98479f9ec1 100644
--- a/fs/qnx6/super_mmi.c
+++ b/fs/qnx6/super_mmi.c
@@ -34,9 +34,9 @@ static void qnx6_mmi_copy_sb(struct qnx6_super_block *qsb,
 
 struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
 {
-	struct buffer_head *bh1, *bh2 = NULL;
+	struct buffer_head *bh1, *bh2;
 	struct qnx6_mmi_super_block *sb1, *sb2;
-	struct qnx6_super_block *qsb = NULL;
+	struct qnx6_super_block *qsb;
 	struct qnx6_sb_info *sbi;
 	__u64 offset;
 
@@ -52,7 +52,7 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
 	if (fs32_to_cpu(sbi, sb1->sb_magic) != QNX6_SUPER_MAGIC) {
 		if (!silent) {
 			pr_err("wrong signature (magic) in superblock #1.\n");
-			goto out;
+			goto brelse_first;
 		}
 	}
 
@@ -60,7 +60,7 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
 	if (fs32_to_cpu(sbi, sb1->sb_checksum) !=
 				crc32_be(0, (char *)(bh1->b_data + 8), 504)) {
 		pr_err("superblock #1 checksum error\n");
-		goto out;
+		goto brelse_first;
 	}
 
 	/* calculate second superblock blocknumber */
@@ -70,38 +70,38 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
 	/* set new blocksize */
 	if (!sb_set_blocksize(s, fs32_to_cpu(sbi, sb1->sb_blocksize))) {
 		pr_err("unable to set blocksize\n");
-		goto out;
+		goto brelse_first;
 	}
 	/* blocksize invalidates bh - pull it back in */
 	brelse(bh1);
 	bh1 = sb_bread(s, 0);
 	if (!bh1)
-		goto out;
+		goto exit;
 	sb1 = (struct qnx6_mmi_super_block *)bh1->b_data;
 
 	/* read second superblock */
 	bh2 = sb_bread(s, offset);
 	if (!bh2) {
 		pr_err("unable to read the second superblock\n");
-		goto out;
+		goto brelse_first;
 	}
 	sb2 = (struct qnx6_mmi_super_block *)bh2->b_data;
 	if (fs32_to_cpu(sbi, sb2->sb_magic) != QNX6_SUPER_MAGIC) {
 		if (!silent)
 			pr_err("wrong signature (magic) in superblock #2.\n");
-		goto out;
+		goto brelse_second;
 	}
 
 	/* checksum check - start at byte 8 and end at byte 512 */
 	if (fs32_to_cpu(sbi, sb2->sb_checksum)
 			!= crc32_be(0, (char *)(bh2->b_data + 8), 504)) {
 		pr_err("superblock #1 checksum error\n");
-		goto out;
+		goto brelse_second;
 	}
 
 	qsb = kmalloc(sizeof(*qsb), GFP_KERNEL);
 	if (!qsb)
-		goto out;
+		goto brelse_second;
 
 	if (fs64_to_cpu(sbi, sb1->sb_serial) >
 					fs64_to_cpu(sbi, sb2->sb_serial)) {
@@ -136,11 +136,10 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
 
 	/* success */
 	return sbi->sb;
-
-out:
-	if (bh1 != NULL)
-		brelse(bh1);
-	if (bh2 != NULL)
-		brelse(bh2);
+brelse_second:
+	brelse(bh2);
+brelse_first:
+	brelse(bh1);
+exit:
 	return NULL;
 }
-- 
2.14.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web