linux-mips
[Top] [All Lists]

Re: [PATCH 2/2] MIPS: math-emu: Declare ys variable as possibly unused

To: Aleksandar Markovic <Aleksandar.Markovic@mips.com>
Subject: Re: [PATCH 2/2] MIPS: math-emu: Declare ys variable as possibly unused
From: Mathieu Malaterre <malat@debian.org>
Date: Wed, 27 Dec 2017 09:40:54 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, Miodrag Dinic <Miodrag.Dinic@mips.com>, Goran Ferenc <goran.ferenc@imgtec.com>, James Hogan <jhogan@kernel.org>, Douglas Leung <douglas.leung@imgtec.com>, "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=kY0CCDF0+7jZ7gp8AxfY19C7flDOsOt4zCH2qhTzHWc=; b=gGC0gbKmla1lmpc9UMdazLAjzGF8esdCTcYoMef9k2bHfKrXHjXCAvOB8t9eUZe619 w/4m1xjcbC2tFWc+qJRy7WQrMGYFsH0lAzduT0eqx6pVGMjnLY1bxfteSrPJiGoAmr3y dP1JbrwJI4mPf7EGATzXJAqlmyjO/mHWkRZQEt3qIdu8K6CnNjs0oVmYiXnhCPaUC0No qIsimTS4ktuOy+ULAmkj8XFXievC8srWkpE9rliscFWQ6AP+wngLW3PRHiqJFn8EOmDJ JgwvDJne7vcG3v9TgG9MeHMV8KSLH+4gFUkgVMInrzZbC96v+Paj2VFg0k0dBQZVpL+Q aRbg==
In-reply-to: <BD3A5F1946F2E540A31AF2CE969BAEEEC28256@MIPSMAIL01.mipstec.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20171226104554.19612-1-malat@debian.org> <20171226104554.19612-2-malat@debian.org> <BD3A5F1946F2E540A31AF2CE969BAEEEC28256@MIPSMAIL01.mipstec.com>
Sender: linux-mips-bounce@linux-mips.org
Aleksandar,

On Tue, Dec 26, 2017 at 4:12 PM, Aleksandar Markovic
<Aleksandar.Markovic@mips.com> wrote:
>> Fix non-fatal warning:
>>
>> arch/mips/math-emu/sp_fdp.c: In function ‘ieee754sp_fdp’:
>> arch/mips/math-emu/ieee754int.h:60:31: warning: variable ‘ys’ set but not 
>> used [-Wunused-but-set-variable]
>>   unsigned int ym; int ye; int ys; int yc
>>                                ^
>> arch/mips/math-emu/sp_fdp.c:37:2: note: in expansion of macro ‘COMPYSP’
>>   COMPYSP;
>>   ^~~~~~~
>>
>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>> ---
>>  arch/mips/math-emu/ieee754int.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/math-emu/ieee754int.h 
>> b/arch/mips/math-emu/ieee754int.h
>> index 06ac0e2ac7ac..cb8f04cd24bf 100644
>> --- a/arch/mips/math-emu/ieee754int.h
>> +++ b/arch/mips/math-emu/ieee754int.h
>> @@ -57,7 +57,7 @@ static inline int ieee754_class_nan(int xc)
>>          unsigned int xm; int xe; int xs __maybe_unused; int xc
>>
>>  #define COMPYSP \
>> -       unsigned int ym; int ye; int ys; int yc
>> +       unsigned int ym; int ye; int ys __maybe_unused; int yc
>>
>>  #define COMPZSP \
>>          unsigned int zm; int ze; int zs; int zc
>
> This will silence the warning, but will do it for all future cases of unused
> ys too - in other words, it may well silence even useful, valid warnings.
> Also, this introduces an inconsistency among COMPXSP, COMPYSP, and COMPZSP
> macros.
>
> A better solution would be to reduce the scope of ys, so that it is always
> used, if declared. Instead of this code segment (in 
> arch/mips/math-emu/sp_fdp.c):
>
> union ieee754sp ieee754sp_fdp(union ieee754dp x)
> {
>         union ieee754sp y;
>         u32 rm;
>
>         COMPXDP;
>         COMPYSP;
>
>         EXPLODEXDP;
>
>         ieee754_clearcx();
>
>         FLUSHXDP;
>
>         switch (xc) {
>         case IEEE754_CLASS_SNAN:
>                 x = ieee754dp_nanxcpt(x);
>                 EXPLODEXDP;
>                 /* Fall through.  */
>         case IEEE754_CLASS_QNAN:
>                 y = ieee754sp_nan_fdp(xs, xm);
>                 if (!ieee754_csr.nan2008) {
>                         EXPLODEYSP;
>                         if (!ieee754_class_nan(yc))
>                                 y = ieee754sp_indef();
>                 }
>                 return y;
>
>
> ... should be the following: (COMPYSP is moved to a smaller code block)
>
> union ieee754sp ieee754sp_fdp(union ieee754dp x)
> {
>         union ieee754sp y;
>         u32 rm;
>
>         COMPXDP;
>
>         EXPLODEXDP;
>
>         ieee754_clearcx();
>
>         FLUSHXDP;
>
>         switch (xc) {
>         case IEEE754_CLASS_SNAN:
>                 x = ieee754dp_nanxcpt(x);
>                 EXPLODEXDP;
>                 /* Fall through.  */
>         case IEEE754_CLASS_QNAN:
>                 {
>                         COMPYSP;
>
>                         y = ieee754sp_nan_fdp(xs, xm);
>                         if (!ieee754_csr.nan2008) {
>                                 EXPLODEYSP;
>                                 if (!ieee754_class_nan(yc))
>                                         y = ieee754sp_indef();
>                         }
>                         return y;
>                 }
>


Thanks for the suggestion. However the sign bit is still not used, so
the warning is still there. Just for clarity did you see that:

 #define COMPXSP \
       unsigned int xm; int xe; int xs __maybe_unused; int xc

I'll try to give it some more thoughts, and come up with something
hopefully working.

-M

<Prev in Thread] Current Thread [Next in Thread>