* [PATCH 0/2] PCMCIA-Resource management: Adjustments for three function implementations
@ 2017-05-15 14:00 SF Markus Elfring
2017-05-15 14:02 ` [PATCH 1/2] pcmcia: Improve a size determination in three functions SF Markus Elfring
2017-05-15 14:03 ` [PATCH 2/2] pcmcia: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-15 14:00 UTC (permalink / raw)
To: linux-pcmcia; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 May 2017 15:46:54 +0200
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Improve a size determination in three functions
Delete an error message for a failed memory allocation in two functions
drivers/pcmcia/rsrc_nonstatic.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
--
2.13.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] pcmcia: Improve a size determination in three functions
2017-05-15 14:00 [PATCH 0/2] PCMCIA-Resource management: Adjustments for three function implementations SF Markus Elfring
@ 2017-05-15 14:02 ` SF Markus Elfring
2017-05-15 14:03 ` [PATCH 2/2] pcmcia: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-15 14:02 UTC (permalink / raw)
To: linux-pcmcia; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 May 2017 15:13:00 +0200
Replace the specification of three 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/pcmcia/rsrc_nonstatic.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 5ef7b46a2578..2e03dd8f1157 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -120,5 +120,5 @@ static int add_interval(struct resource_map *map, u_long base, u_long num)
if ((p->next == map) || (p->next->base > base+num-1))
break;
}
- q = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
+ q = kmalloc(sizeof(*q), GFP_KERNEL);
if (!q) {
@@ -158,6 +158,5 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
q->num = base - q->base;
} else {
/* Split the block into two pieces */
- p = kmalloc(sizeof(struct resource_map),
- GFP_KERNEL);
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
if (!p) {
@@ -1018,7 +1017,7 @@ static int nonstatic_init(struct pcmcia_socket *s)
{
struct socket_data *data;
- data = kzalloc(sizeof(struct socket_data), GFP_KERNEL);
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
--
2.13.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] pcmcia: Delete an error message for a failed memory allocation in two functions
2017-05-15 14:00 [PATCH 0/2] PCMCIA-Resource management: Adjustments for three function implementations SF Markus Elfring
2017-05-15 14:02 ` [PATCH 1/2] pcmcia: Improve a size determination in three functions SF Markus Elfring
@ 2017-05-15 14:03 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-15 14:03 UTC (permalink / raw)
To: linux-pcmcia; +Cc: LKML, kernel-janitors, Wolfram Sang
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 May 2017 15:23:42 +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/pcmcia/rsrc_nonstatic.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 2e03dd8f1157..7b5bc6f6f496 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -124,7 +124,6 @@ static int add_interval(struct resource_map *map, u_long base, u_long num)
- if (!q) {
- printk(KERN_WARNING "out of memory to update resources\n");
+ if (!q)
return -ENOMEM;
- }
+
q->base = base; q->num = num;
q->next = p->next; p->next = q;
return 0;
@@ -162,7 +161,6 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
- if (!p) {
- printk(KERN_WARNING "out of memory to update resources\n");
+ if (!p)
return -ENOMEM;
- }
+
p->base = base+num;
p->num = q->base+q->num - p->base;
q->num = base - q->base;
--
2.13.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-15 14:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 14:00 [PATCH 0/2] PCMCIA-Resource management: Adjustments for three function implementations SF Markus Elfring
2017-05-15 14:02 ` [PATCH 1/2] pcmcia: Improve a size determination in three functions SF Markus Elfring
2017-05-15 14:03 ` [PATCH 2/2] pcmcia: Delete an error message for a failed memory allocation 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;
as well as URLs for NNTP newsgroup(s).