From: Thomas Jansen Date: Thu, 29 Oct 2009 20:21:33 +0000 (+0100) Subject: command, conf: simplify variable initialization X-Git-Tag: release-0.16~50 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f82d8b4b2bbd0ca0d1e5ae8432e48596569d01e0;p=ncmpc.git command, conf: simplify variable initialization --- diff --git a/src/command.c b/src/command.c index 6b90e56..d8af856 100644 --- a/src/command.c +++ b/src/command.c @@ -321,9 +321,8 @@ key2str(int key) void command_dump_keys(void) { - int i; + int i = 0; - i = 0; while (cmds[i].description) { if (cmds[i].command != CMD_NONE) printf(" %20s : %s\n", get_key_names(cmds[i].command,1),cmds[i].name); @@ -336,9 +335,8 @@ command_dump_keys(void) static int set_key_flags(command_definition_t *cp, command_t command, int flags) { - int i; + int i = 0; - i = 0; while (cp[i].name) { if (cp[i].command == command) { cp[i].flags |= flags; @@ -355,9 +353,8 @@ set_key_flags(command_definition_t *cp, command_t command, int flags) const char * get_key_names(command_t command, int all) { - int i; + int i = 0; - i=0; while (cmds[i].description) { if (cmds[i].command == command) { int j; @@ -382,9 +379,8 @@ get_key_names(command_t command, int all) const char * get_key_description(command_t command) { - int i; + int i = 0; - i=0; while (cmds[i].description) { if (cmds[i].command == command) return _(cmds[i].description); @@ -397,9 +393,8 @@ get_key_description(command_t command) const char * get_key_command_name(command_t command) { - int i; + int i = 0; - i=0; while (cmds[i].name) { if (cmds[i].command == command) return cmds[i].name; @@ -411,9 +406,8 @@ get_key_command_name(command_t command) command_t get_key_command_from_name(char *name) { - int i; + int i = 0; - i=0; while (cmds[i].name) { if (strcmp(name, cmds[i].name) == 0) return cmds[i].command; @@ -426,9 +420,8 @@ get_key_command_from_name(char *name) command_t find_key_command(int key, command_definition_t *c) { - int i; + int i = 0; - i=0; while (key && c && c[i].name) { if (c[i].keys[0] == key || c[i].keys[1] == key || @@ -466,9 +459,8 @@ get_keyboard_command(void) int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]) { - int i; + int i = 0; - i=0; while (cmds[i].name) { if (cmds[i].command == command) { memcpy(cmds[i].keys, keys, sizeof(int)*MAX_COMMAND_KEYS); @@ -487,19 +479,18 @@ assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]) int check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize) { - int i; + int i = 0; int retval = 0; if (cp == NULL) cp = cmds; - i=0; while (cp[i].name) { cp[i].flags &= ~COMMAND_KEY_CONFLICT; i++; } - i=0; + i = 0; while (cp[i].name) { int j; command_t cmd; @@ -533,12 +524,11 @@ check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize) int write_key_bindings(FILE *f, int flags) { - int i,j; + int i = 0, j; if (flags & KEYDEF_WRITE_HEADER) fprintf(f, "## Key bindings for ncmpc (generated by ncmpc)\n\n"); - i = 0; while (cmds[i].name && !ferror(f)) { if (cmds[i].flags & COMMAND_KEY_MODIFIED || flags & KEYDEF_WRITE_ALL) { diff --git a/src/conf.c b/src/conf.c index 3ec37b8..9ff0b55 100644 --- a/src/conf.c +++ b/src/conf.c @@ -301,10 +301,8 @@ check_screen_list(char *value) { char **tmp = g_strsplit_set(value, " \t,", 100); char **screen = NULL; - int i,j; + int i = 0, j = 0; - i=0; - j=0; while( tmp && tmp[i] ) { char *name = g_ascii_strdown(tmp[i], -1); if (*name != '\0') { @@ -372,13 +370,12 @@ get_search_mode(char *value) static bool parse_line(char *line) { - size_t len = strlen(line), i = 0, j; + size_t len = strlen(line), i = 0, j = 0; char name[MAX_LINE_LENGTH]; char value[MAX_LINE_LENGTH]; bool match_found; /* get the name part */ - j = 0; while (i < len && line[i] != '=' && !g_ascii_isspace(line[i])) { name[j++] = line[i++];