* [PATCH 0/5] mtip32xx: Adjustments for some function implementations
@ 2017-08-06 19:15 SF Markus Elfring
2017-08-06 19:17 ` [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions SF Markus Elfring
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:15 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 21:02:34 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an error message for a failed memory allocation in five functions
Improve a size determination in two functions
Delete an unnecessary variable initialisation in mtip_pci_probe()
Fix a typo in a comment line in mtip_hw_get_identify()
Adjust an input validation check in mtip_hw_debugfs_exit()
drivers/block/mtip32xx/mtip32xx.c | 37 ++++++++++---------------------------
1 file changed, 10 insertions(+), 27 deletions(-)
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
@ 2017-08-06 19:17 ` SF Markus Elfring
2017-08-07 5:48 ` kbuild test robot
2017-08-06 19:20 ` [PATCH 2/5] mtip32xx: Improve a size determination in two functions SF Markus Elfring
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:17 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 19:09:04 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/mtip32xx/mtip32xx.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 4a3cfc7940de..5ccbab619e57 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2379,11 +2379,8 @@ static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
return 0;
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
- if (!buf) {
- dev_err(&dd->pdev->dev,
- "Memory allocation: status buffer\n");
+ if (!buf)
return -ENOMEM;
- }
size += show_device_status(NULL, buf);
@@ -2409,11 +2406,8 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
return 0;
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
- if (!buf) {
- dev_err(&dd->pdev->dev,
- "Memory allocation: register buffer\n");
+ if (!buf)
return -ENOMEM;
- }
size += sprintf(&buf[size], "H/ S ACTive : [ 0x");
@@ -2475,11 +2469,8 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
return 0;
buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
- if (!buf) {
- dev_err(&dd->pdev->dev,
- "Memory allocation: flag buffer\n");
+ if (!buf)
return -ENOMEM;
- }
size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
dd->port->flags);
@@ -3031,11 +3022,8 @@ static int mtip_hw_init(struct driver_data *dd)
dd->port = kzalloc_node(sizeof(struct mtip_port), GFP_KERNEL,
dd->numa_node);
- if (!dd->port) {
- dev_err(&dd->pdev->dev,
- "Memory allocation: port structure\n");
+ if (!dd->port)
return -ENOMEM;
- }
/* Continue workqueue setup */
for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++)
@@ -4228,11 +4216,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
cpu_to_node(raw_smp_processor_id()), raw_smp_processor_id());
dd = kzalloc_node(sizeof(struct driver_data), GFP_KERNEL, my_node);
- if (dd == NULL) {
- dev_err(&pdev->dev,
- "Unable to allocate memory for driver data\n");
+ if (!dd)
return -ENOMEM;
- }
/* Attach the private data to this PCI device. */
pci_set_drvdata(pdev, dd);
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] mtip32xx: Improve a size determination in two functions
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
2017-08-06 19:17 ` [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions SF Markus Elfring
@ 2017-08-06 19:20 ` SF Markus Elfring
2017-08-06 19:22 ` [PATCH 3/5] mtip32xx: Delete an unnecessary variable initialisation in mtip_pci_probe() SF Markus Elfring
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:20 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 19:54:49 +0200
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" 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>
---
drivers/block/mtip32xx/mtip32xx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 5ccbab619e57..97cbf39b4273 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3019,9 +3019,7 @@ static int mtip_hw_init(struct driver_data *dd)
num_command_slots = dd->slot_groups * 32;
hba_setup(dd);
-
- dd->port = kzalloc_node(sizeof(struct mtip_port), GFP_KERNEL,
- dd->numa_node);
+ dd->port = kzalloc_node(sizeof(*dd->port), GFP_KERNEL, dd->numa_node);
if (!dd->port)
return -ENOMEM;
@@ -4215,7 +4213,7 @@ static int mtip_pci_probe(struct pci_dev *pdev,
my_node, pcibus_to_node(pdev->bus), dev_to_node(&pdev->dev),
cpu_to_node(raw_smp_processor_id()), raw_smp_processor_id());
- dd = kzalloc_node(sizeof(struct driver_data), GFP_KERNEL, my_node);
+ dd = kzalloc_node(sizeof(*dd), GFP_KERNEL, my_node);
if (!dd)
return -ENOMEM;
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] mtip32xx: Delete an unnecessary variable initialisation in mtip_pci_probe()
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
2017-08-06 19:17 ` [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions SF Markus Elfring
2017-08-06 19:20 ` [PATCH 2/5] mtip32xx: Improve a size determination in two functions SF Markus Elfring
@ 2017-08-06 19:22 ` SF Markus Elfring
2017-08-06 19:23 ` [PATCH 4/5] mtip32xx: Fix a typo in a comment line in mtip_hw_get_identify() SF Markus Elfring
2017-08-06 19:24 ` [PATCH 5/5] mtip32xx: Adjust an input validation check in mtip_hw_debugfs_exit() SF Markus Elfring
4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:22 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 20:06:42 +0200
The local variable "dd" will be set to an appropriate pointer a bit later.
Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/mtip32xx/mtip32xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 97cbf39b4273..cba5bc2a1493 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4193,7 +4193,7 @@ static int mtip_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
int rv = 0;
- struct driver_data *dd = NULL;
+ struct driver_data *dd;
char cpu_list[256];
const struct cpumask *node_mask;
int cpu, i = 0, j = 0;
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] mtip32xx: Fix a typo in a comment line in mtip_hw_get_identify()
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-08-06 19:22 ` [PATCH 3/5] mtip32xx: Delete an unnecessary variable initialisation in mtip_pci_probe() SF Markus Elfring
@ 2017-08-06 19:23 ` SF Markus Elfring
2017-08-06 19:24 ` [PATCH 5/5] mtip32xx: Adjust an input validation check in mtip_hw_debugfs_exit() SF Markus Elfring
4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:23 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 20:28:48 +0200
Add a missing character in this description.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/mtip32xx/mtip32xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index cba5bc2a1493..18e634efed95 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2981,7 +2981,7 @@ static int mtip_hw_get_identify(struct driver_data *dd)
}
}
- /* get write protect progess */
+ /* get write protect progress */
memset(&attr242, 0, sizeof(struct smart_attr));
if (mtip_get_smart_attr(dd->port, 242, &attr242))
dev_warn(&dd->pdev->dev,
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] mtip32xx: Adjust an input validation check in mtip_hw_debugfs_exit()
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
` (3 preceding siblings ...)
2017-08-06 19:23 ` [PATCH 4/5] mtip32xx: Fix a typo in a comment line in mtip_hw_get_identify() SF Markus Elfring
@ 2017-08-06 19:24 ` SF Markus Elfring
4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-08-06 19:24 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe, Johannes Thumshirn, Ming Lei, Sagi Grimberg
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 6 Aug 2017 20:52:26 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: debugfs_remove_recursive(NULL) is safe and this check is probably not required
Thus adjust this source code place.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/mtip32xx/mtip32xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 18e634efed95..db37ff872d56 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2572,7 +2572,7 @@ static int mtip_hw_debugfs_init(struct driver_data *dd)
static void mtip_hw_debugfs_exit(struct driver_data *dd)
{
- if (dd->dfs_node)
+ if (dd)
debugfs_remove_recursive(dd->dfs_node);
}
--
2.13.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions
2017-08-06 19:17 ` [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions SF Markus Elfring
@ 2017-08-07 5:48 ` kbuild test robot
0 siblings, 0 replies; 7+ messages in thread
From: kbuild test robot @ 2017-08-07 5:48 UTC (permalink / raw)
To: SF Markus Elfring
Cc: kbuild-all, Bart Van Assche, Jens Axboe, Johannes Thumshirn,
Ming Lei, Sagi Grimberg, LKML, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 8302 bytes --]
Hi Markus,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.13-rc4 next-20170804]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/mtip32xx-Adjustments-for-some-function-implementations/20170807-033055
config: x86_64-randconfig-b0-08071209 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from include/uapi/linux/uuid.h:21,
from include/linux/uuid.h:19,
from include/linux/mod_devicetable.h:12,
from include/linux/pci.h:20,
from drivers/block/mtip32xx/mtip32xx.c:21:
include/linux/string.h: In function 'strncpy':
include/linux/string.h:209: warning: '______f' is static but declared in inline function 'strncpy' which is not static
include/linux/string.h:211: warning: '______f' is static but declared in inline function 'strncpy' which is not static
include/linux/string.h: In function 'strcat':
include/linux/string.h:219: warning: '______f' is static but declared in inline function 'strcat' which is not static
include/linux/string.h:221: warning: '______f' is static but declared in inline function 'strcat' which is not static
include/linux/string.h: In function 'strlen':
include/linux/string.h:230: warning: '______f' is static but declared in inline function 'strlen' which is not static
include/linux/string.h:233: warning: '______f' is static but declared in inline function 'strlen' which is not static
include/linux/string.h: In function 'strnlen':
include/linux/string.h:243: warning: '______f' is static but declared in inline function 'strnlen' which is not static
include/linux/string.h: In function 'strlcpy':
include/linux/string.h:255: warning: '______f' is static but declared in inline function 'strlcpy' which is not static
include/linux/string.h:258: warning: '______f' is static but declared in inline function 'strlcpy' which is not static
include/linux/string.h:260: warning: '______f' is static but declared in inline function 'strlcpy' which is not static
include/linux/string.h:262: warning: '______f' is static but declared in inline function 'strlcpy' which is not static
include/linux/string.h: In function 'strncat':
include/linux/string.h:276: warning: '______f' is static but declared in inline function 'strncat' which is not static
include/linux/string.h:280: warning: '______f' is static but declared in inline function 'strncat' which is not static
include/linux/string.h: In function 'memset':
include/linux/string.h:290: warning: '______f' is static but declared in inline function 'memset' which is not static
include/linux/string.h:292: warning: '______f' is static but declared in inline function 'memset' which is not static
include/linux/string.h: In function 'memcpy':
include/linux/string.h:301: warning: '______f' is static but declared in inline function 'memcpy' which is not static
include/linux/string.h:302: warning: '______f' is static but declared in inline function 'memcpy' which is not static
include/linux/string.h:304: warning: '______f' is static but declared in inline function 'memcpy' which is not static
include/linux/string.h:307: warning: '______f' is static but declared in inline function 'memcpy' which is not static
include/linux/string.h: In function 'memmove':
include/linux/string.h:316: warning: '______f' is static but declared in inline function 'memmove' which is not static
include/linux/string.h:317: warning: '______f' is static but declared in inline function 'memmove' which is not static
include/linux/string.h:319: warning: '______f' is static but declared in inline function 'memmove' which is not static
include/linux/string.h:322: warning: '______f' is static but declared in inline function 'memmove' which is not static
include/linux/string.h: In function 'memscan':
include/linux/string.h:331: warning: '______f' is static but declared in inline function 'memscan' which is not static
include/linux/string.h:333: warning: '______f' is static but declared in inline function 'memscan' which is not static
include/linux/string.h: In function 'memcmp':
include/linux/string.h:342: warning: '______f' is static but declared in inline function 'memcmp' which is not static
include/linux/string.h:343: warning: '______f' is static but declared in inline function 'memcmp' which is not static
include/linux/string.h:345: warning: '______f' is static but declared in inline function 'memcmp' which is not static
include/linux/string.h:348: warning: '______f' is static but declared in inline function 'memcmp' which is not static
include/linux/string.h: In function 'memchr':
include/linux/string.h:356: warning: '______f' is static but declared in inline function 'memchr' which is not static
include/linux/string.h:358: warning: '______f' is static but declared in inline function 'memchr' which is not static
include/linux/string.h: In function 'memchr_inv':
include/linux/string.h:367: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
include/linux/string.h:369: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
include/linux/string.h: In function 'kmemdup':
include/linux/string.h:378: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
include/linux/string.h:380: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
include/linux/string.h: In function 'strcpy':
include/linux/string.h:390: warning: '______f' is static but declared in inline function 'strcpy' which is not static
drivers/block/mtip32xx/mtip32xx.c: In function 'mtip_hw_read_device_status':
>> drivers/block/mtip32xx/mtip32xx.c:2373: warning: unused variable 'dd'
vim +/dd +2373 drivers/block/mtip32xx/mtip32xx.c
0caff003 Asai Thambi S P 2013-04-03 2369
0caff003 Asai Thambi S P 2013-04-03 2370 static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
0caff003 Asai Thambi S P 2013-04-03 2371 size_t len, loff_t *offset)
0caff003 Asai Thambi S P 2013-04-03 2372 {
c8afd0dc David Milburn 2013-05-23 @2373 struct driver_data *dd = (struct driver_data *)f->private_data;
0caff003 Asai Thambi S P 2013-04-03 2374 int size = *offset;
c8afd0dc David Milburn 2013-05-23 2375 char *buf;
c8afd0dc David Milburn 2013-05-23 2376 int rv = 0;
0caff003 Asai Thambi S P 2013-04-03 2377
0caff003 Asai Thambi S P 2013-04-03 2378 if (!len || *offset)
0caff003 Asai Thambi S P 2013-04-03 2379 return 0;
0caff003 Asai Thambi S P 2013-04-03 2380
c8afd0dc David Milburn 2013-05-23 2381 buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
b4f96ba8 Markus Elfring 2017-08-06 2382 if (!buf)
c8afd0dc David Milburn 2013-05-23 2383 return -ENOMEM;
c8afd0dc David Milburn 2013-05-23 2384
0caff003 Asai Thambi S P 2013-04-03 2385 size += show_device_status(NULL, buf);
0caff003 Asai Thambi S P 2013-04-03 2386
0caff003 Asai Thambi S P 2013-04-03 2387 *offset = size <= len ? size : len;
0caff003 Asai Thambi S P 2013-04-03 2388 size = copy_to_user(ubuf, buf, *offset);
0caff003 Asai Thambi S P 2013-04-03 2389 if (size)
c8afd0dc David Milburn 2013-05-23 2390 rv = -EFAULT;
0caff003 Asai Thambi S P 2013-04-03 2391
c8afd0dc David Milburn 2013-05-23 2392 kfree(buf);
c8afd0dc David Milburn 2013-05-23 2393 return rv ? rv : *offset;
0caff003 Asai Thambi S P 2013-04-03 2394 }
0caff003 Asai Thambi S P 2013-04-03 2395
:::::: The code at line 2373 was first introduced by commit
:::::: c8afd0dcbd14e2352258f2e2d359b36d0edd459f mtip32xx: dynamically allocate buffer in debugfs functions
:::::: TO: David Milburn <dmilburn@redhat.com>
:::::: CC: Jens Axboe <axboe@kernel.dk>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29410 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-08-07 5:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-06 19:15 [PATCH 0/5] mtip32xx: Adjustments for some function implementations SF Markus Elfring
2017-08-06 19:17 ` [PATCH 1/5] mtip32xx: Delete an error message for a failed memory allocation in five functions SF Markus Elfring
2017-08-07 5:48 ` kbuild test robot
2017-08-06 19:20 ` [PATCH 2/5] mtip32xx: Improve a size determination in two functions SF Markus Elfring
2017-08-06 19:22 ` [PATCH 3/5] mtip32xx: Delete an unnecessary variable initialisation in mtip_pci_probe() SF Markus Elfring
2017-08-06 19:23 ` [PATCH 4/5] mtip32xx: Fix a typo in a comment line in mtip_hw_get_identify() SF Markus Elfring
2017-08-06 19:24 ` [PATCH 5/5] mtip32xx: Adjust an input validation check in mtip_hw_debugfs_exit() 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
all inboxes | Powered by JetHome®