PCMCIA-rsrc_nonstatic: Adjustments for two function implementations
Subsystems (2)
cover PCMCIA-rsrc_nonstatic: Adjustments for two function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 21:26:54 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in two functions Improve a size determination in three functions
drivers/pcmcia/rsrc_nonstatic.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/2 pcmcia/rsrc_nonstatic: Delete an error message for a failed memory allocation in two functions
From: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 21:00:13 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/pcmcia/rsrc_nonstatic.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/pcmcia/rsrc_nonstatic.c +4 -6
@@ -121,10 +121,9 @@ static int add_interval(struct resource_map *map, u_long base, u_long num)break ; } q =kmalloc (sizeof (struct resource_map ),GFP_KERNEL ); -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 ;
@@ -160,10 +159,9 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)/* Split the block into two pieces */ p =kmalloc (sizeof (struct resource_map ),GFP_KERNEL ); -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;
Signature · 1 line
2.15.1
PATCH 2/2 pcmcia/rsrc_nonstatic: Improve a size determination in three functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 21:07:39 +0100
Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/pcmcia/rsrc_nonstatic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pcmcia/rsrc_nonstatic.c +3 -5
@@ -120,7 +120,7 @@ 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)return -ENOMEM ;
@@ -157,8 +157,7 @@ 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)return -ENOMEM ;
@@ -1014,9 +1013,8 @@ static inline int nonstatic_autoadd_resources(struct pcmcia_socket *s)static int nonstatic_init (struct pcmcia_socket *s) { -struct socket_data *data; +struct socket_data *data =kzalloc (sizeof (*data),GFP_KERNEL ); - data =kzalloc (sizeof (struct socket_data ),GFP_KERNEL );if (!data)return -ENOMEM ;
Signature · 1 line
2.15.1