From: Andre Noll Date: Mon, 26 Sep 2011 20:51:48 +0000 (+0200) Subject: catblob: Fix "no matches" message. X-Git-Tag: v0.4.9~3^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=6bfdc5bf94294ee8ec19c530d77ea4a0fb4e8618 catblob: Fix "no matches" message. The catblob commands are supposed to print this message only if none of the given patterns matches any blob in the database. However, in case all of the matching blobs are empty, we do print the message. The problem is that the match count is not being increased due to cat_blob() returning negative for empty blobs. This count is computed in action_if_pattern_matches() which calls cat_blob() as its action handler which in turn calls osl_open_disk_object(). But this function returns -E_OSL_EMPTY for empty blobs, and cat_blob() just passes through this value. This patch changes cat_blob() so that it explicitly checks for -E_OSL_EMPTY and returns zero in this case so that the match counter will be increased. --- diff --git a/blob.c b/blob.c index 21144d85..b1d55224 100644 --- a/blob.c +++ b/blob.c @@ -203,9 +203,9 @@ static int cat_blob(struct osl_table *table, struct osl_row *row, ret = osl(osl_open_disk_object(table, row, BLOBCOL_DEF, &obj)); if (ret < 0) - return ret; - if (obj.size) - ret = pass_buffer_as_shm(obj.data, obj.size, data); + return (ret == osl(-E_OSL_EMPTY))? 0 : ret; + assert(obj.size > 0); + ret = pass_buffer_as_shm(obj.data, obj.size, data); ret2 = osl(osl_close_disk_object(&obj)); return (ret < 0)? ret : ret2; }