* [PATCH] ide: avoid warning for timings calculation
@ 2017-05-11 12:52 Arnd Bergmann
2017-05-27 20:22 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-05-11 12:52 UTC (permalink / raw)
To: David S. Miller; +Cc: Arnd Bergmann, linux-ide, linux-kernel
gcc-7 warns about the result of a constant multiplication used as
a boolean:
drivers/ide/ide-timings.c: In function 'ide_timing_quantize':
drivers/ide/ide-timings.c:112:24: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
q->setup = EZ(t->setup * 1000, T);
This slightly rearranges the macro to simplify the code and avoid
the warning at the same time.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/ide/ide-timings.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/ide/ide-timings.c b/drivers/ide/ide-timings.c
index 0e05f75934c9..9da64c1de85c 100644
--- a/drivers/ide/ide-timings.c
+++ b/drivers/ide/ide-timings.c
@@ -104,19 +104,19 @@ u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
-#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
+#define EZ(v, unit) ((v) ? ENOUGH(v * 1000, unit) : 0)
static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
int T, int UT)
{
- q->setup = EZ(t->setup * 1000, T);
- q->act8b = EZ(t->act8b * 1000, T);
- q->rec8b = EZ(t->rec8b * 1000, T);
- q->cyc8b = EZ(t->cyc8b * 1000, T);
- q->active = EZ(t->active * 1000, T);
- q->recover = EZ(t->recover * 1000, T);
- q->cycle = EZ(t->cycle * 1000, T);
- q->udma = EZ(t->udma * 1000, UT);
+ q->setup = EZ(t->setup, T);
+ q->act8b = EZ(t->act8b, T);
+ q->rec8b = EZ(t->rec8b, T);
+ q->cyc8b = EZ(t->cyc8b, T);
+ q->active = EZ(t->active, T);
+ q->recover = EZ(t->recover, T);
+ q->cycle = EZ(t->cycle, T);
+ q->udma = EZ(t->udma, UT);
}
void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ide: avoid warning for timings calculation
2017-05-11 12:52 [PATCH] ide: avoid warning for timings calculation Arnd Bergmann
@ 2017-05-27 20:22 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-05-27 20:22 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: David S. Miller, linux-ide, linux-kernel
On Thu, May 11, 2017 at 3:52 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc-7 warns about the result of a constant multiplication used as
> a boolean:
>
> drivers/ide/ide-timings.c: In function 'ide_timing_quantize':
> drivers/ide/ide-timings.c:112:24: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> q->setup = EZ(t->setup * 1000, T);
>
> This slightly rearranges the macro to simplify the code and avoid
> the warning at the same time.
> #define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
> -#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
> +#define EZ(v, unit) ((v) ? ENOUGH(v * 1000, unit) : 0)
Perhaps
v -> (v) in the multiplication.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-27 20:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-11 12:52 [PATCH] ide: avoid warning for timings calculation Arnd Bergmann
2017-05-27 20:22 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).