log.h: new log_oom() -> int -ENOMEM, use it

also a number of minor fixups and bug fixes: spelling, oom errors
that didn't print errors, not properly forwarding error codes,
few more consistency issues, et cetera
This commit is contained in:
Shawn Landden
2012-07-26 11:48:26 +02:00
committed by Kay Sievers
parent e146e4516b
commit 0d0f0c50d3
40 changed files with 183 additions and 310 deletions
+1 -2
View File
@@ -281,8 +281,7 @@ static int create_socket(char **name) {
}
if (!(c = strdup(sa.un.sun_path))) {
r = -ENOMEM;
log_error("Out of memory.");
r = log_oom();
goto fail;
}
+1 -1
View File
@@ -1161,7 +1161,7 @@ void bus_async_unregister_and_exit(DBusConnection *bus, const char *name) {
return;
oom:
log_error("Out of memory.");
log_oom();
if (pending) {
dbus_pending_call_cancel(pending);
+6
View File
@@ -24,6 +24,7 @@
#include <syslog.h>
#include <stdbool.h>
#include <stdarg.h>
#include <errno.h>
#include "macro.h"
@@ -102,6 +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 modifies the buffer passed! */
#define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)
+2 -4
View File
@@ -52,10 +52,8 @@ static int parse_field(const void *data, size_t length, const char *field, char
buf = malloc(nl+1);
memcpy(buf, (const char*) data + fl, nl);
((char*)buf)[nl] = 0;
if (!buf) {
log_error("Out of memory.");
return -ENOMEM;
}
if (!buf)
return log_oom();
free(*target);
*target = buf;
+3 -5
View File
@@ -909,8 +909,7 @@ int load_env_file(
continue;
if (!(u = normalize_env_assignment(p))) {
log_error("Out of memory.");
r = -ENOMEM;
r = log_oom();
goto finish;
}
@@ -918,8 +917,7 @@ int load_env_file(
free(u);
if (!t) {
log_error("Out of memory.");
r = -ENOMEM;
r = log_oom();
goto finish;
}
@@ -4278,7 +4276,7 @@ void execute_directory(const char *directory, DIR *d, char *argv[]) {
continue;
if (asprintf(&path, "%s/%s", directory, de->d_name) < 0) {
log_error("Out of memory.");
log_oom();
continue;
}