Skip to content

Commit a45e47f

Browse files
arndbgregkh
authored andcommitted
staging: fsl-mc: fix warning in DT ranges parser
The fsl-mc-bus driver in staging contains a copy of the standard 'ranges' property parsing algorithm with a hack to treat a missing property the same way as an empty one. This code produces false-positive warnings for me in an allmodconfig build: drivers/staging/fsl-mc/bus/fsl-mc-bus.c: In function 'fsl_mc_bus_probe': drivers/staging/fsl-mc/bus/fsl-mc-bus.c:645:6: error: 'mc_size_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:682:8: error: 'mc_addr_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:644:6: note: 'mc_addr_cells' was declared here drivers/staging/fsl-mc/bus/fsl-mc-bus.c:684:8: error: 'paddr_cells' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/staging/fsl-mc/bus/fsl-mc-bus.c:643:6: note: 'paddr_cells' was declared here To avoid the warnings, I'm simplifying the argument handling to pass the number of valid ranges in the property as the function return code rather than passing it by reference. With this change, gcc can see that we don't evaluate the cell numbers for an missing ranges property. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 87bfbdd commit a45e47f

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/staging/fsl-mc/bus/fsl-mc-bus.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,7 @@ static int parse_mc_ranges(struct device *dev,
588588
int *paddr_cells,
589589
int *mc_addr_cells,
590590
int *mc_size_cells,
591-
const __be32 **ranges_start,
592-
u8 *num_ranges)
591+
const __be32 **ranges_start)
593592
{
594593
const __be32 *prop;
595594
int range_tuple_cell_count;
@@ -602,8 +601,6 @@ static int parse_mc_ranges(struct device *dev,
602601
dev_warn(dev,
603602
"missing or empty ranges property for device tree node '%s'\n",
604603
mc_node->name);
605-
606-
*num_ranges = 0;
607604
return 0;
608605
}
609606

@@ -630,33 +627,32 @@ static int parse_mc_ranges(struct device *dev,
630627
return -EINVAL;
631628
}
632629

633-
*num_ranges = ranges_len / tuple_len;
634-
return 0;
630+
return ranges_len / tuple_len;
635631
}
636632

637633
static int get_mc_addr_translation_ranges(struct device *dev,
638634
struct fsl_mc_addr_translation_range
639635
**ranges,
640636
u8 *num_ranges)
641637
{
642-
int error;
638+
int ret;
643639
int paddr_cells;
644640
int mc_addr_cells;
645641
int mc_size_cells;
646642
int i;
647643
const __be32 *ranges_start;
648644
const __be32 *cell;
649645

650-
error = parse_mc_ranges(dev,
646+
ret = parse_mc_ranges(dev,
651647
&paddr_cells,
652648
&mc_addr_cells,
653649
&mc_size_cells,
654-
&ranges_start,
655-
num_ranges);
656-
if (error < 0)
657-
return error;
650+
&ranges_start);
651+
if (ret < 0)
652+
return ret;
658653

659-
if (!(*num_ranges)) {
654+
*num_ranges = ret;
655+
if (!ret) {
660656
/*
661657
* Missing or empty ranges property ("ranges;") for the
662658
* 'fsl,qoriq-mc' node. In this case, identity mapping

0 commit comments

Comments
 (0)