From: SF Markus Elfring <hidden> Date: 2017-10-17 15:36:17
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:27:37 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in pnv_ioda_pick_m64_pe()
Use common code in pnv_ioda_pick_m64_pe()
Improve a size determination in pnv_pci_init_ioda_phb()
arch/powerpc/platforms/powernv/pci-ioda.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
--
2.14.2
From: SF Markus Elfring <hidden> Date: 2017-10-17 15:38:22
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 16:52:43 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -358,11 +358,8 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)/* Allocate bitmap */size=_ALIGN_UP(phb->ioda.total_pe_num/8,sizeof(unsignedlong));pe_alloc=kzalloc(size,GFP_KERNEL);-if(!pe_alloc){-pr_warn("%s: Out of memory !\n",-__func__);+if(!pe_alloc)returnNULL;-}/* Figure out reserved PE numbers by the PE */pnv_ioda_reserve_m64_pe(bus,pe_alloc,all);
From: SF Markus Elfring <hidden> Date: 2017-10-17 15:39:34
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:07:54 +0200
Add a jump target so that a bit of code can be better reused
at the end of this function.
Signed-off-by: Markus Elfring <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
@@ -364,21 +364,20 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)/* Figure out reserved PE numbers by the PE */pnv_ioda_reserve_m64_pe(bus,pe_alloc,all);+master_pe=NULL;+/**thecurrentbusmightnotownM64windowandthat'sall*contributedbyitschildbuses.Forthecase,weneedn't*pickM64dependentPE#.*/-if(bitmap_empty(pe_alloc,phb->ioda.total_pe_num)){-kfree(pe_alloc);-returnNULL;-}+if(bitmap_empty(pe_alloc,phb->ioda.total_pe_num))+gotofree_pe;/**FigureoutthemasterPEandputallslavePEstomaster*PE'slisttoformcompoundPE.*/-master_pe=NULL;i=-1;while((i=find_next_bit(pe_alloc,phb->ioda.total_pe_num,i+1))<phb->ioda.total_pe_num){
From: SF Markus Elfring <hidden> Date: 2017-10-17 15:40:35
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:18:10 +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.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 16:52:43 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -358,11 +358,8 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)/* Allocate bitmap */size=_ALIGN_UP(phb->ioda.total_pe_num/8,sizeof(unsignedlong));pe_alloc=kzalloc(size,GFP_KERNEL);-if(!pe_alloc){-pr_warn("%s: Out of memory !\n",-__func__);+if(!pe_alloc)returnNULL;-}/* Figure out reserved PE numbers by the PE */pnv_ioda_reserve_m64_pe(bus,pe_alloc,all);
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:18:10 +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.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <redacted>
---
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:07:54 +0200
Add a jump target so that a bit of code can be better reused
at the end of this function.
Rather than moving bits around, I'd rather allocate pe_alloc on stack and
ditch kfree() at all. I'll make a patch for this.
@@ -364,21 +364,20 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)/* Figure out reserved PE numbers by the PE */pnv_ioda_reserve_m64_pe(bus,pe_alloc,all);+master_pe=NULL;+/**thecurrentbusmightnotownM64windowandthat'sall*contributedbyitschildbuses.Forthecase,weneedn't*pickM64dependentPE#.*/-if(bitmap_empty(pe_alloc,phb->ioda.total_pe_num)){-kfree(pe_alloc);-returnNULL;-}+if(bitmap_empty(pe_alloc,phb->ioda.total_pe_num))+gotofree_pe;/**FigureoutthemasterPEandputallslavePEstomaster*PE'slisttoformcompoundPE.*/-master_pe=NULL;i=-1;while((i=find_next_bit(pe_alloc,phb->ioda.total_pe_num,i+1))<phb->ioda.total_pe_num){
From: Michael Ellerman <hidden> Date: 2018-03-20 10:15:33
On Tue, 2017-10-17 at 15:40:17 UTC, SF Markus Elfring wrote:
From: Markus Elfring <redacted>
Date: Tue, 17 Oct 2017 17:18:10 +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.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <redacted>
Reviewed-by: Alexey Kardashevskiy <redacted>