Fix return codes for loop functions.
authorAndre Noll <maan@systemlinux.org>
Wed, 5 Nov 2008 17:30:28 +0000 (18:30 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 5 Nov 2008 17:30:28 +0000 (18:30 +0100)
The four different loop functions must set the return value in
their private struct because these functions are called from
within the osl library which will replace any negative return value
by -E_OSL_LOOP.

select.c

index 9a19825ba0caf0bda41608242455b78a8fc3e564..3ec359eb07096f4f5ecc5fa815351757d935f99b 100644 (file)
--- a/select.c
+++ b/select.c
@@ -282,7 +282,7 @@ static int global_summary_loop_function(struct osl_row *row, void *data)
 err:
        gsi->ret = ret;
        gsi->osl_errno = (ret == -E_OSL)? osl_errno : 0;
-       return -1;
+       return ret;
 }
 
 static int print_global_summary(struct format_info *fi)
@@ -334,7 +334,7 @@ static int user_summary_loop_function(struct osl_row *row, void *data)
 err:
        usi->ret = ret;
        usi->osl_errno = (ret == -E_OSL)? osl_errno : 0;
-       return -1;
+       return ret;
 }
 
 static int compute_user_summary(struct user_info *ui, __a_unused void *data)
@@ -468,12 +468,14 @@ static int user_list_loop_function(struct osl_row *row, void *data)
        free(dirname);
        ret = output("%s", buf);
        free(buf);
+       if (ret < 0)
+               goto err;
        uli->count--;
        return ret;
 err:
        uli->ret = ret;
        uli->osl_errno = (ret == -E_OSL)? osl_errno : 0;
-       return -1;
+       return ret;
 }
 
 static int print_user_list(struct user_info *ui, void *data)
@@ -536,6 +538,8 @@ static int global_list_loop_function(struct osl_row *row, void *data)
        free(dirname);
        ret = output("%s", buf);
        free(buf);
+       if (ret < 0)
+               goto err;
        if (gli->count > 0)
                gli->count--;
        return ret;