chiark / gitweb /
log: out-of-line __log_oom()
authorMichal Schmidt <mschmidt@redhat.com>
Thu, 26 Jul 2012 12:23:49 +0000 (14:23 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Thu, 26 Jul 2012 12:24:40 +0000 (14:24 +0200)
The callers' code gets smaller.

src/shared/log.c
src/shared/log.h

index 6a10dc4540ed288032f6fefb3ccedaf730d777a3..1cbc9d625074f00d6f9b24e300e6145fdf2ec27e 100644 (file)
@@ -658,6 +658,11 @@ _noreturn_ void log_assert_failed_unreachable(const char *text, const char *file
         log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
 }
 
+int __log_oom(const char *file, int line, const char *func) {
+        log_meta(LOG_ERR, file, line, func, "Out of memory.");
+        return -ENOMEM;
+}
+
 int log_set_target_from_string(const char *e) {
         LogTarget t;
 
index 7c3376c31e5efdda0ecc2eb7106294635c6a6eff..ab894df172ef724776cce154847684e681336fbb 100644 (file)
@@ -103,11 +103,8 @@ int log_dump_internal(
 #define log_warning(...) log_meta(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
 #define log_error(...)   log_meta(LOG_ERR,     __FILE__, __LINE__, __func__, __VA_ARGS__)
 
-/* This must be a macro for __LINE__ etc. to work */
-#define log_oom() ({ \
-       log_error("Out of memory."); \
-       -ENOMEM; \
-})
+int __log_oom(const char *file, int line, const char *func);
+#define log_oom() __log_oom(__FILE__, __LINE__, __func__)
 
 /* This modifies the buffer passed! */
 #define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)