From: Max Kellermann Date: Mon, 15 Sep 2008 10:27:29 +0000 (+0200) Subject: fixed mixed declaration + code X-Git-Tag: v0.12_alpha1~315 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b;p=ncmpc.git fixed mixed declaration + code Although they are allowedd in C99, try to avoid them. Move variable declarations to the top of the current scope. --- diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 8943d4f..2c770ff 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -71,6 +71,8 @@ static int store_lyr_hd(void) char title[512]; static char path[1024]; FILE *lyr_file; + int i; + char line_buf[1024]; get_text_line(&lyr_text, 0, artist, 512); get_text_line(&lyr_text, 1, title, 512); @@ -83,9 +85,6 @@ static int store_lyr_hd(void) if (lyr_file == NULL) return -1; - int i; - char line_buf[1024]; - for (i = 3; i <= lyr_text.text->len; i++) { if(get_text_line(&lyr_text, i, line_buf, 1024) == -1); fputs(line_buf, lyr_file); @@ -106,6 +105,9 @@ static gpointer get_lyr(void *c) { mpd_Status *status = ((retrieval_spec*)c)->client->status; mpd_Song *cur = ((retrieval_spec*)c)->client->song; + char artist[MAX_SONGNAME_LENGTH]; + char title[MAX_SONGNAME_LENGTH]; + //mpdclient_update((mpdclient_t*)c); if(!(IS_PAUSED(status->state)||IS_PLAYING(status->state))) { @@ -114,8 +116,6 @@ static gpointer get_lyr(void *c) } - char artist[MAX_SONGNAME_LENGTH]; - char title[MAX_SONGNAME_LENGTH]; lock=2; result = 0; @@ -160,8 +160,8 @@ list_callback(int idx, int *highlight, void *data) if ((idx == lyr_text.lines->len && lyr_text.lines->len > 4) || ((lyr_text.lines->len == 0 || lyr_text.lines->len == 4) && idx == 0)) { - *highlight=3; src_lyr* selected = g_array_index(src_lyr_stack, src_lyr*, src_selection); + *highlight=3; if (selected != NULL) return selected->description; return ""; diff --git a/src/screen_search.c b/src/screen_search.c index 982fe34..dd2353c 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -247,8 +247,6 @@ search_advanced_query(char *query, mpdclient_t *c) i=0; j=0; while (strv[i] && strlen(strv[i]) > 0 && i < 9) { - D("strv[%d] = \"%s\"\n", i, strv[i]); - int id = search_get_tag_id(strv[i]); if (id == -1) { if (table[j]) { @@ -281,6 +279,9 @@ search_advanced_query(char *query, mpdclient_t *c) if (advanced_search_mode && j > 0) { + int iter; + mpd_InfoEntity *entity; + /*----------------------------------------------------------------------- * NOTE (again): This code exists to test a new search ui, * Its ugly and MUST be redesigned before the next release! @@ -290,7 +291,6 @@ search_advanced_query(char *query, mpdclient_t *c) /** stupid - but this is just a test...... (fulhack) */ mpd_startSearch(c->connection, FALSE); - int iter; for(iter = 0; iter < 10; iter++) { mpd_addConstraintSearch(c->connection, table[iter], arg[iter]); } @@ -299,8 +299,6 @@ search_advanced_query(char *query, mpdclient_t *c) fl = g_malloc0(sizeof(mpdclient_filelist_t)); - mpd_InfoEntity *entity; - while ((entity=mpd_getNextInfoEntity(c->connection))) { filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); diff --git a/src/src_lyrics.c b/src/src_lyrics.c index 4d41aea..448c301 100644 --- a/src/src_lyrics.c +++ b/src/src_lyrics.c @@ -28,10 +28,12 @@ int get_text_line(formed_text *text, int num, char *dest, int len) { + int linelen; + memset(dest, '\0', len*sizeof(char)); if (num >= text->lines->len - 1) return -1; - int linelen; + if (num == 0) { linelen = g_array_index(text->lines, int, num); memcpy(dest, text->text->str, linelen*sizeof(char)); @@ -128,9 +130,10 @@ void src_lyr_stack_init(void) int src_lyr_init(void) { + int i = 0; + src_lyr_stack_init (); - int i = 0; while (g_array_index (src_lyr_stack, src_lyr*, i) != NULL) { src_lyr *i_stack; i_stack = g_array_index (src_lyr_stack, src_lyr*, i); @@ -150,12 +153,14 @@ int get_lyr_by_src (int priority, char *artist, char *title) static int src_lyr_load_plugin_file(const char *file) { GString *path; + src_lyr *new_src; + src_lyr_plugin_register register_func; + path = g_string_new (PLUGIN_DIR_SYSTEM); g_string_append (path, "/"); g_string_append (path, file); - src_lyr_plugin_register register_func; - src_lyr *new_src = malloc (sizeof (src_lyr)); + new_src = malloc(sizeof(src_lyr)); new_src->module = g_module_open (path->str, G_MODULE_BIND_LAZY); if (!g_module_symbol (new_src->module, "register_me", (gpointer*) ®ister_func)) return -1; @@ -178,13 +183,13 @@ static void src_lyr_plugins_load_from_dir(GDir *plugin_dir) static int src_lyr_plugins_load(void) { GDir *plugin_dir; + GString *user_dir_path; plugin_dir = g_dir_open (PLUGIN_DIR_SYSTEM, 0, NULL); if (plugin_dir == NULL) return -1; src_lyr_plugins_load_from_dir (plugin_dir); - GString *user_dir_path; user_dir_path = g_string_new (g_get_home_dir()); g_string_append (user_dir_path, PLUGIN_DIR_USER);