diff options
author | Max Kellermann <max@duempel.org> | 2008-12-25 14:29:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-12-25 14:29:38 +0100 |
commit | d2cd085eef172fb0c684ef4075ba17f8fd5b999a (patch) | |
tree | 2b2c1dad26c66d3a2b0791d96d27374a61eafcd7 /src/conf.c | |
parent | d7a166e749de8f9649321ffe227a71156f9bc656 (diff) | |
download | mpd-d2cd085eef172fb0c684ef4075ba17f8fd5b999a.tar.gz mpd-d2cd085eef172fb0c684ef4075ba17f8fd5b999a.tar.xz mpd-d2cd085eef172fb0c684ef4075ba17f8fd5b999a.zip |
conf: don't pass length to parse_key_value()
We have a null-terminated string, no need to pass the length around.
Diffstat (limited to 'src/conf.c')
-rw-r--r-- | src/conf.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/conf.c b/src/conf.c index bc66967b1..e3875e3af 100644 --- a/src/conf.c +++ b/src/conf.c @@ -96,8 +96,9 @@ print_error(const char *msg, const char *input) } static int -parse_key_value(char *str, size_t len, char **end) +parse_key_value(char *str, char **end) { + size_t len = strlen(str); size_t i; int value; key_parser_state_t state; @@ -166,7 +167,7 @@ static int parse_key_definition(char *str) { char buf[MAX_LINE_LENGTH]; - char *p, *end; + char *p; size_t len = strlen(str), i; int j,key; int keys[MAX_COMMAND_KEYS]; @@ -190,8 +191,7 @@ parse_key_definition(char *str) /* get the value part */ memset(buf, 0, MAX_LINE_LENGTH); g_strlcpy(buf, str+i, MAX_LINE_LENGTH); - len = strlen(buf); - if (len == 0) { + if (*buf == 0) { print_error(_("Incomplete key definition"), str); return -1; } @@ -199,16 +199,13 @@ parse_key_definition(char *str) /* parse key values */ i = 0; key = 0; - len = strlen(buf); p = buf; - end = buf+len; memset(keys, 0, sizeof(int)*MAX_COMMAND_KEYS); - while (i < MAX_COMMAND_KEYS && p < end && - (key = parse_key_value(p, len + 1, &p)) >= 0) { + while (i < MAX_COMMAND_KEYS && *p != 0 && + (key = parse_key_value(p, &p)) >= 0) { keys[i++] = key; - while (p < end && (*p==',' || *p==' ' || *p=='\t')) + while (*p==',' || *p==' ' || *p=='\t') p++; - len = strlen(p); } if (key < 0) { |