Skip to contentSkip to conversation

config_distro_bootcmd.h: add note on error handling

PATCH In review Stephen Warren 3 participants 6 messages Mar 10, 2015 – Mar 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 config_distro_bootcmd.h: add note on error handling

From: Stephen Warren <[email protected]>

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

---
 include/config_distro_bootcmd.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/config_distro_bootcmd.h +16 -0
index 07a0b3b23472..73f093f9eaf5 100644
@@ -10,6 +10,22 @@
 #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
 #define _CONFIG_CMD_DISTRO_BOOTCMD_H
 
+/*
+ * A note on error handling: It is possible for BOOT_TARGET_DEVICES to
+ * reference a device that is not enabled in the U-Boot configuration, e.g.
+ * it may include MMC in the list without CONFIG_CMD_MMC being enabled. Given
+ * that BOOT_TARGET_DEVICES is a macro that's expanded by the C pre-processor
+ * at compile time, it's not  possible to detect and report such problems via
+ * a simple #ifdef/#error combination. Still, the code needs to report errors.
+ * The best way I've found to do this is to make BOOT_TARGET_DEVICES expand to
+ * reference a non-existent symbol, and have the name of that symbol encode
+ * the error message. Consequently, this file contains references to e.g.
+ * BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC. Given the
+ * prevalence of capitals here, this looks like a pre-processor macro and
+ * hence seems like it should be all capitals, but it's really an error
+ * message that includes some other pre-processor symbols in the text.
+ */
+
 /* We need the part command */
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 config_distro_bootcmd.h: add note on error handling

Quoted 8 lines · Stephen Warren

From: Stephen Warren <[email protected]>

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150311/0ef25192/attachment.sig>
#2 lore raw

PATCH 1/1 config_distro_bootcmd.h: add note on error handling

Quoted 4 lines · Tom Rini
Quoted 2 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Quoted 8 lines
Quoted 6 lines

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

Thanks. It looks like you usually apply the patches to this file rather than acking it for someone else to take. Was your reviewed-by just a hint you're waiting for e.g. Simon to review it too?

#3 lore raw

PATCH 1/1 config_distro_bootcmd.h: add note on error handling

Quoted 9 lines · Stephen Warren
Quoted 8 lines · Tom Rini
Quoted 6 lines · Stephen Warren

From: Stephen Warren <[email protected]>

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Thanks. It looks like you usually apply the patches to this file rather than acking it for someone else to take. Was your reviewed-by just a hint you're waiting for e.g. Simon to review it too?

Yes, thanks :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150311/50911880/attachment.sig>
#4 lore raw

PATCH 1/1 config_distro_bootcmd.h: add note on error handling

In reply to Stephen Warren
Quoted 29 lines · Stephen Warren

From: Stephen Warren <[email protected]>

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

---
 include/config_distro_bootcmd.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/config_distro_bootcmd.h +9 -0
index 07a0b3b23472..73f093f9eaf5 100644
@@ -10,6 +10,22 @@
 #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
 #define _CONFIG_CMD_DISTRO_BOOTCMD_H
 
+/*
+ * A note on error handling: It is possible for BOOT_TARGET_DEVICES to
+ * reference a device that is not enabled in the U-Boot configuration, e.g.
+ * it may include MMC in the list without CONFIG_CMD_MMC being enabled. Given
+ * that BOOT_TARGET_DEVICES is a macro that's expanded by the C pre-processor
+ * at compile time, it's not  possible to detect and report such problems via
+ * a simple #ifdef/#error combination. Still, the code needs to report errors.
+ * The best way I've found to do this is to make BOOT_TARGET_DEVICES expand to
+ * reference a non-existent symbol, and have the name of that symbol encode

include/config_distro_bootcmd.h line 31

Quoted 10 lines
include/config_distro_bootcmd.h +7 -0
+ * the error message. Consequently, this file contains references to e.g.
+ * BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC. Given the
+ * prevalence of capitals here, this looks like a pre-processor macro and
+ * hence seems like it should be all capitals, but it's really an error
+ * message that includes some other pre-processor symbols in the text.
+ */
+
 /* We need the part command */
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART

Very clear thank you.

#5 lore raw
In reply to Stephen Warren
Quoted 10 lines · Stephen Warren

From: Stephen Warren <[email protected]>

This should make it more clear why there appear to be C pre-processor symbols in the file that contain mixed case. They're really error messages.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150315/178410f9/attachment.sig>