Skip to contentSkip to conversation

sam460ex: Add comment explaining ignored errors from fdt operations

PATCH In review Guenter Roeck 3 participants 6 messages Jul 5, 2018 – Jul 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sam460ex: Add comment explaining ignored errors from fdt operations

Failing to set serial port clock frequencies is not fatal. Add a comment into the code explaining this, and typecast the function to void to silence static analyzers.

Cc BALATON Zoltan <[email protected]>
Cc Pilippe Mathieu-Daudé <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 hw/ppc/sam460ex.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/ppc/sam460ex.c +4 -1
index 7eed2ec..b004cda 100644
@@ -324,7 +324,10 @@ static int sam460ex_load_device_tree(hwaddr addr,
     /* set serial port clocks */
     offset = fdt_node_offset_by_compatible(fdt, -1, "ns16550");
     while (offset >= 0) {
-        fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
+        /* Failure to set serial port clocks is not fatal, so just ignore
+         * errors when trying to do so.
+         */
+        (void)fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
         offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");
     }
 
Signature · 1 line
2.7.4
#1 lore raw

hw/ppc/sam460ex.c static int sam460ex_load_device_tree(hwaddr addr, · line 331

Quoted 5 lines · Guenter Roeck
hw/ppc/sam460ex.c +4 -0
+        /* Failure to set serial port clocks is not fatal, so just ignore
+         * errors when trying to do so.
+         */
+        (void)fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
         offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");

Ok, but why would it even fail? Maybe it's not this case, but even if it's not fatal for the OS, generating different device trees silently seems like a recipe for Heisenbugs.

Thanks,

Paolo

#2 lore raw
Quoted 10 lines · Paolo Bonzini

hw/ppc/sam460ex.c static int sam460ex_load_device_tree(hwaddr addr, · line 331

Quoted 5 lines · Guenter Roeck
hw/ppc/sam460ex.c +4 -0
+        /* Failure to set serial port clocks is not fatal, so just ignore
+         * errors when trying to do so.
+         */
+        (void)fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ);
         offset = fdt_node_offset_by_compatible(fdt, offset, "ns16550");

Ok, but why would it even fail? Maybe it's not this case, but even if it's not fatal for the OS, generating different device trees silently seems like a recipe for Heisenbugs.

Yes, quite. Especially since the most likely errors I can see here would actually indicate something has already gone horribly wrong with the device tree construction, so a missing clock-frequency is the least of our troubles.

I think using _FDT() here would be a better approach.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 9 lines · David Gibson
Quoted 3 lines

Ok, but why would it even fail? Maybe it's not this case, but even if it's not fatal for the OS, generating different device trees silently seems like a recipe for Heisenbugs.

Yes, quite. Especially since the most likely errors I can see here would actually indicate something has already gone horribly wrong with the device tree construction, so a missing clock-frequency is the least of our troubles.

I think using _FDT() here would be a better approach.

Or qemu_fdt_setprop_cell, which is there exactly for this reason. Volunteers needed to report it in checkpatch! :)

Paolo

#4 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · David Gibson
Quoted 3 lines

Ok, but why would it even fail? Maybe it's not this case, but even if it's not fatal for the OS, generating different device trees silently seems like a recipe for Heisenbugs.

Yes, quite. Especially since the most likely errors I can see here would actually indicate something has already gone horribly wrong with the device tree construction, so a missing clock-frequency is the least of our troubles.

Quoted 5 lines
Quoted 1 line

I think using _FDT() here would be a better approach.

Or qemu_fdt_setprop_cell, which is there exactly for this reason. Volunteers needed to report it in checkpatch! :)

Sure, except it uses different parameters. Why don't you come up with an implementation that is acceptable to you ? I was asked earlier to add the comment, which I did, only to now be told that it is insufficient. This can go on forever. At this point, I'll be happy to send a revert request.

Guenter

#5 lore raw
Quoted 12 lines · Guenter Roeck
Quoted 11 lines · Paolo Bonzini
Quoted 9 lines · David Gibson
Quoted 3 lines

Ok, but why would it even fail? Maybe it's not this case, but even if it's not fatal for the OS, generating different device trees silently seems like a recipe for Heisenbugs.

Yes, quite. Especially since the most likely errors I can see here would actually indicate something has already gone horribly wrong with the device tree construction, so a missing clock-frequency is the least of our troubles.

I think using _FDT() here would be a better approach.

Quoted 8 lines
Quoted 3 lines

Or qemu_fdt_setprop_cell, which is there exactly for this reason. Volunteers needed to report it in checkpatch! :)

Sure, except it uses different parameters. Why don't you come up with an implementation that is acceptable to you ? I was asked earlier to add the comment, which I did, only to now be told that it is insufficient. This can go on forever. At this point, I'll be happy to send a revert request.

Well, we asked for the comment because we were told that ignoring the error was intentional. When the comment was made, it became clear that wasn't really the case.

Really, I should have caught this when I first merged the code, though. The error handling throughout this function is kind of bogus, so I'm about to add my own patch to fix it.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson