[systemd-devel] [PATCH 2/2] log: fix error codes handling in catalog_list_items
Previously r was set to zero and so if(r0) 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 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 2/2] log: fix error codes handling in catalog_list_items
On Wed, Mar 27, 2013 at 10:44:21AM +0100, Lukas Nykryn wrote: Previously r was set to zero and so if(r0) was never true. Also it does not make sense to print error code from previous loop. Applied the first one and a half of this one. You're right that k should be used instead of r, but this is in a loop, so r 0 is possible. The convention is to return the *first* error. Zbyszek --- 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 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 2/2] log: fix error codes handling in catalog_list_items
So if we want to return first error there should be -if (r 0) +if (r == 0) r = k; Am I right? Lukas St 27. březen 2013, 17:06:27 CET, Zbigniew Jędrzejewski-Szmek napsal: On Wed, Mar 27, 2013 at 10:44:21AM +0100, Lukas Nykryn wrote: Previously r was set to zero and so if(r0) was never true. Also it does not make sense to print error code from previous loop. Applied the first one and a half of this one. You're right that k should be used instead of r, but this is in a loop, so r 0 is possible. The convention is to return the *first* error. Zbyszek --- 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 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel