From: Andre Noll Date: Wed, 5 Nov 2008 17:30:28 +0000 (+0100) Subject: Fix return codes for loop functions. X-Git-Tag: v0.0.5~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=51dee16f222c24d152321c789603f0b456112715;hp=5e2e9dc031b9695b461780b06210a9085ad23458 Fix return codes for loop functions. 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. --- diff --git a/select.c b/select.c index 9a19825..3ec359e 100644 --- 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;