aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-22 10:39:01 +0200
committerMax Kellermann <max@duempel.org>2008-09-22 10:39:01 +0200
commita8c896dcc90efbad043d28d18bd4dad1403fcabd (patch)
tree3dd1adca3bc8861b169ab0c91de0a76714d70ec7 /src
parent7a2cf03579fc97563a338be183297da1dca4b9f8 (diff)
downloadmpd-a8c896dcc90efbad043d28d18bd4dad1403fcabd.tar.gz
mpd-a8c896dcc90efbad043d28d18bd4dad1403fcabd.tar.xz
mpd-a8c896dcc90efbad043d28d18bd4dad1403fcabd.zip
options: added constant option_table_size
Instead of checking for the sentinel at the end of the option table, check the option_table_size constant.
Diffstat (limited to 'src')
-rw-r--r--src/options.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/options.c b/src/options.c
index 2c8182795..dc0475c4d 100644
--- a/src/options.c
+++ b/src/options.c
@@ -66,21 +66,20 @@ static const arg_opt_t option_table[] = {
{ 'K', "dump-keys", NULL, "Dump key bindings to stdout" },
{ 'D', "debug", NULL, "Enable debug output on stderr" },
#endif
- { 0, NULL, NULL, NULL },
};
+static const unsigned option_table_size = sizeof(option_table) / sizeof(option_table[0]);
+
static const arg_opt_t *
lookup_option(int s, char *l)
{
- int i;
+ unsigned i;
- i=0;
- while (option_table[i].descrition) {
+ for (i = 0; i < option_table_size; ++i) {
if (l && strcmp(l, option_table[i].longopt) == 0)
return &option_table[i];;
if (s && s == option_table[i].shortopt)
return &option_table[i];;
- i++;
}
return NULL;
@@ -113,10 +112,11 @@ option_error(int error, const char *option, const char *arg)
static void
display_help(void)
{
- int i = 0;
+ unsigned i;
printf("Usage: %s [OPTION]...\n", PACKAGE);
- while (option_table[i].descrition) {
+
+ for (i = 0; i < option_table_size; ++i) {
char tmp[MAX_LONGOPT_LENGTH];
if (option_table[i].argument)