All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: prevent compiler warning from cop2_{save,restore}
@ 2014-09-25  9:26 ` Paul Burton
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Burton @ 2014-09-25  9:26 UTC (permalink / raw)
  To: linux-mips; +Cc: Paul Burton

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>
---
 arch/mips/include/asm/cop2.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h
index 51f80bd..63b3468 100644
--- a/arch/mips/include/asm/cop2.h
+++ b/arch/mips/include/asm/cop2.h
@@ -37,15 +37,15 @@ extern void nlm_cop2_restore(struct nlm_cop2_state *);
 
 #define cop2_present		1
 #define cop2_lazy_restore	1
-#define cop2_save(r)		do { (r); } while (0)
-#define cop2_restore(r)		do { (r); } while (0)
+#define cop2_save(r)		do { (void)(r); } while (0)
+#define cop2_restore(r)		do { (void)(r); } while (0)
 
 #else
 
 #define cop2_present		0
 #define cop2_lazy_restore	0
-#define cop2_save(r)		do { (r); } while (0)
-#define cop2_restore(r)		do { (r); } while (0)
+#define cop2_save(r)		do { (void)(r); } while (0)
+#define cop2_restore(r)		do { (void)(r); } while (0)
 #endif
 
 enum cu2_ops {
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] MIPS: prevent compiler warning from cop2_{save,restore}
@ 2014-09-25  9:26 ` Paul Burton
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Burton @ 2014-09-25  9:26 UTC (permalink / raw)
  To: linux-mips; +Cc: Paul Burton

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>
---
 arch/mips/include/asm/cop2.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h
index 51f80bd..63b3468 100644
--- a/arch/mips/include/asm/cop2.h
+++ b/arch/mips/include/asm/cop2.h
@@ -37,15 +37,15 @@ extern void nlm_cop2_restore(struct nlm_cop2_state *);
 
 #define cop2_present		1
 #define cop2_lazy_restore	1
-#define cop2_save(r)		do { (r); } while (0)
-#define cop2_restore(r)		do { (r); } while (0)
+#define cop2_save(r)		do { (void)(r); } while (0)
+#define cop2_restore(r)		do { (void)(r); } while (0)
 
 #else
 
 #define cop2_present		0
 #define cop2_lazy_restore	0
-#define cop2_save(r)		do { (r); } while (0)
-#define cop2_restore(r)		do { (r); } while (0)
+#define cop2_save(r)		do { (void)(r); } while (0)
+#define cop2_restore(r)		do { (void)(r); } while (0)
 #endif
 
 enum cu2_ops {
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: prevent compiler warning from cop2_{save,restore}
  2014-09-25  9:26 ` Paul Burton
  (?)
@ 2014-09-25  9:42 ` Sergei Shtylyov
  -1 siblings, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2014-09-25  9:42 UTC (permalink / raw)
  To: Paul Burton, linux-mips

Hello.

On 9/25/2014 1:26 PM, Paul Burton wrote:

> 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>
> ---
>   arch/mips/include/asm/cop2.h | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

> diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h
> index 51f80bd..63b3468 100644
> --- a/arch/mips/include/asm/cop2.h
> +++ b/arch/mips/include/asm/cop2.h
> @@ -37,15 +37,15 @@ extern void nlm_cop2_restore(struct nlm_cop2_state *);
>
>   #define cop2_present		1
>   #define cop2_lazy_restore	1
> -#define cop2_save(r)		do { (r); } while (0)
> -#define cop2_restore(r)		do { (r); } while (0)
> +#define cop2_save(r)		do { (void)(r); } while (0)
> +#define cop2_restore(r)		do { (void)(r); } while (0)
>
>   #else
>
>   #define cop2_present		0
>   #define cop2_lazy_restore	0
> -#define cop2_save(r)		do { (r); } while (0)
> -#define cop2_restore(r)		do { (r); } while (0)
> +#define cop2_save(r)		do { (void)(r); } while (0)
> +#define cop2_restore(r)		do { (void)(r); } while (0)
>   #endif

    Looks like the definition are identical between 2 arms of #if, so why not 
move the macro definition out of #if, perhaps in later cleanup patch?

WBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-25  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25  9:26 [PATCH] MIPS: prevent compiler warning from cop2_{save,restore} Paul Burton
2014-09-25  9:26 ` Paul Burton
2014-09-25  9:42 ` Sergei Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.