* [PATCH 0/3] OrangeFS: Adjustments for some function implementations
@ 2017-08-17 20:11 SF Markus Elfring
2017-08-17 20:13 ` [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions SF Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-17 20:11 UTC (permalink / raw)
To: Martin Brandenburg, Mike Marshall, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 17 Aug 2017 21:54:32 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete error messages for a failed memory allocation in five functions
Use kcalloc() in orangefs_prepare_cdm_array()
Adjust three checks for null pointers
fs/orangefs/acl.c | 2 +-
fs/orangefs/devorangefs-req.c | 9 +++------
fs/orangefs/orangefs-bufmap.c | 10 ++--------
fs/orangefs/orangefs-debugfs.c | 5 +----
fs/orangefs/orangefs-mod.c | 1 -
fs/orangefs/super.c | 4 +---
fs/orangefs/xattr.c | 4 ++--
7 files changed, 10 insertions(+), 25 deletions(-)
--
2.14.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions
2017-08-17 20:11 [PATCH 0/3] OrangeFS: Adjustments for some function implementations SF Markus Elfring
@ 2017-08-17 20:13 ` SF Markus Elfring
2017-08-17 20:14 ` [PATCH 2/3] orangefs: Use kcalloc() in orangefs_prepare_cdm_array() SF Markus Elfring
2017-08-17 20:15 ` [PATCH 3/3] orangefs: Adjust three checks for null pointers SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-17 20:13 UTC (permalink / raw)
To: Martin Brandenburg, Mike Marshall, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 17 Aug 2017 21:00:07 +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/orangefs/devorangefs-req.c | 9 +++------
fs/orangefs/orangefs-bufmap.c | 10 ++--------
fs/orangefs/orangefs-debugfs.c | 1 -
fs/orangefs/orangefs-mod.c | 1 -
fs/orangefs/super.c | 4 +---
5 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c
index c19f0787c9c6..2826859bdc2c 100644
--- a/fs/orangefs/devorangefs-req.c
+++ b/fs/orangefs/devorangefs-req.c
@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
if (op->downcall.type != ORANGEFS_VFS_OP_READDIR)
goto wakeup;
- op->downcall.trailer_buf =
- vmalloc(op->downcall.trailer_size);
- if (op->downcall.trailer_buf == NULL) {
- gossip_err("%s: failed trailer vmalloc.\n",
- __func__);
+ op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size);
+ if (!op->downcall.trailer_buf)
goto Enomem;
- }
+
memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
if (!copy_from_iter_full(op->downcall.trailer_buf,
op->downcall.trailer_size, iter)) {
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index 038d67545d9f..7ef473f3d642 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
bufmap->buffer_index_array =
kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL);
- if (!bufmap->buffer_index_array) {
- gossip_err("orangefs: could not allocate %d buffer indices\n",
- bufmap->desc_count);
+ if (!bufmap->buffer_index_array)
goto out_free_bufmap;
- }
bufmap->desc_array =
kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
GFP_KERNEL);
- if (!bufmap->desc_array) {
- gossip_err("orangefs: could not allocate %d descriptors\n",
- bufmap->desc_count);
+ if (!bufmap->desc_array)
goto out_free_index_array;
- }
bufmap->page_count = bufmap->total_size / PAGE_SIZE;
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 716ed337f166..93fe8f8e60f1 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -577,5 +577,4 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
if (!cdm_array) {
- pr_info("malloc failed for cdm_array!\n");
rc = -ENOMEM;
goto out;
}
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index c1b5174cb5a9..85ef87245a87 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -100,5 +100,4 @@ static int __init orangefs_init(void)
if (!orangefs_htable_ops_in_progress) {
- gossip_err("Failed to initialize op hashtable");
ret = -ENOMEM;
goto cleanup_inode;
}
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index 5a1bed6c8c6a..47f3fb9cbec4 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
struct orangefs_inode_s *orangefs_inode;
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
- if (orangefs_inode == NULL) {
- gossip_err("Failed to allocate orangefs_inode\n");
+ if (!orangefs_inode)
return NULL;
- }
/*
* We want to clear everything except for rw_semaphore and the
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] orangefs: Use kcalloc() in orangefs_prepare_cdm_array()
2017-08-17 20:11 [PATCH 0/3] OrangeFS: Adjustments for some function implementations SF Markus Elfring
2017-08-17 20:13 ` [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions SF Markus Elfring
@ 2017-08-17 20:14 ` SF Markus Elfring
2017-08-17 20:15 ` [PATCH 3/3] orangefs: Adjust three checks for null pointers SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-17 20:14 UTC (permalink / raw)
To: Martin Brandenburg, Mike Marshall, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 17 Aug 2017 21:18:01 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/orangefs/orangefs-debugfs.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 93fe8f8e60f1..5f59917fd631 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -571,7 +571,5 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
goto out;
}
- cdm_array =
- kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
- GFP_KERNEL);
+ cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
if (!cdm_array) {
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] orangefs: Adjust three checks for null pointers
2017-08-17 20:11 [PATCH 0/3] OrangeFS: Adjustments for some function implementations SF Markus Elfring
2017-08-17 20:13 ` [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions SF Markus Elfring
2017-08-17 20:14 ` [PATCH 2/3] orangefs: Use kcalloc() in orangefs_prepare_cdm_array() SF Markus Elfring
@ 2017-08-17 20:15 ` SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-17 20:15 UTC (permalink / raw)
To: Martin Brandenburg, Mike Marshall, kernel-janitors; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 17 Aug 2017 21:35:16 +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 affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/orangefs/acl.c | 2 +-
fs/orangefs/xattr.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 7a3754488312..4ea7da31e7f0 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
* I don't do that for now.
*/
value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
- if (value == NULL)
+ if (!value)
return ERR_PTR(-ENOMEM);
gossip_debug(GOSSIP_ACL_DEBUG,
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index 237c9c04dc3b..8d40e01ed0f8 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -239,7 +239,7 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
internal_flag = convert_to_internal_xattr_flags(flags);
/* This is equivalent to a removexattr */
- if (size == 0 && value == NULL) {
+ if (size == 0 && !value) {
gossip_debug(GOSSIP_XATTR_DEBUG,
"removing xattr (%s)\n",
name);
@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
int i = 0;
int returned_count = 0;
- if (size > 0 && buffer == NULL) {
+ if (size > 0 && !buffer) {
gossip_err("%s: bogus NULL pointers\n", __func__);
return -EINVAL;
}
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-17 20:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 20:11 [PATCH 0/3] OrangeFS: Adjustments for some function implementations SF Markus Elfring
2017-08-17 20:13 ` [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions SF Markus Elfring
2017-08-17 20:14 ` [PATCH 2/3] orangefs: Use kcalloc() in orangefs_prepare_cdm_array() SF Markus Elfring
2017-08-17 20:15 ` [PATCH 3/3] orangefs: Adjust three checks for null pointers 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