Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1646185 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-05-20 21:10 +0200 |
| Last post | 2017-05-20 21:20 +0200 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:10 +0200
[PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant in fsl_hv_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:20 +0200
[PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations in ioctl_memcpy() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:20 +0200
[PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:20 +0200
[PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:20 +0200
[PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation in fsl_hv_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-20 21:20 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:10 +0200 |
| Subject | [PATCH 0/5] fsl_hypervisor: Adjustments for two function implementations |
| Message-ID | <tJhVf-5rT-5@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:20 +0200 |
| Subject | [PATCH 3/5] fsl_hypervisor: Return the success indication only as a constant in fsl_hv_open() |
| Message-ID | <tJi4V-5vp-3@gated-at.bofh.it> |
| In reply to | #1646185 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:20 +0200 |
| Subject | [PATCH 5/5] fsl_hypervisor: Delete error messages for failed memory allocations in ioctl_memcpy() |
| Message-ID | <tJi4V-5vp-7@gated-at.bofh.it> |
| In reply to | #1646185 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:20 +0200 |
| Subject | [PATCH 4/5] fsl_hypervisor: Use kcalloc() in ioctl_memcpy() |
| Message-ID | <tJi4W-5vp-9@gated-at.bofh.it> |
| In reply to | #1646185 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:20 +0200 |
| Subject | [PATCH 1/5] fsl_hypervisor: Improve a size determination in fsl_hv_open() |
| Message-ID | <tJi4W-5vp-13@gated-at.bofh.it> |
| In reply to | #1646185 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-20 21:20 +0200 |
| Subject | [PATCH 2/5] fsl_hypervisor: Delete an error message for a failed memory allocation in fsl_hv_open() |
| Message-ID | <tJi4W-5vp-15@gated-at.bofh.it> |
| In reply to | #1646185 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web