Skip to content

Commit c29dfd6

Browse files
arndbaegl
authored andcommitted
EDAC/ie31200: work around false positive build warning
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. [Tony: Qiuxu pointed out that the "populate DIMM info" comment was left behind in the refactor and suggested moving it. I deleted the comment as unnecessry in front os a call to populate_dimm_info(). That seems pretty self-describing.] Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Jason Baron <[email protected]> Signed-off-by: Tony Luck <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 0ad2507 commit c29dfd6

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/edac/ie31200_edac.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,9 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)
409409
int i, j, ret;
410410
struct mem_ctl_info *mci = NULL;
411411
struct edac_mc_layer layers[2];
412-
struct dimm_data dimm_info[IE31200_CHANNELS][IE31200_DIMMS_PER_CHANNEL];
413412
void __iomem *window;
414413
struct ie31200_priv *priv;
415-
u32 addr_decode, mad_offset;
414+
u32 addr_decode[IE31200_CHANNELS], mad_offset;
416415

417416
/*
418417
* Kaby Lake, Coffee Lake seem to work like Skylake. Please re-visit
@@ -470,19 +469,10 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)
470469
mad_offset = IE31200_MAD_DIMM_0_OFFSET;
471470
}
472471

473-
/* populate DIMM info */
474472
for (i = 0; i < IE31200_CHANNELS; i++) {
475-
addr_decode = readl(window + mad_offset +
473+
addr_decode[i] = readl(window + mad_offset +
476474
(i * 4));
477-
edac_dbg(0, "addr_decode: 0x%x\n", addr_decode);
478-
for (j = 0; j < IE31200_DIMMS_PER_CHANNEL; j++) {
479-
populate_dimm_info(&dimm_info[i][j], addr_decode, j,
480-
skl);
481-
edac_dbg(0, "size: 0x%x, rank: %d, width: %d\n",
482-
dimm_info[i][j].size,
483-
dimm_info[i][j].dual_rank,
484-
dimm_info[i][j].x16_width);
485-
}
475+
edac_dbg(0, "addr_decode: 0x%x\n", addr_decode[i]);
486476
}
487477

488478
/*
@@ -493,14 +483,22 @@ static int ie31200_probe1(struct pci_dev *pdev, int dev_idx)
493483
*/
494484
for (i = 0; i < IE31200_DIMMS_PER_CHANNEL; i++) {
495485
for (j = 0; j < IE31200_CHANNELS; j++) {
486+
struct dimm_data dimm_info;
496487
struct dimm_info *dimm;
497488
unsigned long nr_pages;
498489

499-
nr_pages = IE31200_PAGES(dimm_info[j][i].size, skl);
490+
populate_dimm_info(&dimm_info, addr_decode[j], i,
491+
skl);
492+
edac_dbg(0, "size: 0x%x, rank: %d, width: %d\n",
493+
dimm_info.size,
494+
dimm_info.dual_rank,
495+
dimm_info.x16_width);
496+
497+
nr_pages = IE31200_PAGES(dimm_info.size, skl);
500498
if (nr_pages == 0)
501499
continue;
502500

503-
if (dimm_info[j][i].dual_rank) {
501+
if (dimm_info.dual_rank) {
504502
nr_pages = nr_pages / 2;
505503
dimm = edac_get_dimm(mci, (i * 2) + 1, j, 0);
506504
dimm->nr_pages = nr_pages;

0 commit comments

Comments
 (0)