[PATCH] Makefiles: Disable unused-variable warning (was: Re: [PATCH1/6] memcg: fix unused variable warning)

From: Michal Hocko
Date: Tue Dec 27 2011 - 08:58:01 EST


On Sat 24-12-11 05:00:14, Kirill A. Shutemov wrote:
> From: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx>
>
> mm/memcontrol.c: In function âmemcg_check_eventsâ:
> mm/memcontrol.c:784:22: warning: unused variable âdo_numainfoâ [-Wunused-variable]
>
> Signed-off-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
> ---
> mm/memcontrol.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d643bd6..a5e92bd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -781,14 +781,15 @@ static void memcg_check_events(struct mem_cgroup *memcg, struct page *page)
> /* threshold event is triggered in finer grain than soft limit */
> if (unlikely(mem_cgroup_event_ratelimit(memcg,
> MEM_CGROUP_TARGET_THRESH))) {
> - bool do_softlimit, do_numainfo;
> + bool do_softlimit;
>
> - do_softlimit = mem_cgroup_event_ratelimit(memcg,
> - MEM_CGROUP_TARGET_SOFTLIMIT);
> #if MAX_NUMNODES > 1
> + bool do_numainfo;
> do_numainfo = mem_cgroup_event_ratelimit(memcg,
> MEM_CGROUP_TARGET_NUMAINFO);
> #endif
> + do_softlimit = mem_cgroup_event_ratelimit(memcg,
> + MEM_CGROUP_TARGET_SOFTLIMIT);

I don't like this very much. Maybe we should get rid of both do_* and
do it with flags? But maybe it is not worth the additional code at
all...

Anyway, I am wondering why unused-but-set-variable is disabled while
unused-variable is enabled. Shouldn't we just disable it as well rather
than workaround this in the code? The warning is just pure noise in this
case.
What about something like:
---