From fe9e30d6b74e340f9a97b9e358e20ec8a2785954 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sat, 23 Nov 2013 17:46:04 -0600 Subject: 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 Reviewed-on: http://review.coreboot.org/4264 Tested-by: build bot (Jenkins) Reviewed-by: Vladimir Serbinenko Reviewed-by: Ronald G. Minnich --- src/include/types.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/include/types.h') 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 #include -#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 */ -- cgit v1.2.3