PCI: remove assignement in non straight forward if condition
PATCH v2 4/4 PCI: remove assignement in non straight forward if condition
The modifications effectively change the value of len_tmp in the case where the first condition is not met.
--- drivers/pci/hotplug/ibmphp_res.c | 13 +++++++++---- drivers/pci/pci.c | 6 +++++- drivers/pci/slot.c | 12 ++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-)
drivers/pci/hotplug/ibmphp_res.c +9 -4
@@ -1044,7 +1044,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)/* found our range */ if (!res_prev) {/* first time in the loop */ -if ((res_cur->start != range->start) && ((len_tmp = res_cur->start -1 - range->start) >= res->len)) { + len_tmp = res_cur->start -1 - range->start; + +if ((res_cur->start != range->start) && (len_tmp >= res->len)) {debug ("len_tmp = %x\n" , len_tmp);if ((len_tmp < len_cur) || (len_cur ==0 )) {
@@ -1084,7 +1086,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) }if (!res_cur->next) {/* last device on the range */ -if ((range->end != res_cur->end) && ((len_tmp = range->end - (res_cur->end +1 )) >= res->len)) { + len_tmp = range->end - (res_cur->end +1 ); + +if ((range->end != res_cur->end) && (len_tmp >= res->len)) {debug ("len_tmp = %x\n" , len_tmp);if ((len_tmp < len_cur) || (len_cur ==0 )) {
@@ -1123,8 +1127,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)if (res_prev) {if (res_prev->rangeno != res_cur->rangeno) {/* 1st device on this range */ -if ((res_cur->start != range->start) && - ((len_tmp = res_cur->start -1 - range->start) >= res->len)) { + len_tmp = res_cur->start -1 - range->start; + +if ((res_cur->start != range->start) && (len_tmp >= res->len)) {if ((len_tmp < len_cur) || (len_cur ==0 )) {if ((range->start % tmp_divide) ==0 ) {/* just perfect, starting address is divisible by length */
drivers/pci/pci.c +5 -1
@@ -4434,9 +4434,13 @@ static int __init pci_setup(char *str) {while (str) {char *k =strchr (str,',' ); +char tmp = *str; +if (k) *k++ =0 ; -if (*str && (str =pcibios_setup (str)) && *str) { + + str =pcibios_setup (str); +if (tmp && str && *str) {if (!strcmp (str,"nomsi" )) {pci_no_msi (); }else if (!strcmp (str,"noaer" )) {
drivers/pci/slot.c +10 -2
@@ -265,8 +265,16 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, slot =get_slot (parent, slot_nr);if (slot) {if (hotplug) { -if ((err = slot->hotplug ? -EBUSY :0 ) - || (err =rename_slot (slot, name))) { + err = slot->hotplug ? -EBUSY :0 ; +if (err) + goto hotplugerror; + + err =rename_slot (slot, name); +if (err) + goto hotplugerror; + +if (0 ) { +hotplugerror:kobject_put (&slot->kobj); slot =NULL ; goto err;
Signature · 1 line
1.9.1
Bjorn Helgaas
maintainerQuoted 17 lines · Quentin Lambert
The modifications effectively change the value of
len_tmpin the case where the first condition is not met.Signed-off-by Quentin Lambert <[email protected]>--- drivers/pci/hotplug/ibmphp_res.c | 13 +++++++++---- drivers/pci/pci.c | 6 +++++- drivers/pci/slot.c | 12 ++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-)...
drivers/pci/pci.c +0
-0@@ -4434,9 +4434,13 @@ static int __init pci_setup(char *str) {
drivers/pci/pci.c static int __init pci_setup(char *str) · line 4443
Quoted 10 lines
drivers/pci/pci.c +5
-1while (str) {char *k =strchr (str,',' ); +char tmp = *str; +if (k) *k++ =0 ; -if (*str && (str =pcibios_setup (str)) && *str) { + + str =pcibios_setup (str); +if (tmp && str && *str) {
I dropped this change because I don't think the replacement is quite equivalent. Previously, we only called pcibios_setup() if "*str". The new code calls it even if "!*str".
Quoted 16 lines
drivers/pci/pci.c +0
-0if (!strcmp (str,"nomsi" )) {pci_no_msi (); }else if (!strcmp (str,"noaer" )) {drivers/pci/slot.c +3
-2@@ -265,8 +265,16 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, slot =get_slot (parent, slot_nr);if (slot) {if (hotplug) { -if ((err = slot->hotplug ? -EBUSY :0 ) - || (err =rename_slot (slot, name))) { + err = slot->hotplug ? -EBUSY :0 ; +if (err) + goto hotplugerror;
drivers/pci/slot.c struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, · line 280
Quoted 10 lines
drivers/pci/slot.c +7
-0+ + err =rename_slot (slot, name); +if (err) + goto hotplugerror; + +if (0 ) { +hotplugerror:kobject_put (&slot->kobj); slot =NULL ; goto err;
And I dropped this one because the code is too ugly. Granted, the original is probably even uglier, but if we're going to change it, I'm going to hold out for a prettier restructuring.
Bjorn