[coreboot-gerrit] New patch to review for coreboot: 306fb34 include/types.h: Add generic enum for error codes

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Sun Nov 24 02:24:48 CET 2013


Alexandru Gagniuc (mr.nuke.me at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4264

-gerrit

commit 306fb34c88e3bee54a3f1072f4c57ae476a953be
Author: Alexandru Gagniuc <mr.nuke.me at gmail.com>
Date:   Sat Nov 23 17:46:04 2013 -0600

    include/types.h: Add generic enum for error codes
    
    The idea is that instead of:
     if (do_something()) do_something_else();
    It is more readable to write:
     if (do_something() != CB_SUCCESS) handle_error();
    
    Change-Id: I4fa5a6f2d2960cd747fda6602bdfff6aef08f8e2
    Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
---
 src/include/types.h | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/include/types.h b/src/include/types.h
index 384fac5..180fa3a 100644
--- a/src/include/types.h
+++ b/src/include/types.h
@@ -21,5 +21,19 @@
 #define __TYPES_H
 #include <stdint.h>
 #include <stddef.h>
-#endif
 
+/**
+ * Coreboot error codes
+ *
+ * When building functions that return a status or an error code, use cb_err as
+ * the return type. When failure reason needs to be communicated by the return
+ * value, define a it here. Start new enum groups with values in decrements of
+ * 100.
+ */
+enum cb_err {
+	CB_SUCCESS = 0,		/**< Call completed succesfully */
+	CB_ERR = -1,		/**< Generic error code */
+	CB_ERR_ARG = -2,	/**< Invalid argument */
+};
+
+#endif /* __TYPES_H */



More information about the coreboot-gerrit mailing list