Skip to content

Commit e2378e6

Browse files
David Laightbjorn-helgaas
authored andcommitted
PCI: Use max() instead of max_t() to ease static analysis
In this code: used_buses = max_t(unsigned int, available_buses, pci_hotplug_bus_size - 1); max_t() casts the 'unsigned long' pci_hotplug_bus_size (either 32 or 64 bits) to 'unsigned int' (32 bits) result type, so there's a potential of discarding significant bits. Instead, use max(a, b), which casts 'unsigned int' to 'unsigned long' and cannot discard significant bits. In this case, pci_hotplug_bus_size is constrained to <= 0xff by pci_setup() so this doesn't fix a bug, but it makes static analysis easier. Signed-off-by: David Laight <david.laight.linux@gmail.com> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20251119224140.8616-26-david.laight.linux@gmail.com
1 parent 3a86608 commit e2378e6

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/pci/probe.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,8 +3170,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
31703170
* bus number if there is room.
31713171
*/
31723172
if (bus->self && bus->self->is_hotplug_bridge) {
3173-
used_buses = max_t(unsigned int, available_buses,
3174-
pci_hotplug_bus_size - 1);
3173+
used_buses = max(available_buses, pci_hotplug_bus_size - 1);
31753174
if (max - start < used_buses) {
31763175
max = start + used_buses;
31773176

0 commit comments

Comments
 (0)