[systemd-commits] 2 commits - src/shared

Michal Schmidt michich at kemper.freedesktop.org
Thu Jul 26 05:28:17 PDT 2012


 src/shared/log.c |    5 +++++
 src/shared/log.h |    6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 6dc1e7e0ba35c078b533d06a4933edae38fd94ad
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Thu Jul 26 14:23:49 2012 +0200

    log: out-of-line __log_oom()
    
    The callers' code gets smaller.

diff --git a/src/shared/log.c b/src/shared/log.c
index 6a10dc4..1cbc9d6 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -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;
 
diff --git a/src/shared/log.h b/src/shared/log.h
index 7c3376c..ab894df 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -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)

commit cd6f1c0f87fd3e3345e51476e25cd1104efb7fa3
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Thu Jul 26 14:07:27 2012 +0200

    log: log_oom() must be a macro

diff --git a/src/shared/log.h b/src/shared/log.h
index 7bdb3e0..7c3376c 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -103,10 +103,11 @@ 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__)
 
-static inline int log_oom(void) {
-       log_error("Out of memory.");
-       return -ENOMEM;
-}
+/* This must be a macro for __LINE__ etc. to work */
+#define log_oom() ({ \
+       log_error("Out of memory."); \
+       -ENOMEM; \
+})
 
 /* This modifies the buffer passed! */
 #define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)



More information about the systemd-commits mailing list