mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] JFFS2: Adjustments for seven function implementations
@ 2017-08-18 19:05 SF Markus Elfring
  2017-08-18 19:06 ` [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-18 19:05 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: LKML, kernel-janitors

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions
  2017-08-18 19:05 [PATCH 0/3] JFFS2: Adjustments for seven function implementations SF Markus Elfring
@ 2017-08-18 19:06 ` SF Markus Elfring
  2017-08-18 19:07 ` [PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium() SF Markus Elfring
  2017-08-18 19:08 ` [PATCH 3/3] jffs2: Adjust a null pointer check in two functions SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-18 19:06 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: LKML, kernel-janitors

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium()
  2017-08-18 19:05 [PATCH 0/3] JFFS2: Adjustments for seven function implementations SF Markus Elfring
  2017-08-18 19:06 ` [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
@ 2017-08-18 19:07 ` SF Markus Elfring
  2017-08-18 19:08 ` [PATCH 3/3] jffs2: Adjust a null pointer check in two functions SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-18 19:07 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: LKML, kernel-janitors

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] jffs2: Adjust a null pointer check in two functions
  2017-08-18 19:05 [PATCH 0/3] JFFS2: Adjustments for seven function implementations SF Markus Elfring
  2017-08-18 19:06 ` [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
  2017-08-18 19:07 ` [PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium() SF Markus Elfring
@ 2017-08-18 19:08 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-18 19:08 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse; +Cc: LKML, kernel-janitors

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-18 19:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 19:05 [PATCH 0/3] JFFS2: Adjustments for seven function implementations SF Markus Elfring
2017-08-18 19:06 ` [PATCH 1/3] jffs2: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
2017-08-18 19:07 ` [PATCH 2/3] jffs2: Improve a size determination in jffs2_scan_medium() SF Markus Elfring
2017-08-18 19:08 ` [PATCH 3/3] jffs2: Adjust a null pointer check in two functions SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome