]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
catblob: Fix "no matches" message.
authorAndre Noll <maan@systemlinux.org>
Mon, 26 Sep 2011 20:51:48 +0000 (22:51 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Nov 2011 11:29:13 +0000 (12:29 +0100)
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.

blob.c

diff --git a/blob.c b/blob.c
index 21144d851a48d8a3d6c2fb16eb792adea5c87a1e..b1d552248cea4e925136172eab846cf1549b3b26 100644 (file)
--- 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;
 }