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>
This commit is contained in:
parent
85263b06bb
commit
fe9e30d6b7
|
@ -21,5 +21,19 @@
|
||||||
#define __TYPES_H
|
#define __TYPES_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.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 */
|
||||||
|
|
Loading…
Reference in New Issue