Changes in uspace/lib/socket/include/net_err.h [2721a75:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/socket/include/net_err.h
r2721a75 r849ed54 28 28 29 29 /** @addtogroup net 30 * @{30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Common error processing codes and routines.34 * Common error processing codes and routines. 35 35 */ 36 36 … … 41 41 42 42 #ifdef CONFIG_DEBUG 43 #include <stdio.h> 44 #include <str_error.h> 43 44 #include <stdio.h> 45 45 46 #endif 46 47 47 48 /** An actual stored error code. 48 *49 49 */ 50 #define ERROR_CODE 50 #define ERROR_CODE error_check_return_value 51 51 52 52 /** An error processing routines declaration. 53 * 54 * This has to be declared in the block where the error processing 55 * is desired. 56 * 53 * This has to be declared in the block where the error processing is desired. 57 54 */ 58 #define ERROR_DECLARE 55 #define ERROR_DECLARE int ERROR_CODE 59 56 60 /** Store the value as an error code and checks if an error occurred. 61 * 62 * @param[in] value The value to be checked. May be a function call. 63 * @return False if the value indicates success (EOK). 64 * @return True otherwise. 65 * 57 /** Stores the value as an error code and checks if an error occurred. 58 * @param[in] value The value to be checked. May be a function call. 59 * @returns FALSE if the value indicates success (EOK). 60 * @returns TRUE otherwise. 66 61 */ 67 62 #ifdef CONFIG_DEBUG 68 63 69 #define ERROR_OCCURRED(value) \ 70 (((ERROR_CODE = (value)) != EOK) \ 71 && ({ \ 72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \ 73 __FILE__, __LINE__, str_error(ERROR_CODE)); \ 74 1; \ 75 })) 64 #define ERROR_OCCURRED(value) \ 65 (((ERROR_CODE = (value)) != EOK) \ 66 && ({printf("error at %s:%d %d\n", __FILE__, __LINE__, ERROR_CODE); 1;})) 76 67 77 68 #else 78 69 79 #define ERROR_OCCURRED(value) 70 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK) 80 71 81 72 #endif 82 73 83 /** Error propagation 84 * 85 * Check if an error occurred and immediately exit the actual 86 * function returning the error code. 87 * 88 * @param[in] value The value to be checked. May be a function call. 89 * 74 /** Checks if an error occurred and immediately exits the actual function returning the error code. 75 * @param[in] value The value to be checked. May be a function call. 90 76 */ 91 77 92 #define ERROR_PROPAGATE(value) \ 93 if (ERROR_OCCURRED(value)) \ 94 return ERROR_CODE 78 #define ERROR_PROPAGATE(value) if(ERROR_OCCURRED(value)) return ERROR_CODE 95 79 96 80 #endif
Note:
See TracChangeset
for help on using the changeset viewer.