Alexandru Gagniuc (mr.nuke.me@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@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@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 */