From 8fcaba9a22ac0deda7dc6a8d5f270d1df08f9966 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Wed, 20 Apr 2011 11:55:06 +0100 Subject: [PATCH] fix rc_service_extra_commands return value If there were no extra commands, rc_service_extra_commands returned a list containing a single empty string. This changes that to return an empty list, which is more consistent with what you would expect. X-Gentoo-Bug: 360013 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013 --- src/librc/librc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/librc/librc.c b/src/librc/librc.c index f2f694df..5feb5d7a 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service) if ((fp = popen(cmd, "r"))) { rc_getline(&buffer, &len, fp); p = buffer; - while ((token = strsep(&p, " "))) { - if (!commands) - commands = rc_stringlist_new(); - rc_stringlist_add(commands, token); - } + commands = rc_stringlist_new(); + + while ((token = strsep(&p, " "))) + if (token[0] != '\0') + rc_stringlist_add(commands, token); + pclose(fp); free(buffer); } + free(cmd); return commands; }