EDAC/ie31200: work around false positive build warning
Subsystems (2)
PATCH 1/1 EDAC/ie31200: work around false positive build warning
From: Arnd Bergmann <[email protected]>
gcc-14 produces a bogus warning in some configurations:
drivers/edac/ie31200_edac.c: In function 'ie31200_probe1.isra':drivers/edac/ie31200_edac.c:412:26: error: 'dimm_info' is used uninitialized [-Werror=uninitialized]
412 | struct dimm_data dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL];
| ^~~~~~~~~
drivers/edac/ie31200_edac.c:412:26: note: 'dimm_info' declared here
412 | struct dimm_data dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL];
| ^~~~~~~~~I don't see any way the unintialized access could really happen here, but I can see why the compiler gets confused by the two loops.
Instead, rework the two nested loops to only read the addr_decode registers and then keep only one instance of the dimm info structure.
--- drivers/edac/ie31200_edac.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/edac/ie31200_edac.c +13 -14
@@ -409,10 +409,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)int i, j, ret;struct mem_ctl_info *mci =NULL ;struct edac_mc_layer layers[2 ]; -struct dimm_data dimm_info[IE31200_CHANNELS ][IE31200_DIMMS_PER_CHANNEL ];void __iomem *window;struct ie31200_priv *priv; -u32 addr_decode, mad_offset; +u32 addr_decode[IE31200_CHANNELS ], mad_offset;/* * Kaby Lake, Coffee Lake seem to work like Skylake. Please re-visit
@@ -472,17 +471,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)/* populate DIMM info */ for (i =0 ; i <IE31200_CHANNELS ; i++) { - addr_decode =readl (window + mad_offset + + addr_decode[i] =readl (window + mad_offset + (i *4 )); -edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode); -for (j =0 ; j <IE31200_DIMMS_PER_CHANNEL ; j++) { -populate_dimm_info (&dimm_info[i][j], addr_decode, j, - skl); -edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , - dimm_info[i][j].size, - dimm_info[i][j].dual_rank, - dimm_info[i][j].x16_width); - } +edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode[i]); }/*
@@ -493,14 +484,22 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)*/ for (i =0 ; i <IE31200_DIMMS_PER_CHANNEL ; i++) {for (j =0 ; j <IE31200_CHANNELS ; j++) { +struct dimm_data dimm_info;struct dimm_info *dimm;unsigned long nr_pages; - nr_pages =IE31200_PAGES (dimm_info[j][i].size, skl); +populate_dimm_info (&dimm_info, addr_decode[j], i, + skl); +edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , + dimm_info.size, + dimm_info.dual_rank, + dimm_info.x16_width); + + nr_pages =IE31200_PAGES (dimm_info.size, skl);if (nr_pages ==0 )continue ; -if (dimm_info[j][i].dual_rank) { +if (dimm_info.dual_rank) { nr_pages = nr_pages /2 ; dimm =edac_get_dimm (mci, (i *2 ) +1 , j,0 ); dimm->nr_pages = nr_pages;
Signature · 1 line
2.39.5
Quoted 12 lines
From: Arnd Bergmann <[email protected]>
[...]
Subject: [PATCH] EDAC/ie31200: work around false positive build warningFrom: Arnd Bergmann <[email protected]>
gcc-14 produces a bogus warning in some configurations:
drivers/edac/ie31200_edac.c: In function 'ie31200_probe1.isra':drivers/edac/ie31200_edac.c:412:26: error: 'dimm_info' is used uninitialized [-Werror=uninitialized]
412 | structdimm_data
Quoted 8 lines
dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL]; | ^~~~~~~~~ drivers/edac/ie31200_edac.c:412:26: note: 'dimm_info' declared here 412 | struct dimm_data dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL]; | ^~~~~~~~~I don't see any way the unintialized access could really happen here, but I can
It looks like gcc-14 isn't smart enough to recognize that this is a false positive build warning :-). Actually, the dim_info[][] array is always initialized by populate_dimm_info().
Quoted 29 lines
see why the compiler gets confused by the two loops.
Instead, rework the two nested loops to only read the
addr_decoderegisters and then keep only one instance of the dimm info structure.Signed-off-by Arnd Bergmann <[email protected]>--- drivers/edac/ie31200_edac.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)drivers/edac/ie31200_edac.c index renamed from drivers/edac/ie31200_edac.c +0
-0
4fc16922dc1a..b0ccc54dc66a100644drivers/edac/ie31200_edac.c +1
-2@@ -409,10 +409,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)int i, j, ret;struct mem_ctl_info *mci =NULL ;struct edac_mc_layer layers[2 ]; -struct dimm_data dimm_info[IE31200_CHANNELS ][IE31200_DIMMS_PER_CHANNEL ];void __iomem *window;struct ie31200_priv *priv; -u32 addr_decode, mad_offset; +u32 addr_decode[IE31200_CHANNELS ], mad_offset;drivers/edac/ie31200_edac.c +0
-0/* * Kaby Lake, Coffee Lake seem to work like Skylake. Please re-visit
drivers/edac/ie31200_edac.c static int ie31200_probe1(struct pci_dev *pdev, int · line 473
Quoted 3 lines
drivers/edac/ie31200_edac.c +0
-0@@ -472,17 +471,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)/* populate DIMM info */
This comment also needs to be moved to just above the new location of populate_dimm_info().
Quoted 19 lines
drivers/edac/ie31200_edac.c +2
-10for (i =0 ; i <IE31200_CHANNELS ; i++) { - addr_decode =readl (window + mad_offset + + addr_decode[i] =readl (window + mad_offset + (i *4 )); -edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode); -for (j =0 ; j <IE31200_DIMMS_PER_CHANNEL ; j++) { -populate_dimm_info (&dimm_info[i][j], addr_decode, j, - skl); -edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , - dimm_info[i][j].size, - dimm_info[i][j].dual_rank, - dimm_info[i][j].x16_width); - } +edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode[i]); }drivers/edac/ie31200_edac.c +0
-0/*
drivers/edac/ie31200_edac.c static int ie31200_probe1(struct pci_dev *pdev, int · line 500
Quoted 9 lines
drivers/edac/ie31200_edac.c +1
-1@@ -493,14 +484,22 @@ static int ie31200_probe1(struct pci_dev *pdev, intdev_idx) */ for (i =0 ; i <IE31200_DIMMS_PER_CHANNEL ; i++) {for (j =0 ; j <IE31200_CHANNELS ; j++) { +struct dimm_data dimm_info;struct dimm_info *dimm;unsigned long nr_pages; - nr_pages =IE31200_PAGES (dimm_info[j][i].size, skl);
Move the comment here.
Quoted 19 lines
drivers/edac/ie31200_edac.c +9
-1+populate_dimm_info (&dimm_info, addr_decode[j], i, + skl); +edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , + dimm_info.size, + dimm_info.dual_rank, + dimm_info.x16_width); + + nr_pages =IE31200_PAGES (dimm_info.size, skl);if (nr_pages ==0 )continue ; -if (dimm_info[j][i].dual_rank) { +if (dimm_info.dual_rank) { nr_pages = nr_pages /2 ; dimm =edac_get_dimm (mci, (i *2 ) +1 , j,0 );
dimm->nr_pages=nr_pages;
--
2.39.5
Quoted 24 lines · Qiuxu
!-------------------------------------------------------------------|
This Message Is From an External Sender
This message came from outside your organization.
|-------------------------------------------------------------------!Quoted 19 lines
From: Arnd Bergmann <[email protected]>
[...]
Subject: [PATCH] EDAC/ie31200: work around false positive build warningFrom: Arnd Bergmann <[email protected]>
gcc-14 produces a bogus warning in some configurations:
drivers/edac/ie31200_edac.c: In function 'ie31200_probe1.isra':drivers/edac/ie31200_edac.c:412:26: error: 'dimm_info' is used uninitialized [-Werror=uninitialized]
412 | structdimm_datadimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL]; | ^~~~~~~~~ drivers/edac/ie31200_edac.c:412:26: note: 'dimm_info' declared here 412 | struct dimm_data dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL]; | ^~~~~~~~~
Quoted 11 lines
Quoted 1 line
I don't see any way the unintialized access could really happen here, but I can
It looks like gcc-14 isn't smart enough to recognize that this is a false positive build warning :-). Actually, the dim_info[][] array is always initialized by
populate_dimm_info().Quoted 6 lines
see why the compiler gets confused by the two loops.
Instead, rework the two nested loops to only read the
addr_decoderegisters and then keep only one instance of the dimm info structure.Signed-off-by Arnd Bergmann <[email protected]>
Seems fine with the comment adjustment.
Thanks.
Quoted 80 lines
Quoted 23 lines
--- drivers/edac/ie31200_edac.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)drivers/edac/ie31200_edac.c index renamed from drivers/edac/ie31200_edac.c +0
-0
4fc16922dc1a..b0ccc54dc66a100644drivers/edac/ie31200_edac.c +1
-2@@ -409,10 +409,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)int i, j, ret;struct mem_ctl_info *mci =NULL ;struct edac_mc_layer layers[2 ]; -struct dimm_data dimm_info[IE31200_CHANNELS ][IE31200_DIMMS_PER_CHANNEL ];void __iomem *window;struct ie31200_priv *priv; -u32 addr_decode, mad_offset; +u32 addr_decode[IE31200_CHANNELS ], mad_offset;/*
* Kaby Lake, Coffee Lake seem to work like Skylake. Please re-visitdrivers/edac/ie31200_edac.c static int ie31200_probe1(struct pci_dev *pdev, int · line 473
Quoted 3 lines
drivers/edac/ie31200_edac.c +0
-0@@ -472,17 +471,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)/* populate DIMM info */ This comment also needs to be moved to just above the new location of
populate_dimm_info().Quoted 19 lines
drivers/edac/ie31200_edac.c +2
-10for (i =0 ; i <IE31200_CHANNELS ; i++) { - addr_decode =readl (window + mad_offset + + addr_decode[i] =readl (window + mad_offset + (i *4 )); -edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode); -for (j =0 ; j <IE31200_DIMMS_PER_CHANNEL ; j++) { -populate_dimm_info (&dimm_info[i][j], addr_decode, j, - skl); -edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , - dimm_info[i][j].size, - dimm_info[i][j].dual_rank, - dimm_info[i][j].x16_width); - } +edac_dbg (0 ,"addr_decode: 0x%x\n" , addr_decode[i]); }/*
drivers/edac/ie31200_edac.c static int ie31200_probe1(struct pci_dev *pdev, int · line 500
Quoted 9 lines
drivers/edac/ie31200_edac.c +1
-1@@ -493,14 +484,22 @@ static int ie31200_probe1(struct pci_dev *pdev, intdev_idx) */ for (i =0 ; i <IE31200_DIMMS_PER_CHANNEL ; i++) {for (j =0 ; j <IE31200_CHANNELS ; j++) { +struct dimm_data dimm_info;struct dimm_info *dimm;unsigned long nr_pages; - nr_pages =IE31200_PAGES (dimm_info[j][i].size, skl);Move the comment here.
Quoted 19 lines
drivers/edac/ie31200_edac.c +9
-1+populate_dimm_info (&dimm_info, addr_decode[j], i, + skl); +edac_dbg (0 ,"size: 0x%x, rank: %d, width: %d\n" , + dimm_info.size, + dimm_info.dual_rank, + dimm_info.x16_width); + + nr_pages =IE31200_PAGES (dimm_info.size, skl);if (nr_pages ==0 )continue ; -if (dimm_info[j][i].dual_rank) { +if (dimm_info.dual_rank) { nr_pages = nr_pages /2 ; dimm =edac_get_dimm (mci, (i *2 ) +1 , j,0 );
dimm->nr_pages=nr_pages;
--
2.39.5
Luck, Tony
maintainerQuoted 8 lines
Quoted 8 lines
It looks like gcc-14 isn't smart enough to recognize that this is a false positive build warning :-). Actually, the dim_info[][] array is always initialized by
populate_dimm_info().Quoted 5 lines
see why the compiler gets confused by the two loops.
Instead, rework the two nested loops to only read the
addr_decoderegisters and then keep only one instance of the dimm info structure.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Arnd Bergmann <[email protected]>Seems fine with the comment adjustment.
Thanks.
Acked-by Jason Baron <[email protected]>
Applied (with comment adjustment) to RAS tree edac-drivers branch
Thanks
-Tony