summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2013-11-23 17:46:04 -0600
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2013-11-25 23:59:46 +0100
commitfe9e30d6b74e340f9a97b9e358e20ec8a2785954 (patch)
tree5dd135cae0becec8b1acc99b81fb76690d3ff395
parent85263b06bb423fdeb703f85c8e3378d989e854a3 (diff)
downloadcoreboot-fe9e30d6b74e340f9a97b9e358e20ec8a2785954.tar.xz
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@gmail.com> Reviewed-on: http://review.coreboot.org/4264 Tested-by: build bot (Jenkins) Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r--src/include/types.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/include/types.h b/src/include/types.h
index 384fac53b2..180fa3a68a 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 */