From d5e45a0c7b49c51a6b4e8939de112df272d83139 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Tue, 15 Jan 2013 18:10:16 +0000 Subject: [PATCH] (daemon) #5225 nightly regression: remote option '-l' displays warning -- fixed. --- daemon/remote.c | 54 +++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index f8a651e1b..7cc740ed2 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -552,14 +552,20 @@ getEncodedMetainfo (const char * filename) } static void -addIdArg (tr_variant * args, const char * id) +addIdArg (tr_variant * args, const char * id, const char * fallback) { - if (!*id) + if (!id || !*id) { - fprintf (stderr, "No torrent specified! Please use the -t option first.\n"); - id = "-1"; /* no torrent will have this ID, so should be a no-op */ + id = fallback; + + if (!id || !*id) + { + fprintf (stderr, "No torrent specified! Please use the -t option first.\n"); + id = "-1"; /* no torrent will have this ID, so will act as a no-op */ + } } - else if (!tr_strcmp0 (id, "active")) + + if (!tr_strcmp0 (id, "active")) { tr_variantDictAddStr (args, TR_KEY_ids, "recently-active"); } @@ -1894,7 +1900,7 @@ processArgs (const char * rpcurl, int argc, const char ** argv) case 'a': /* add torrent */ if (sset != 0) status |= flush (rpcurl, &sset); if (tadd != 0) status |= flush (rpcurl, &tadd); - if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id); status |= flush (rpcurl, &tset); } + if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } tadd = tr_new0 (tr_variant, 1); tr_variantInitDict (tadd, 3); tr_variantDictAddStr (tadd, TR_KEY_method, "torrent-add"); @@ -1931,7 +1937,7 @@ processArgs (const char * rpcurl, int argc, const char ** argv) case 't': /* set current torrent */ if (tadd != 0) status |= flush (rpcurl, &tadd); - if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id); status |= flush (rpcurl, &tset); } + if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } tr_strlcpy (id, optarg, sizeof (id)); break; @@ -1973,37 +1979,37 @@ processArgs (const char * rpcurl, int argc, const char ** argv) args = tr_variantDictAddDict (top, ARGUMENTS, 0); fields = tr_variantDictAddList (args, TR_KEY_fields, 0); - if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id); status |= flush (rpcurl, &tset); } + if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } switch (c) { case 'i': tr_variantDictAddInt (top, TR_KEY_tag, TAG_DETAILS); n = TR_N_ELEMENTS (details_keys); for (i=0; i