Added set_error() API to have a single point of entry for setting for errno and errstr.
[akaros.git] / kern / include / err.h
index 84cb8a7..b26f8da 100644 (file)
                     int curindex = 0;
 #define waserror() setjmp(&(errpush(errstack, ARRAY_SIZE(errstack), &curindex, \
                                                                        &prev_errbuf)->jmpbuf))
-#define error(e, x, ...)                                               \
-       do {                                                                            \
-               if (x != NULL)                                                                                                  \
-                       set_errstr(x, ##__VA_ARGS__);                                                           \
-               else                                                                                                                    \
-                       set_errstr(errno_to_string(e));                                                         \
-               set_errno(e);                                                                                                   \
+#define error(e, x, ...)                                                                                               \
+       do {                                                                                                                            \
+               set_error(e, x, ##__VA_ARGS__);                                                                 \
                longjmp(&get_cur_errbuf()->jmpbuf, 1);                                                  \
        } while(0)
 #define nexterror() longjmp(&(errpop(errstack, ARRAY_SIZE(errstack), &curindex, \