Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Prevent compiler warning from cop2_{save,restore}

The no-op cases of cop2_save & cop2_restore lead to the following
warnings being emitted during build with recent versions of gcc (tested
using gcc 4.8.3 from the Mentor Sourcery CodeBench 2014.05 toolchain):

In file included from ./arch/mips/include/asm/switch_to.h:18:0,
from kernel/sched/core.c:78:
kernel/sched/core.c: In function 'finish_task_switch':
include/asm-generic/current.h:6:45: warning: value computed is not used [-Wunused-value]
#define get_current() (current_thread_info()->task)
^
./arch/mips/include/asm/cop2.h:48:32: note: in definition of macro 'cop2_restore'
#define cop2_restore(r) do { (r); } while (0)
^
include/asm-generic/current.h:7:17: note: in expansion of macro 'get_current'
#define current get_current()
^
./arch/mips/include/asm/switch_to.h:114:16: note: in expansion of macro 'current'
cop2_restore(current); \
^
kernel/sched/core.c:2225:2: note: in expansion of macro 'finish_arch_switch'
finish_arch_switch(prev);
^

Avoid the warning by "using" the value by casting to void.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7880/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
b89f3068 39a59593

+4 -4
+4 -4
arch/mips/include/asm/cop2.h
··· 37 37 38 38 #define cop2_present 1 39 39 #define cop2_lazy_restore 1 40 - #define cop2_save(r) do { (r); } while (0) 41 - #define cop2_restore(r) do { (r); } while (0) 40 + #define cop2_save(r) do { (void)(r); } while (0) 41 + #define cop2_restore(r) do { (void)(r); } while (0) 42 42 43 43 #else 44 44 45 45 #define cop2_present 0 46 46 #define cop2_lazy_restore 0 47 - #define cop2_save(r) do { (r); } while (0) 48 - #define cop2_restore(r) do { (r); } while (0) 47 + #define cop2_save(r) do { (void)(r); } while (0) 48 + #define cop2_restore(r) do { (void)(r); } while (0) 49 49 #endif 50 50 51 51 enum cu2_ops {