Describe the errno an error stores, not the current one

The description looked up the message of whatever errno was set when
the description was built, so an error printed later read
"Success (errno 28)".
This commit is contained in:
T. R. Bernstein
2026-09-19 00:45:22 +02:00
parent 21f096aede
commit 3215d2eb5a
3 changed files with 16 additions and 10 deletions
+3 -6
View File
@@ -5,6 +5,7 @@
#include <sys/inotify.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
static inline int cinotify_deinit(int fd) {
return close(fd);
@@ -14,12 +15,8 @@ static inline int cinotify_get_errno(void) {
return errno;
}
static inline char* get_error_message() {
int error_number = errno;
errno = 0;
char* error_message = strerror(error_number);
if (errno > 0) return NULL;
return error_message;
static inline char* cinotify_error_message(int error_number) {
return strerror(error_number);
}
#endif