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
This commit is contained in:
James Le Cuirot 2011-04-20 11:55:06 +01:00 committed by William Hubbs
parent 04e256e3b8
commit 8fcaba9a22

View File

@ -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;
}