[systemd-devel] [PATCH 2/2] log: fix error codes handling in catalog_list_items

Lukas Nykryn lnykryn at redhat.com
Wed Mar 27 02:44:21 PDT 2013


Previously r was set to zero and so if(r<0) was never true. Also it does not make sense to print error code from previous loop.
---
 src/journal/catalog.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index dacf5c5..96854d7 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -616,9 +616,8 @@ int catalog_list_items(FILE *f, bool oneline, char **items) {
                 k = sd_id128_from_string(*item, &id);
                 if (k < 0) {
                         log_error("Failed to parse id128 '%s': %s",
-                                  *item, strerror(-r));
-                        if (r < 0)
-                                r = k;
+                                  *item, strerror(-k));
+                        r = k;
                         continue;
                 }
 
@@ -626,9 +625,8 @@ int catalog_list_items(FILE *f, bool oneline, char **items) {
                 if (k < 0) {
                         log_full(k == -ENOENT ? LOG_NOTICE : LOG_ERR,
                                  "Failed to retrieve catalog entry for '%s': %s",
-                                  *item, strerror(-r));
-                        if (r < 0)
-                                r = k;
+                                  *item, strerror(-k));
+                        r = k;
                         continue;
                 }
 
-- 
1.8.1.4



More information about the systemd-devel mailing list