]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/journal-importer: use %m instead of strerror()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Oct 2022 07:18:26 +0000 (09:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Oct 2022 14:10:21 +0000 (16:10 +0200)
Here SYNTHETIC_ERRNO() was used based on the general rule that logging
functions should do that when the error value is generated at the call
site. But here we're really propagating a memory allocation error, which
wasn't reported using errno, but the meaning is the same. And it's better
to bend the rule a bit like this than to use strerror().

src/shared/journal-importer.c

index 66481da267a9ffc3913f3dd469a7aca37bea79ae..d9eabec886fde020635827e0e977cee6897f91b2 100644 (file)
@@ -426,11 +426,10 @@ int journal_importer_push_data(JournalImporter *imp, const char *data, size_t si
         assert(imp->state != IMPORTER_STATE_EOF);
 
         if (!realloc_buffer(imp, imp->filled + size))
-                return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
+                return log_error_errno(ENOMEM,
                                        "Failed to store received data of size %zu "
-                                       "(in addition to existing %zu bytes with %zu filled): %s",
-                                       size, MALLOC_SIZEOF_SAFE(imp->buf), imp->filled,
-                                       strerror_safe(ENOMEM));
+                                       "(in addition to existing %zu bytes with %zu filled): %m",
+                                       size, MALLOC_SIZEOF_SAFE(imp->buf), imp->filled);
 
         memcpy(imp->buf + imp->filled, data, size);
         imp->filled += size;