From: Andre Noll Date: Sat, 29 Nov 2008 21:20:47 +0000 (+0100) Subject: Fix -Wdeclaration-after-statement warnings. X-Git-Tag: v0.3.3~8 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=97e3deb06e0dd2e63520c2dc0736e753e1276fde;p=paraslash.git Fix -Wdeclaration-after-statement warnings. This option is new in gcc-4, so do not activate it by default. --- diff --git a/Makefile.in b/Makefile.in index 05af6da8..3831e1c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -23,6 +23,7 @@ DEBUG_CPPFLAGS += -Wredundant-decls # invalid option for gcc-3.3.3 # DEBUG_CPPFLAGS += -Wextra # DEBUG_CPPFLAGS += -Wold-style-definition +# DEBUG_CPPFLAGS += -Wdeclaration-after-statement # many warnings about trivial stuff # CPPFLAGS += -Wconversion diff --git a/aacdec.c b/aacdec.c index 235b292d..4c256946 100644 --- a/aacdec.c +++ b/aacdec.c @@ -157,9 +157,9 @@ out: static void aacdec_open(struct filter_node *fn) { - fn->private_data = para_calloc(sizeof(struct private_aacdec_data)); - struct private_aacdec_data *padd = fn->private_data; + struct private_aacdec_data *padd = para_calloc(sizeof(*padd)); + fn->private_data = padd; fn->bufsize = AAC_OUTBUF_SIZE; fn->buf = para_calloc(fn->bufsize); padd->handle = aac_open(); diff --git a/aft.c b/aft.c index 2d40c235..90989284 100644 --- a/aft.c +++ b/aft.c @@ -588,8 +588,6 @@ int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi) static int save_afd(struct audio_file_data *afd) { size_t size = sizeof(*afd) + sizeof_chunk_table(&afd->afhi); - - PARA_DEBUG_LOG("size: %zu\n", size); int shmid, ret = shm_new(size); void *shm_afd; char *buf; @@ -1599,6 +1597,7 @@ static void com_add_callback(int fd, const struct osl_object *query) struct afs_info default_afsi = {.last_played = 0}; struct para_buffer msg = {.max_size = SHMMAX, .max_size_handler = pass_buffer_as_shm, .private_data = &fd}; + uint16_t afhi_offset, chunks_offset; hash = (HASH_TYPE *)buf + CAB_HASH_OFFSET; hash_to_asc(hash, asc);; @@ -1653,8 +1652,8 @@ static void com_add_callback(int fd, const struct osl_object *query) goto out; } /* no hs or force mode, child must have sent afhi */ - uint16_t afhi_offset = read_u16(buf + CAB_AFHI_OFFSET_POS); - uint16_t chunks_offset = read_u16(buf + CAB_CHUNKS_OFFSET_POS); + afhi_offset = read_u16(buf + CAB_AFHI_OFFSET_POS); + chunks_offset = read_u16(buf + CAB_CHUNKS_OFFSET_POS); objs[AFTCOL_AFHI].data = buf + afhi_offset; objs[AFTCOL_AFHI].size = chunks_offset - afhi_offset; @@ -2304,10 +2303,6 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) }; int ret; char *source_path = (char *)query->data + sizeof(cad.flags); - - ret = get_afsi_of_path(source_path, &cad.source_afsi); - if (ret < 0) - goto out; struct pattern_match_data pmd = { .table = audio_file_table, .loop_col_num = AFTCOL_HASH, @@ -2318,6 +2313,10 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) .data = &cad, .action = copy_selector_info }; + + ret = get_afsi_of_path(source_path, &cad.source_afsi); + if (ret < 0) + goto out; ret = for_each_matching_row(&pmd); out: if (ret < 0) diff --git a/alsa_write.c b/alsa_write.c index cfae4fb9..89d1995c 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -212,10 +212,12 @@ static void alsa_close(struct writer_node *wn) __malloc static void *alsa_parse_config(const char *options) { + int ret; struct alsa_write_args_info *conf = para_calloc(sizeof(struct alsa_write_args_info)); + PARA_INFO_LOG("options: %s, %zd\n", options, strcspn(options, " \t")); - int ret = alsa_cmdline_parser_string(options, conf, "alsa_write"); + ret = alsa_cmdline_parser_string(options, conf, "alsa_write"); if (ret) goto err_out; PARA_INFO_LOG("help given: %d\n", conf->help_given); diff --git a/attribute.c b/attribute.c index e7fba902..24a3826d 100644 --- a/attribute.c +++ b/attribute.c @@ -301,9 +301,9 @@ static void com_addatt_callback(int fd, const struct osl_object *query) struct osl_object objs[NUM_ATT_COLUMNS]; struct osl_row *row; unsigned char bitnum; - len = strlen(p); struct addatt_event_data aed; + len = strlen(p); if (!len || p[len - 1] == '-' || p[len - 1] == '+') { ret2 = para_printf(&pb, "invalid attribute name: %s\n", p); if (ret2 < 0) diff --git a/file_write.c b/file_write.c index d7cea2f9..839515f8 100644 --- a/file_write.c +++ b/file_write.c @@ -95,10 +95,10 @@ static void file_write_close(struct writer_node *wn) __malloc static void *file_write_parse_config(const char *options) { - PARA_INFO_LOG("options: %s\n", options); struct file_write_args_info *conf = para_calloc(sizeof(struct file_write_args_info)); int ret = file_cmdline_parser_string(options, conf, "file_write"); + PARA_INFO_LOG("conf->filename_given: %d\n", conf->filename_given); if (!ret) return conf; diff --git a/mp3dec.c b/mp3dec.c index 615a0640..0006a181 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -108,9 +108,9 @@ static void mp3dec_close(struct filter_node *fn) static void mp3dec_open(struct filter_node *fn) { - fn->private_data = para_calloc(sizeof(struct private_mp3dec_data)); - struct private_mp3dec_data *pmd = fn->private_data; + struct private_mp3dec_data *pmd = para_calloc(sizeof(*pmd)); + fn->private_data = pmd; mad_stream_init(&pmd->stream); mad_frame_init(&pmd->frame); mad_synth_init(&pmd->synth); diff --git a/osl.c b/osl.c index f06d4ba3..2aee5b6a 100644 --- a/osl.c +++ b/osl.c @@ -31,8 +31,9 @@ */ int para_lseek(int fd, off_t *offset, int whence) { - *offset = lseek(fd, *offset, whence); int ret = -E_LSEEK; + + *offset = lseek(fd, *offset, whence); if (*offset == -1) return ret; return 1; @@ -1447,8 +1448,10 @@ int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects, goto out; rollback: /* rollback all changes made, ignore further errors */ for (i--; i >= 0; i--) { + enum osl_storage_type st; + cd = get_column_description(t->desc, i); - enum osl_storage_type st = cd->storage_type; + st = cd->storage_type; if (st == OSL_NO_STORAGE) continue; diff --git a/rbtree.c b/rbtree.c index 5d24aeb5..95bcee39 100644 --- a/rbtree.c +++ b/rbtree.c @@ -438,9 +438,9 @@ struct rb_node *rb_nth(struct rb_node *node, unsigned n) */ int rb_rank(struct rb_node *node, unsigned *rank) { - *rank = 1; struct rb_node *parent; + *rank = 1; if (!node) return -1; if (node->rb_left) diff --git a/string.c b/string.c index 752fb8f9..d23e43c1 100644 --- a/string.c +++ b/string.c @@ -59,9 +59,10 @@ __must_check __malloc void *para_realloc(void *p, size_t size) */ __must_check __malloc void *para_malloc(size_t size) { - assert(size); - void *p = malloc(size); + void *p; + assert(size); + p = malloc(size); if (!p) { PARA_EMERG_LOG("malloc failed (size = %zu), aborting\n", size);