From dd344b43e87ef5a24a4ba739821998605e38a015 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Nov 2013 13:00:15 +0100 Subject: Enable -Wshadow This one really did bite me hard (see previous commit), so enable it by default. Fix some cases of shadowing throughout the codebase. None of these change behavior, and all of these were correct code, and just tripped up the warning. --- configure | 4 ++-- demux/demux_lavf.c | 2 +- mpvcore/input/input.c | 4 ++-- stream/rar.c | 6 +++--- video/filter/vf_vavpp.c | 4 ++-- video/filter/vf_yadif.c | 12 ++++++------ video/out/vo_vdpau.c | 1 - 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 40d15d82d5..a15e08bca5 100755 --- a/configure +++ b/configure @@ -1153,14 +1153,14 @@ if test -z "$CFLAGS" ; then WARNFLAGS="-wd167 -wd556 -wd144" elif test "$cc_vendor" = "clang"; then CFLAGS="$_opt $_debug $_pipe" - WARNFLAGS="-Wall -Wno-switch -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes" + WARNFLAGS="-Wall -Wno-switch -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes -Wshadow" ERRORFLAGS="-Werror=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function" elif test "$cc_vendor" != "gnu" ; then CFLAGS="$_opt $_debug $_pipe" else CFLAGS="$_opt $_debug $_pipe" WARNFLAGS="-Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls" - ERRORFLAGS="-Werror-implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function" + ERRORFLAGS="-Werror-implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function -Wshadow" extra_ldflags="$extra_ldflags" fi else diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 9b8881fc8a..e80db5aed4 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -649,7 +649,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) t = av_dict_get(c->metadata, "title", NULL, 0); demuxer_add_chapter(demuxer, t ? bstr0(t->value) : bstr0(NULL), start, end, i); - AVDictionaryEntry *t = NULL; + t = NULL; while ((t = av_dict_get(c->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) { demuxer_add_chapter_info(demuxer, i, bstr0(t->key), bstr0(t->value)); diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c index 0f7c0f6b4a..e9c628dedb 100644 --- a/mpvcore/input/input.c +++ b/mpvcore/input/input.c @@ -1407,10 +1407,10 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, static void update_mouse_section(struct input_ctx *ictx) { - struct cmd_bind *cmd = + struct cmd_bind *bind = find_any_bind_for_key(ictx, NULL, 1, (int[]){MP_KEY_MOUSE_MOVE}); - char *new_section = cmd ? cmd->owner->section : "default"; + char *new_section = bind ? bind->owner->section : "default"; char *old = ictx->mouse_section; ictx->mouse_section = new_section; diff --git a/stream/rar.c b/stream/rar.c index fd4dbf008d..4147a86866 100644 --- a/stream/rar.c +++ b/stream/rar.c @@ -188,12 +188,12 @@ static int SkipFile(struct stream *s, int *count, rar_file_t ***file, const int name_offset = (hdr->flags & RAR_BLOCK_FILE_HAS_HIGH) ? (7+33) : (7+25); if (name_offset + name_size <= hdr->size) { const int max_size = name_offset + name_size; - bstr data = stream_peek(s, max_size); - if (data.len < max_size) { + bstr namedata = stream_peek(s, max_size); + if (namedata.len < max_size) { free(name); return -1; } - memcpy(name, &data.start[name_offset], name_size); + memcpy(name, &namedata.start[name_offset], name_size); } rar_file_t *current = NULL; diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 62dd9a77a0..f9f77a1b64 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -342,8 +342,8 @@ static bool initialize(struct vf_priv_s *p) if (!num) continue; VAProcDeinterlacingType algorithm = VAProcDeinterlacingBob; - for (int i=0; i>1;\ - CHECK(-1) CHECK(-2) }} }} - CHECK( 1) CHECK( 2) }} }} + CHECK(0, -1) CHECK(1, -2) }} }} + CHECK(0, 1) CHECK(1, 2) }} }} if(p->mode<2){ int b= (prev2[-2*refs] + next2[-2*refs])>>1; diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 2140bde948..fd6f87edb9 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -1356,7 +1356,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) return; surface = (VdpVideoSurface)(intptr_t)reserved_mpi->planes[3]; if (handle_preemption(vo) >= 0) { - VdpStatus vdp_st; const void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]}; if (vc->image_format == IMGFMT_NV12) -- cgit v1.2.3