* [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations
@ 2017-05-20 19:08 SF Markus Elfring
2017-05-20 19:10 ` [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:08 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 20:36:54 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Improve a size determination in fsl_hv_open()
Delete an error message for a failed memory allocation in fsl_hv_open()
Return the success indication only as a constant in fsl_hv_open()
Use kcalloc() in ioctl_memcpy()
Delete error messages for failed memory allocations in ioctl_memcpy()
drivers/virt/fsl_hypervisor.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
--
2.13.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open()
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
@ 2017-05-20 19:10 ` SF Markus Elfring
2017-05-20 19:12 ` [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation " SF Markus Elfring
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:10 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 19:52:38 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/virt/fsl_hypervisor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index d3eca879a0a8..d1df6c6740f1 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -659,5 +659,5 @@ static int fsl_hv_open(struct inode *inode, struct file *filp)
unsigned long flags;
int ret = 0;
- dbq = kzalloc(sizeof(struct doorbell_queue), GFP_KERNEL);
+ dbq = kzalloc(sizeof(*dbq), GFP_KERNEL);
if (!dbq) {
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation in fsl_hv_open()
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
2017-05-20 19:10 ` [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring
@ 2017-05-20 19:12 ` SF Markus Elfring
2017-05-20 19:13 ` [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant " SF Markus Elfring
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:12 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors, Wolfram Sang
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 19:57:52 +0200
Omit an extra message for a memory allocation failure in this function.
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/virt/fsl_hypervisor.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index d1df6c6740f1..40c5eb64f39b 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -663,7 +663,5 @@ static int fsl_hv_open(struct inode *inode, struct file *filp)
- if (!dbq) {
- pr_err("fsl-hv: out of memory\n");
+ if (!dbq)
return -ENOMEM;
- }
spin_lock_init(&dbq->lock);
init_waitqueue_head(&dbq->wait);
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant in fsl_hv_open()
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
2017-05-20 19:10 ` [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring
2017-05-20 19:12 ` [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation " SF Markus Elfring
@ 2017-05-20 19:13 ` SF Markus Elfring
2017-05-20 19:14 ` [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy() SF Markus Elfring
2017-05-20 19:16 ` [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations " SF Markus Elfring
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:13 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 20:05:19 +0200
* Return a success code without storing it in an intermediate variable.
* Delete the local variable "ret" which became unnecessary with
this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/virt/fsl_hypervisor.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 40c5eb64f39b..9e881dc29c6b 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -657,7 +657,6 @@ static int fsl_hv_open(struct inode *inode, struct file *filp)
{
struct doorbell_queue *dbq;
unsigned long flags;
- int ret = 0;
dbq = kzalloc(sizeof(*dbq), GFP_KERNEL);
if (!dbq)
@@ -671,8 +670,7 @@ static int fsl_hv_open(struct inode *inode, struct file *filp)
spin_unlock_irqrestore(&db_list_lock, flags);
filp->private_data = dbq;
-
- return ret;
+ return 0;
}
/*
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy()
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-05-20 19:13 ` [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant " SF Markus Elfring
@ 2017-05-20 19:14 ` SF Markus Elfring
2017-05-20 19:16 ` [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations " SF Markus Elfring
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:14 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 20:15:57 +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 type 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>
---
drivers/virt/fsl_hypervisor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 9e881dc29c6b..4031632b8c9d 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -223,5 +223,5 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
* 'pages' is an array of struct page pointers that's initialized by
* get_user_pages().
*/
- pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL);
+ pages = kcalloc(num_pages, sizeof(*pages), GFP_KERNEL);
if (!pages) {
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations in ioctl_memcpy()
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
` (3 preceding siblings ...)
2017-05-20 19:14 ` [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy() SF Markus Elfring
@ 2017-05-20 19:16 ` SF Markus Elfring
4 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-20 19:16 UTC (permalink / raw)
To: Arnd Bergmann, Jan Kara, Jesper Nilsson, Kumar Gala,
Lorenzo Stoakes, Michal Hocko, Timur Tabi
Cc: LKML, kernel-janitors, Wolfram Sang
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 May 2017 20:27:23 +0200
Omit two extra messages for memory allocation failures in this function.
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/virt/fsl_hypervisor.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 4031632b8c9d..db07c76f1ff7 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -227,7 +227,5 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
- if (!pages) {
- pr_debug("fsl-hv: could not allocate page list\n");
+ if (!pages)
return -ENOMEM;
- }
/*
* sg_list is the list of fh_sg_list objects that we pass to the
@@ -238,5 +236,4 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
if (!sg_list_unaligned) {
- pr_debug("fsl-hv: could not allocate S/G list\n");
ret = -ENOMEM;
goto exit;
}
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-20 19:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20 19:08 [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring
2017-05-20 19:10 ` [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring
2017-05-20 19:12 ` [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-20 19:13 ` [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant " SF Markus Elfring
2017-05-20 19:14 ` [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy() SF Markus Elfring
2017-05-20 19:16 ` [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations " 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;
as well as URLs for NNTP newsgroup(s).