SGI-XPC: Adjustments for some function implementations
Subsystems (2)
cover SGI-XPC: Adjustments for some function implementations
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 14:54:34 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete error messages for a failed memory allocation in three functions Improve a size determination in two functions
Adjust 27 checks for null pointers
drivers/misc/sgi-xp/xpc_main.c | 16 +++++------- drivers/misc/sgi-xp/xpc_uv.c | 59 ++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 44 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 sgi-xpc: Delete error messages for a failed memory allocation in three functions
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 14:00:17 +0100
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/misc/sgi-xp/xpc_main.c | 8 ++------ drivers/misc/sgi-xp/xpc_uv.c | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-)
drivers/misc/sgi-xp/xpc_main.c +2 -6
@@ -418,10 +418,8 @@ xpc_setup_ch_structures(struct xpc_partition *part)DBUG_ON (part->channels !=NULL ); part->channels =kzalloc (sizeof (struct xpc_channel ) *XPC_MAX_NCHANNELS ,GFP_KERNEL ); -if (part->channels =NULL ) { -dev_err (xpc_chan,"can't get memory for channels\n" ); +if (!part->channels)return xpNoMemory; - }/* allocate the remote open and close args */
@@ -907,10 +905,8 @@ xpc_setup_partitions(void) xpc_partitions =kzalloc (sizeof (struct xpc_partition ) * xp_max_npartitions,GFP_KERNEL ); -if (xpc_partitions =NULL ) { -dev_err (xpc_part,"can't get memory for partition structure\n" ); +if (!xpc_partitions)return -ENOMEM ; - }/* * The first few fields of each entry of xpc_partitions[] need to
drivers/misc/sgi-xp/xpc_uv.c +0 -4
@@ -217,8 +217,6 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name, mq =kmalloc (sizeof (struct xpc_gru_mq_uv ),GFP_KERNEL );if (mq =NULL ) { -dev_err (xpc_part,"xpc_create_gru_mq_uv() failed to kmalloc() " -"a xpc_gru_mq_uv structure\n" ); ret = -ENOMEM ; goto out_0; }
@@ -226,8 +224,6 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name, mq->gru_mq_desc =kzalloc (sizeof (struct gru_message_queue_desc ),GFP_KERNEL );if (mq->gru_mq_desc =NULL ) { -dev_err (xpc_part,"xpc_create_gru_mq_uv() failed to kmalloc() " -"a gru_message_queue_desc structure\n" ); ret = -ENOMEM ; goto out_1; }
Signature · 1 line
2.15.1
Re: [PATCH 1/3] sgi-xpc: Delete error messages for a failed memory allocation in three functions
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 14:00:17 +0100Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
PATCH 2/3 sgi-xpc: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 14:18:12 +0100
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.
This issue was detected by using the Coccinelle software.
--- drivers/misc/sgi-xp/xpc_uv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/misc/sgi-xp/xpc_uv.c +2 -5
@@ -212,10 +212,9 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name,int nasid;int pg_order;struct page *page; -struct xpc_gru_mq_uv *mq;struct uv_IO_APIC_route_entry *mmr_value; +struct xpc_gru_mq_uv *mq =kmalloc (sizeof (*mq),GFP_KERNEL ); - mq =kmalloc (sizeof (struct xpc_gru_mq_uv ),GFP_KERNEL );if (mq =NULL ) { ret = -ENOMEM ; goto out_0;
@@ -686,9 +685,7 @@ xpc_send_activate_IRQ_uv(struct xpc_partition *part, void *msg, size_t msg_size,if (!(part_uv->flags &XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV )) { gru_mq_desc = part_uv->cached_activate_gru_mq_desc;if (gru_mq_desc =NULL ) { - gru_mq_desc =kmalloc (sizeof (struct -gru_message_queue_desc ), -GFP_KERNEL ); + gru_mq_desc =kmalloc (sizeof (*gru_mq_desc),GFP_KERNEL );if (gru_mq_desc =NULL ) { ret = xpNoMemory; goto done;
Signature · 1 line
2.15.1
Re: [PATCH 2/3] sgi-xpc: Improve a size determination in two functions
Quoted 1 line · SF Markus Elfring
Signed-off-by Markus Elfring <[email protected]>
PATCH 3/3 sgi-xpc: Adjust 27 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Jan 2018 14:40:57 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Thus fix the affected source code places.
--- drivers/misc/sgi-xp/xpc_main.c | 8 +++---- drivers/misc/sgi-xp/xpc_uv.c | 48 ++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 29 deletions(-)
drivers/misc/sgi-xp/xpc_main.c +4 -4
@@ -383,7 +383,7 @@ xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base) {/* see if kzalloc will give us cachline aligned memory by default */ *base =kzalloc (size, flags); -if (*base =NULL ) +if (!*base)return NULL ;if ((u64)*base =L1_CACHE_ALIGN ((u64)*base))
@@ -393,7 +393,7 @@ xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)/* nope, we'll have to do it ourselves */ *base =kzalloc (size +L1_CACHE_BYTES , flags); -if (*base =NULL ) +if (!*base)return NULL ;return (void *)L1_CACHE_ALIGN ((u64)*base);
@@ -415,7 +415,7 @@ xpc_setup_ch_structures(struct xpc_partition *part)* Allocate all of the channel structures as a contiguous chunk of * memory. */ -DBUG_ON (part->channels !=NULL ); +DBUG_ON (part->channels); part->channels =kzalloc (sizeof (struct xpc_channel ) *XPC_MAX_NCHANNELS ,GFP_KERNEL );if (!part->channels)
@@ -427,7 +427,7 @@ xpc_setup_ch_structures(struct xpc_partition *part)xpc_kzalloc_cacheline_aligned (XPC_OPENCLOSE_ARGS_SIZE ,GFP_KERNEL , &part-> remote_openclose_args_base); -if (part->remote_openclose_args =NULL ) { +if (!part->remote_openclose_args) {dev_err (xpc_chan,"can't get memory for remote connect args\n" ); ret = xpNoMemory; goto out_1;
drivers/misc/sgi-xp/xpc_uv.c +23 -25
174 lines not on this page · raw message
Signature · 1 line
2.15.1
Re: [PATCH 3/3] sgi-xpc: Adjust 27 checks for null pointers
Quoted 1 line · SF Markus Elfring
Signed-off-by Markus Elfring <[email protected]>
If you need to resubmit, please consider re-ordering the changes to due the comparison to NULL changes in your first patch, followed by the other two in either order. I think it will clear up some of the inconsistency in your first patch.
Thanks,
Robin
Greg Kroah-Hartman
maintainerQuoted 4 lines · Robin Holt
If you need to resubmit, please consider re-ordering the changes to due the comparison to NULL changes in your first patch, followed by the other two in either order. I think it will clear up some of the inconsistency in your first patch.
Note you are responding to someone who is on my, and many other kernel maintainers, blacklists, so I never see the patches. So it's not really worth reviewing, as I'll not be picking them up myself, sorry.
greg k-h