]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
aft.c: Fix com_add().
authorAndre Noll <maan@systemlinux.org>
Wed, 12 Sep 2007 21:43:16 +0000 (23:43 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 12 Sep 2007 21:43:16 +0000 (23:43 +0200)
callbacks shall return zero or negative, if no result is provided. So let
com_ls_callback() return zero if no match was found, or if the audio file table
does not contain any entries. Check for ret > 0 in com_add() instead of ret >=
0, i.e. don't use the result pointer if ret is zero.

aft.c

diff --git a/aft.c b/aft.c
index 3c33aae0c747513a39ddd4426a413a30e5644b58..9ec977613e0b78f36d5ef56e974ed986cef85ca8 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -981,7 +981,7 @@ static int com_ls_callback(const struct osl_object *query,
                        prepare_ls_row);
        if (ret < 0)
                goto out;
-       ret = opts->num_patterns? -E_NO_MATCH : 1;
+       ret = opts->num_patterns? -E_NO_MATCH : 0;
        if (!opts->num_matching_paths) {
                PARA_NOTICE_LOG("no match, ret: %d\n", ret);
                goto out;
@@ -1004,6 +1004,7 @@ static int com_ls_callback(const struct osl_object *query,
        ret = 1;
 out:
        ls_output->data = b.buf;
+       PARA_NOTICE_LOG("ls_outoute.data: %p\n", ls_output->data);
        ls_output->size = b.size;
        free(opts->data);
        free(opts->data_ptr);
@@ -1123,8 +1124,8 @@ int com_afs_ls(int fd, int argc, char * const * const argv)
        opts.num_patterns = argc - i;
        ret = send_option_arg_callback_request(&query, opts.num_patterns,
                argv + i, com_ls_callback, &ls_output);
-       if (ret >= 0 && ls_output.data) {
-               send_buffer(fd, (char *)ls_output.data);
+       if (ret > 0) {
+               ret = send_buffer(fd, (char *)ls_output.data);
                free(ls_output.data);
        }
        return ret;