recv: Don't set argv to NULL when parsing receiver args.
authorAndre Noll <maan@systemlinux.org>
Sun, 31 Jan 2010 22:16:15 +0000 (23:16 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 31 Jan 2010 22:16:15 +0000 (23:16 +0100)
This leads to error messages like

(null): unrecognized option '--foo'

in case an invalid option was given. Fix it by setting argv[0] to
the receiver name instead.

Thanks to Gerrit Renker for pointing out this bug.

recv_common.c

index 953e2a1..00c1dd8 100644 (file)
@@ -42,15 +42,13 @@ static void *parse_receiver_args(int receiver_num, char *options)
                argc = split_args(options, &argv, " \t");
                for (i = argc - 1; i >= 0; i--)
                        argv[i + 1] = argv[i];
-               argv[0] = para_strdup(r->name);
                argc += 1;
-               PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
        } else {
                argc = 1;
                argv = para_malloc(2 * sizeof(char*));
-               argv[0] = NULL;
                argv[1] = NULL;
        }
+       argv[0] = make_message("%s_recv", r->name);
        conf = r->parse_config(argc, argv);
        free(argv[0]);
        free(argv);