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

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Mar 27 09:06:27 PDT 2013


On Wed, Mar 27, 2013 at 10:44:21AM +0100, Lukas Nykryn wrote:
> 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.

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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 


More information about the systemd-devel mailing list