Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.11 66 lines 1.6 kB view raw
1diff -crb --new-file a/lib/error.h b/lib/error.h 2*** a/lib/error.h 1969-12-31 19:00:00.000000000 -0500 3--- b/lib/error.h 2021-01-21 04:38:25.000000000 -0500 4*************** 5*** 0 **** 6--- 1,27 ---- 7+ #ifndef _ERROR_H_ 8+ #define _ERROR_H_ 9+ 10+ #include <stdarg.h> 11+ #include <stdio.h> 12+ #include <stdlib.h> 13+ #include <string.h> 14+ #include <errno.h> 15+ 16+ static unsigned int error_message_count = 0; 17+ 18+ static inline void error(int status, int errnum, const char* format, ...) 19+ { 20+ va_list ap; 21+ fprintf(stderr, "%s: ", program_invocation_name); 22+ va_start(ap, format); 23+ vfprintf(stderr, format, ap); 24+ va_end(ap); 25+ if (errnum) 26+ fprintf(stderr, ": %s", strerror(errnum)); 27+ fprintf(stderr, "\n"); 28+ error_message_count++; 29+ if (status) 30+ exit(status); 31+ } 32+ 33+ #endif /* _ERROR_H_ */ 34diff -crb --new-file a/src/error.h b/src/error.h 35*** a/src/error.h 1969-12-31 19:00:00.000000000 -0500 36--- b/src/error.h 2021-01-21 04:38:29.000000000 -0500 37*************** 38*** 0 **** 39--- 1,27 ---- 40+ #ifndef _ERROR_H_ 41+ #define _ERROR_H_ 42+ 43+ #include <stdarg.h> 44+ #include <stdio.h> 45+ #include <stdlib.h> 46+ #include <string.h> 47+ #include <errno.h> 48+ 49+ static unsigned int error_message_count = 0; 50+ 51+ static inline void error(int status, int errnum, const char* format, ...) 52+ { 53+ va_list ap; 54+ fprintf(stderr, "%s: ", program_invocation_name); 55+ va_start(ap, format); 56+ vfprintf(stderr, format, ap); 57+ va_end(ap); 58+ if (errnum) 59+ fprintf(stderr, ": %s", strerror(errnum)); 60+ fprintf(stderr, "\n"); 61+ error_message_count++; 62+ if (status) 63+ exit(status); 64+ } 65+ 66+ #endif /* _ERROR_H_ */