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


Groups > linux.kernel > #1715383 > unrolled thread

[PATCH 0/3] JFFS2: Adjustments for seven function implementations

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

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] JFFS2: Adjustments for seven function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-18 21:10 +0200
    [PATCH 3/3] jffs2: Adjust a null pointer check in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-18 21:10 +0200
    [PATCH 2/3] jffs2: Improve a size determination in  jffs2_scan_medium() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-18 21:10 +0200
    [PATCH 1/3] jffs2: Delete an error message for a failed memory  allocation in four functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-18 21:10 +0200

#1715383 — [PATCH 0/3] JFFS2: Adjustments for seven function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-18 21:10 +0200
Subject[PATCH 0/3] JFFS2: Adjustments for seven function implementations
Message-ID<ufUOB-7Rd-5@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 18 Aug 2017 20:50:05 +0200

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

Markus Elfring (3):
  Delete an error message for a failed memory allocation in four functions
  Improve a size determination in jffs2_scan_medium()
  Adjust a null pointer check in two functions

 fs/jffs2/compr.c    | 5 ++---
 fs/jffs2/dir.c      | 1 -
 fs/jffs2/erase.c    | 5 +----
 fs/jffs2/gc.c       | 5 ++---
 fs/jffs2/nodemgmt.c | 3 +--
 fs/jffs2/scan.c     | 2 +-
 fs/jffs2/security.c | 2 +-
 7 files changed, 8 insertions(+), 15 deletions(-)

-- 
2.14.0

[toc] | [next] | [standalone]


#1715384 — [PATCH 3/3] jffs2: Adjust a null pointer check in two functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-18 21:10 +0200
Subject[PATCH 3/3] jffs2: Adjust a null pointer check in two functions
Message-ID<ufUOC-7Rd-9@gated-at.bofh.it>
In reply to#1715383
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 18 Aug 2017 20:40:35 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jffs2/nodemgmt.c | 3 +--
 fs/jffs2/security.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index a7bbe879cfc3..d5346ba782f7 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -242,8 +242,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
 
 static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
 {
-
-	if (c->nextblock == NULL) {
+	if (!c->nextblock) {
 		jffs2_dbg(1, "%s(): Erase block at 0x%08x has already been placed in a list\n",
 			  __func__, jeb->offset);
 		return;
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c
index c2332e30f218..9859b522721f 100644
--- a/fs/jffs2/security.c
+++ b/fs/jffs2/security.c
@@ -29,7 +29,7 @@ static int jffs2_initxattrs(struct inode *inode,
 	const struct xattr *xattr;
 	int err = 0;
 
-	for (xattr = xattr_array; xattr->name != NULL; xattr++) {
+	for (xattr = xattr_array; xattr->name; xattr++) {
 		err = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY,
 					xattr->name, xattr->value,
 					xattr->value_len, 0);
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1715387 — [PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-18 21:10 +0200
Subject[PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium()
Message-ID<ufUOD-7Rd-23@gated-at.bofh.it>
In reply to#1715383
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 18 Aug 2017 20:22:15 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jffs2/scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 90431dd613b8..d7696151b47d 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -132,5 +132,5 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
 	}
 
 	if (jffs2_sum_active()) {
-		s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
+		s = kzalloc(sizeof(*s), GFP_KERNEL);
 		if (!s) {
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1715388 — [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-18 21:10 +0200
Subject[PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions
Message-ID<ufUOD-7Rd-25@gated-at.bofh.it>
In reply to#1715383
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 18 Aug 2017 20:06:44 +0200

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/jffs2/compr.c | 5 ++---
 fs/jffs2/dir.c   | 1 -
 fs/jffs2/erase.c | 5 +----
 fs/jffs2/gc.c    | 5 ++---
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c
index 4849a4c9a0e2..96d19ef95b11 100644
--- a/fs/jffs2/compr.c
+++ b/fs/jffs2/compr.c
@@ -80,10 +80,9 @@ static int jffs2_selected_compress(u8 compr, unsigned char *data_in,
 	char *output_buf;
 
 	output_buf = kmalloc(*cdatalen, GFP_KERNEL);
-	if (!output_buf) {
-		pr_warn("No memory for compressor allocation. Compression failed.\n");
+	if (!output_buf)
 		return ret;
-	}
+
 	orig_slen = *datalen;
 	orig_dlen = *cdatalen;
 	spin_lock(&jffs2_compressor_list_lock);
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 0a754f38462e..0b126df5ecc6 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -350,7 +350,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
 	/* We use f->target field to store the target path. */
 	f->target = kmemdup(target, targetlen + 1, GFP_KERNEL);
 	if (!f->target) {
-		pr_warn("Can't allocate %d bytes of memory\n", targetlen + 1);
 		mutex_unlock(&f->sem);
 		jffs2_complete_reservation(c);
 		ret = -ENOMEM;
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index 4a6cf289be24..d944748524ad 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -380,8 +380,5 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
-	if (!ebuf) {
-		pr_warn("Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n",
-			jeb->offset);
+	if (!ebuf)
 		return -EAGAIN;
-	}
 
 	jffs2_dbg(1, "Verifying erase at 0x%08x\n", jeb->offset);
 
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 9ed0f26cf023..9e49392458e3 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -780,7 +780,6 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
-		if (!mdata) {
-			pr_warn("kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n");
+		if (!mdata)
 			return -ENOMEM;
-		}
+
 		ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen);
 		if (ret) {
 			pr_warn("read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n",
-- 
2.14.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web