* Re: Lots of new warnings with gcc-7.1.1
From: Linus Torvalds @ 2017-07-12 3:41 UTC (permalink / raw)
To: Guenter Roeck
Cc: Tejun Heo, Jean Delvare, Bartlomiej Zolnierkiewicz,
Sathya Prakash, James E.J. Bottomley, Greg Kroah-Hartman,
the arch/x86 maintainers, xen-devel, linux-block,
Linux Media Mailing List, IDE-ML, linux-fbdev@vger.kernel.org,
Network Development
In-Reply-To: <CA+55aFyKpezj3oHwtBShyf9x-DJNAGQhrq55iVGM42eWKQtP3w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]
On Tue, Jul 11, 2017 at 8:17 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> If that's the case, I'd prefer just turning off the format-truncation
> (but not overflow) warning with '-Wno-format-trunction".
Doing
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
in the main Makefile certainly cuts down on the warnings.
We still have some overflow warnings, including the crazy one where
gcc doesn't see that the number of max7315 boards is very limited.
But those could easily be converted to just snprintf() instead, and
then the truncation warning disabling takes care of it. Maybe that's
the right answer.
We also have about a bazillion
warning: ‘*’ in boolean context, suggest ‘&&’ instead
warnings in drivers/ata/libata-core.c, all due to a single macro that
uses a pattern that gcc-7.1.1 doesn't like. The warning looks a bit
debatable, but I suspect the macro could easily be changed too.
Tejun, would you hate just moving the "multiply by 1000" part _into_
that EZ() macro? Something like the attached (UNTESTED!) patch?
Linus
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 1404 bytes --]
drivers/ata/libata-core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 8453f9a4682f..4c7d5a138495 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3231,19 +3231,19 @@ static const struct ata_timing ata_timing[] = {
};
#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 ata_timing_quantize(const struct ata_timing *t, struct ata_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->dmack_hold = EZ(t->dmack_hold * 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->dmack_hold = EZ(t->dmack_hold, T);
+ q->cycle = EZ(t->cycle, T);
+ q->udma = EZ(t->udma, UT);
}
void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
^ permalink raw reply related
* Re: Lots of new warnings with gcc-7.1.1
From: Jakub Kicinski @ 2017-07-12 4:19 UTC (permalink / raw)
To: Linus Torvalds
Cc: Tejun Heo, Jean Delvare, Guenter Roeck, Bartlomiej Zolnierkiewicz,
Sathya Prakash, James E.J. Bottomley, Greg Kroah-Hartman,
the arch/x86 maintainers, xen-devel, linux-block,
Linux Media Mailing List, IDE-ML, linux-fbdev@vger.kernel.org,
Network Development
In-Reply-To: <CA+55aFzXz-PxKSJP=hfHD+mfCX4M6+HMacWMkDz7KB8-3y55qw@mail.gmail.com>
On Tue, 11 Jul 2017 15:35:15 -0700, Linus Torvalds wrote:
> I do suspect I'll make "-Wformat-truncation" (as opposed to
> "-Wformat-overflow") be a "V=1" kind of warning. But let's see how
> many of these we can fix, ok?
Somehow related - what's the stand on -Wimplicit-fallthrough? I run
into the jump tables in jhash.h generating lots of warnings. Is it OK
to do this?
--->8------
diff --git a/include/linux/jhash.h b/include/linux/jhash.h
index 348c6f47e4cc..f6d6513a4c03 100644
--- a/include/linux/jhash.h
+++ b/include/linux/jhash.h
@@ -85,20 +85,19 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
k += 12;
}
/* Last block: affect all 32 bits of (c) */
- /* All the case statements fall through */
switch (length) {
- case 12: c += (u32)k[11]<<24;
- case 11: c += (u32)k[10]<<16;
- case 10: c += (u32)k[9]<<8;
- case 9: c += k[8];
- case 8: b += (u32)k[7]<<24;
- case 7: b += (u32)k[6]<<16;
- case 6: b += (u32)k[5]<<8;
- case 5: b += k[4];
- case 4: a += (u32)k[3]<<24;
- case 3: a += (u32)k[2]<<16;
- case 2: a += (u32)k[1]<<8;
- case 1: a += k[0];
+ case 12: c += (u32)k[11]<<24; /* fall through */
+ case 11: c += (u32)k[10]<<16; /* fall through */
+ case 10: c += (u32)k[9]<<8; /* fall through */
+ case 9: c += k[8]; /* fall through */
+ case 8: b += (u32)k[7]<<24; /* fall through */
+ case 7: b += (u32)k[6]<<16; /* fall through */
+ case 6: b += (u32)k[5]<<8; /* fall through */
+ case 5: b += k[4]; /* fall through */
+ case 4: a += (u32)k[3]<<24; /* fall through */
+ case 3: a += (u32)k[2]<<16; /* fall through */
+ case 2: a += (u32)k[1]<<8; /* fall through */
+ case 1: a += k[0]; /* fall through */
__jhash_final(a, b, c);
case 0: /* Nothing left to add */
break;
@@ -131,11 +130,11 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
k += 3;
}
- /* Handle the last 3 u32's: all the case statements fall through */
+ /* Handle the last 3 u32's */
switch (length) {
- case 3: c += k[2];
- case 2: b += k[1];
- case 1: a += k[0];
+ case 3: c += k[2]; /* fall through */
+ case 2: b += k[1]; /* fall through */
+ case 1: a += k[0]; /* fall through */
__jhash_final(a, b, c);
case 0: /* Nothing left to add */
break;
^ permalink raw reply related
* Re: Lots of new warnings with gcc-7.1.1
From: Mauro Carvalho Chehab @ 2017-07-12 12:37 UTC (permalink / raw)
To: Linus Torvalds
Cc: Tejun Heo, Jean Delvare, Guenter Roeck, Bartlomiej Zolnierkiewicz,
Sathya Prakash, James E.J. Bottomley, Greg Kroah-Hartman,
the arch/x86 maintainers, xen-devel, linux-block,
Linux Media Mailing List, IDE-ML, linux-fbdev@vger.kernel.org,
Network Development, Alan Cox
In-Reply-To: <CA+55aFzXz-PxKSJP=hfHD+mfCX4M6+HMacWMkDz7KB8-3y55qw@mail.gmail.com>
Em Tue, 11 Jul 2017 15:35:15 -0700
Linus Torvalds <torvalds@linux-foundation.org> escreveu:
> [ Very random list of maintainers and mailing lists, at least
> partially by number of warnings generated by gcc-7.1.1 that is then
> correlated with the get_maintainers script ]
Under drivers/media, I fixed a bunch of gcc 7.1 warnings before the
merge window. While most were just noise, some actually pointed to
human errors.
Now, gcc-7.1.1 produces only 6 warnings with W=1 on x86_64 (allyesconfig),
either due to unused-but-set-variable or unused-const-variable. I guess
both warning options are disabled by default. Anyway, I have patches
to fix them already. I'll send you later.
The atomisp staging driver is a completely different beast, with would
produce itself a huge amount of warnings. I ended by adding some
logic on drivers/staging/media/atomisp/ Makefiles to disable them:
ccflags-y += $(call cc-disable-warning, missing-declarations)
ccflags-y += $(call cc-disable-warning, missing-prototypes)
ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
ccflags-y += $(call cc-disable-warning, unused-const-variable)
ccflags-y += $(call cc-disable-warning, suggest-attribute=format)
ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
(there's actually one patch pending related to atomisp, that I'll also
be sending you soon - meant to avoid warnings if compiled with an older
gcc version)
Thanks,
Mauro
^ permalink raw reply
* Re: Lots of new warnings with gcc-7.1.1
From: Greg Kroah-Hartman @ 2017-07-12 13:10 UTC (permalink / raw)
To: Linus Torvalds, Arnd Bergmann
Cc: Tejun Heo, Jean Delvare, Guenter Roeck, Bartlomiej Zolnierkiewicz,
Sathya Prakash, James E.J. Bottomley, the arch/x86 maintainers,
xen-devel, linux-block, Linux Media Mailing List, IDE-ML,
linux-fbdev@vger.kernel.org, Network Development
In-Reply-To: <CA+55aFzXz-PxKSJP=hfHD+mfCX4M6+HMacWMkDz7KB8-3y55qw@mail.gmail.com>
On Tue, Jul 11, 2017 at 03:35:15PM -0700, Linus Torvalds wrote:
> [ Very random list of maintainers and mailing lists, at least
> partially by number of warnings generated by gcc-7.1.1 that is then
> correlated with the get_maintainers script ]
>
> So I upgraded one of my boxes to F26, which upgraded the compiler to gcc-7.1.1
>
> Which in turn means that my nice clean allmodconfig compile is not an
> unholy mess of annoying new warnings.
I asked Arnd about this the other day on IRC as I've hit this as well on
the stable releases, and it's really annoying. He mentioned that he had
lots of these warnings fixed, but didn't push most of the changes out
yet. Arnd, any repo with them in it that we could look at?
> Normally I hate the stupid new warnings, but this time around they are
> actually exactly the kinds of warnings you'd want to see and that are
> hard for humans to pick out errors: lots of format errors wrt limited
> buffer sizes.
>
> At the same time, many of them *are* annoying. We have various limited
> buffers that are limited for a good reason, and some of the format
> truncation warnings are about numbers in the range {0-MAX_INT], where
> we definitely know that we don't need to worry about the really big
> ones.
>
> After all, we're using "snprintf()" for a reason - we *want* to
> truncate if the buffer is too small.
Yeah, that's the warnings in the USB core code, we "know" this will not
happen, and we are using snprintf() for that reason as well, I don't
know how to fool gcc into the fact that it's all ok here.
> Anyway, it would be lovely if some of the more affected developers
> would take a look at gcc-7.1.1 warnings. Right now I get about three
> *thousand* lines of warnings from a "make allmodconfig" build, which
> makes them a bit overwhelming.
I only have 310 when building the 4.12.0 release with 7.1.1, I wonder if
Fedora turned more warnings on in their compiler release, I'm running
Arch here:
$ gcc --version
gcc (GCC) 7.1.1 20170621
thanks,
greg k-h
^ permalink raw reply
* Re: Lots of new warnings with gcc-7.1.1
From: Arnd Bergmann @ 2017-07-12 13:31 UTC (permalink / raw)
To: Linus Torvalds
Cc: Guenter Roeck, Tejun Heo, Jean Delvare, Bartlomiej Zolnierkiewicz,
Sathya Prakash, James E.J. Bottomley, Greg Kroah-Hartman,
the arch/x86 maintainers, xen-devel, linux-block,
Linux Media Mailing List, IDE-ML, linux-fbdev@vger.kernel.org,
Network Development
In-Reply-To: <CA+55aFx5mCk+nzDG+gGzDUqE4gzJVERL_oO+PN-PA6oKaUhCpg@mail.gmail.com>
On Wed, Jul 12, 2017 at 5:41 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> We also have about a bazillion
>
> warning: ‘*’ in boolean context, suggest ‘&&’ instead
>
> warnings in drivers/ata/libata-core.c, all due to a single macro that
> uses a pattern that gcc-7.1.1 doesn't like. The warning looks a bit
> debatable, but I suspect the macro could easily be changed too.
>
> Tejun, would you hate just moving the "multiply by 1000" part _into_
> that EZ() macro? Something like the attached (UNTESTED!) patch?
Tejun applied an almost identical patch of mine a while ago, but it seems to
have gotten lost in the meantime in some rebase:
https://patchwork.kernel.org/patch/9721397/
https://patchwork.kernel.org/patch/9721399/
I guess I should have resubmitted the second patch with the suggested
improvement.
Arnd
^ permalink raw reply
* Re: Lots of new warnings with gcc-7.1.1
From: Arnd Bergmann @ 2017-07-12 13:51 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Linus Torvalds, Tejun Heo, Jean Delvare, Guenter Roeck,
Bartlomiej Zolnierkiewicz, Sathya Prakash, James E.J. Bottomley,
the arch/x86 maintainers, xen-devel, linux-block,
Linux Media Mailing List, IDE-ML, linux-fbdev@vger.kernel.org,
Network Development
In-Reply-To: <20170712131010.GA13946@kroah.com>
On Wed, Jul 12, 2017 at 3:10 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Tue, Jul 11, 2017 at 03:35:15PM -0700, Linus Torvalds wrote:
>> [ Very random list of maintainers and mailing lists, at least
>> partially by number of warnings generated by gcc-7.1.1 that is then
>> correlated with the get_maintainers script ]
>>
>> So I upgraded one of my boxes to F26, which upgraded the compiler to gcc-7.1.1
>>
>> Which in turn means that my nice clean allmodconfig compile is not an
>> unholy mess of annoying new warnings.
>
> I asked Arnd about this the other day on IRC as I've hit this as well on
> the stable releases, and it's really annoying. He mentioned that he had
> lots of these warnings fixed, but didn't push most of the changes out
> yet.
To clarify: most of the patches I wrote ended up getting merged, but
there were a couple that I did not submit a second time after they
got dropped, but I gave up on trying to fix the new -Wformat warnings
and simply disabled them, hoping someone else would do it before me,
or that the gcc developers would find a way to reduce the false-positive
ones before the release.
> Arnd, any repo with them in it that we could look at?
I have a private tree on my workstation that has lots of random
crap, and I rebase it all the time but normally don't publish it.
I have uploaded today's snapshot to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git randconfig-4.13-next
The way I work with this is helpful to catch build regressions as soon
as they happen, but not so good in finding things that I have either
submitted a patch for before and don't remember if it should be
resubmitted, or stuff that I decided I didn't want to deal with at some
point.
I was already planning to start over from scratch one of these days,
and cherry-pick+resubmit the patches that are actually required
for randconfig builds.
>> Anyway, it would be lovely if some of the more affected developers
>> would take a look at gcc-7.1.1 warnings. Right now I get about three
>> *thousand* lines of warnings from a "make allmodconfig" build, which
>> makes them a bit overwhelming.
>
> I only have 310 when building the 4.12.0 release with 7.1.1, I wonder if
> Fedora turned more warnings on in their compiler release, I'm running
> Arch here:
> $ gcc --version
> gcc (GCC) 7.1.1 20170621
This is what I get in today's linux-next:
$ grep error: 4.13-next-allmod-warning | sed -e 's:^.*\[-W:-W:' | sort
| uniq -c | cut -f 1 -d\] | sort -n
1 -Werror=parentheses
2 -Werror=tautological-compare
2 -Werror=unused-result
34 -Werror=format-overflow=
41 -Werror=int-in-bool-context
233 -Werror=format-truncation=
I'll resubmit the patches for -Wparenthese, -Wtautological-compar,
-Wunused-result and -Wint-in-bool-context that I had sent earlier,
plus a new patch to move -Wformat-truncation into W=1.
Arnd
^ permalink raw reply
* [PATCH 00/14] gcc-7 warnings
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Tejun Heo, akpm, Linus Torvalds, Guenter Roeck, linux-media
This series should shut up all warnings introduced by gcc-6 or gcc-7 on
today's linux-next, as observed in "allmodconfig" builds on x86,
arm and arm64.
I have sent some of these before, but some others are new, as I had
at some point disabled the -Wint-in-bool-context warning in my
randconfig testing and did not notice the other warnings.
I have another series to address all -Wformat-overflow warnings,
and one more patch to turn off the -Wformat-truncation warnings
unless we build with "make W=1". I'll send that separately.
Most of these are consist of trivial refactoring of the code to
shut up false-positive warnings, the one exception being
"staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read",
which fixes a regression against linux-3.1 that has gone
unnoticed since then. Still, review from subsystem maintainers
would be appreciated.
I would suggest that Andrew Morton can pick these up into linux-mm
so we can make sure they all make it into the release. Alternatively
Linus might feel like picking them all up himself.
While I did not mark the harmless ones for stable backports,
Greg may also want to pick them up once they go upstream, to
help build-test the stable kernels with gcc-7.
Arnd
Arnd Bergmann (14):
[SUBMITTED 20170511] ide: avoid warning for timings calculation
[SUBMITTED 20170511] ata: avoid gcc-7 warning in ata_timing_quantize
[SUBMITTED 20170314] drm/vmwgfx: avoid gcc-7 parentheses warning
x86: math-emu: avoid -Wint-in-bool-context warning
isdn: isdnloop: suppress a gcc-7 warning
acpi: thermal: fix gcc-6/ccache warning
proc/kcore: hide a harmless warning
Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
SFI: fix tautological-compare warning
staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read
IB/uverbs: fix gcc-7 type warning
drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning
iopoll: avoid -Wint-in-bool-context warning
[media] fix warning on v4l2_subdev_call() result interpreted as bool
arch/x86/math-emu/fpu_emu.h | 2 +-
drivers/acpi/processor_thermal.c | 6 ++++--
drivers/ata/libata-core.c | 20 ++++++++++----------
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c | 6 +++---
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-
drivers/ide/ide-timings.c | 18 +++++++++---------
drivers/infiniband/core/uverbs.h | 14 ++++++++------
drivers/input/misc/adxl34x.c | 2 +-
drivers/isdn/isdnloop/isdnloop.c | 2 +-
drivers/media/pci/cx18/cx18-ioctl.c | 6 ++++--
drivers/media/pci/saa7146/mxb.c | 5 +++--
drivers/media/platform/atmel/atmel-isc.c | 4 ++--
drivers/media/platform/atmel/atmel-isi.c | 4 ++--
drivers/media/platform/blackfin/bfin_capture.c | 4 ++--
drivers/media/platform/omap3isp/ispccdc.c | 5 +++--
drivers/media/platform/pxa_camera.c | 3 ++-
drivers/media/platform/rcar-vin/rcar-core.c | 2 +-
drivers/media/platform/rcar-vin/rcar-dma.c | 4 +++-
drivers/media/platform/soc_camera/soc_camera.c | 4 ++--
drivers/media/platform/stm32/stm32-dcmi.c | 4 ++--
drivers/media/platform/ti-vpe/cal.c | 6 ++++--
drivers/sfi/sfi_core.c | 9 ++++++---
drivers/staging/iio/resolver/ad2s1210.c | 2 +-
.../staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 13 +++++++------
fs/proc/kcore.c | 10 ++++++----
include/linux/iopoll.h | 6 ++++--
include/linux/regmap.h | 2 +-
27 files changed, 93 insertions(+), 72 deletions(-)
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* [PATCH, RESEND 01/14] ide: avoid warning for timings calculation
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, David S. Miller
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Tejun Heo, akpm, Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
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..1858e3ce3993 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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH, RESEND 02/14] ata: avoid gcc-7 warning in ata_timing_quantize
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Tejun Heo
Cc: Damien Le Moal, Arnd Bergmann, Greg Kroah-Hartman, dri-devel,
linux-ide, Geert Uytterhoeven, Hannes Reinecke, Adam Manzanares,
akpm, Mauro Carvalho Chehab, Linus Torvalds, Guenter Roeck,
linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
gcc-7 warns about the result of a constant multiplication used as
a boolean:
drivers/ata/libata-core.c: In function 'ata_timing_quantize':
drivers/ata/libata-core.c:3164:30: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
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/ata/libata-core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index fa7dd4394c02..450059dd06ba 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3231,19 +3231,19 @@ static const struct ata_timing ata_timing[] = {
};
#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 ata_timing_quantize(const struct ata_timing *t, struct ata_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->dmack_hold = EZ(t->dmack_hold * 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->dmack_hold = EZ(t->dmack_hold, T);
+ q->cycle = EZ(t->cycle, T);
+ q->udma = EZ(t->udma, UT);
}
void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH, RESEND 03/14] drm/vmwgfx: avoid gcc-7 parentheses warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, VMware Graphics, Sinclair Yeh, Thomas Hellstrom,
David Airlie
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Brian Paul, Tejun Heo, akpm, Linus Torvalds, Guenter Roeck,
linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
gcc-7 warns about slightly suspicious code in vmw_cmd_invalid:
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c: In function 'vmw_cmd_invalid':
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:522:23: error: the omitted middle operand in ?: will always be 'true', suggest explicit middle operand [-Werror=parentheses]
The problem is that it is mixing boolean and integer values here.
I assume that the code actually works correctly, so making it use
a literal '1' instead of the implied 'true' makes it more readable
and avoids the warning.
The code has been in this file since the start, but it could
make sense to backport this patch to stable to make it build cleanly
with gcc-7.
Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Originally submitted on Nov 16, but for some reason it never appeared
upstream. The patch is still needed as of v4.11-rc2
---
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index c7b53d987f06..3f343e55972a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -519,7 +519,7 @@ static int vmw_cmd_invalid(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header)
{
- return capable(CAP_SYS_ADMIN) ? : -EINVAL;
+ return capable(CAP_SYS_ADMIN) ? 1 : -EINVAL;
}
static int vmw_cmd_ok(struct vmw_private *dev_priv,
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 04/14] x86: math-emu: avoid -Wint-in-bool-context warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Bill Metzenthen, x86
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Ingo Molnar, H. Peter Anvin, Tejun Heo, akpm, Linus Torvalds,
Thomas Gleixner, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
The setsign() macro gets called with an integer argument in a
few places, leading to a harmless warning in gcc-7:
arch/x86/math-emu/reg_add_sub.c: In function 'FPU_add':
arch/x86/math-emu/reg_add_sub.c:80:48: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context]
This turns the integer into a boolean expression by comparing it
to zero.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/x86/math-emu/fpu_emu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/math-emu/fpu_emu.h b/arch/x86/math-emu/fpu_emu.h
index afbc4d805d66..c9c320dccca1 100644
--- a/arch/x86/math-emu/fpu_emu.h
+++ b/arch/x86/math-emu/fpu_emu.h
@@ -157,7 +157,7 @@ extern u_char const data_sizes_16[32];
#define signbyte(a) (((u_char *)(a))[9])
#define getsign(a) (signbyte(a) & 0x80)
-#define setsign(a,b) { if (b) signbyte(a) |= 0x80; else signbyte(a) &= 0x7f; }
+#define setsign(a,b) { if ((b) != 0) signbyte(a) |= 0x80; else signbyte(a) &= 0x7f; }
#define copysign(a,b) { if (getsign(a)) signbyte(b) |= 0x80; \
else signbyte(b) &= 0x7f; }
#define changesign(a) { signbyte(a) ^= 0x80; }
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Karsten Keil, David S. Miller
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide, netdev,
Tejun Heo, akpm, Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
We test whether a bit is set in a mask here, which is correct
but gcc warns about it as it thinks it might be confusing:
drivers/isdn/isdnloop/isdnloop.c:412:37: error: ?: using integer constants in boolean context, the expression will always evaluate to 'true' [-Werror=int-in-bool-context]
This replaces the negation of an integer with an equivalent
comparison to zero, which gets rid of the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/isdn/isdnloop/isdnloop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index 6ffd13466b8c..5792928b944d 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -409,7 +409,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card *card)
return -EINVAL;
}
if (len) {
- if (!(card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE))
+ if ((card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE) == 0)
return 0;
if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
return 0;
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 06/14] acpi: thermal: fix gcc-6/ccache warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Zhang Rui, Rafael J. Wysocki, Len Brown
Cc: Arnd Bergmann, linux-acpi, Greg Kroah-Hartman, dri-devel,
linux-ide, Tejun Heo, akpm, Linus Torvalds, Guenter Roeck,
linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
In some configurations, topology_physical_package_id() is trivially
defined as '-1' for any input, resulting a comparison that is
always true:
drivers/acpi/processor_thermal.c: In function ‘cpufreq_set_cur_state’:
drivers/acpi/processor_thermal.c:137:36: error: self-comparison always evaluates to true [-Werror=tautological-compare]
By introducing a temporary variable, we can tell gcc that this is
intentional.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/acpi/processor_thermal.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 59c3a5d1e600..411f3a7f4a7c 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -122,20 +122,22 @@ static int cpufreq_get_cur_state(unsigned int cpu)
static int cpufreq_set_cur_state(unsigned int cpu, int state)
{
int i;
+ int id;
if (!cpu_has_cpufreq(cpu))
return 0;
reduction_pctg(cpu) = state;
+ id = topology_physical_package_id(cpu);
+
/*
* Update all the CPUs in the same package because they all
* contribute to the temperature and often share the same
* frequency.
*/
for_each_online_cpu(i) {
- if (topology_physical_package_id(i) ==
- topology_physical_package_id(cpu))
+ if (topology_physical_package_id(i) == id)
cpufreq_update_policy(i);
}
return 0;
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 07/14] proc/kcore: hide a harmless warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Jiri Olsa
Cc: Pratyush Anand, Kees Cook, Arnd Bergmann, Ard Biesheuvel,
Greg Kroah-Hartman, dri-devel, linux-ide, Tejun Heo, akpm,
Linus Torvalds, Ingo Molnar, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
gcc warns when MODULES_VADDR/END is defined to the same value as
VMALLOC_START/VMALLOC_END, e.g. on x86-32:
fs/proc/kcore.c: In function ‘add_modules_range’:
fs/proc/kcore.c:622:161: error: self-comparison always evaluates to false [-Werror=tautological-compare]
if (/*MODULES_VADDR != VMALLOC_START && */MODULES_END != VMALLOC_END) {
The code is correct as it is required for most other configurations.
The best workaround I found for shutting up that warning is to make
it a little more complex by adding a temporary variable. The compiler
will still optimize away the code as it finds the two to be identical,
but it no longer warns because it doesn't condider the comparison
"tautological" any more.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/proc/kcore.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 45629f4b5402..c503ad657c46 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -620,12 +620,14 @@ static void __init proc_kcore_text_init(void)
/*
* MODULES_VADDR has no intersection with VMALLOC_ADDR.
*/
-struct kcore_list kcore_modules;
+static struct kcore_list kcore_modules;
static void __init add_modules_range(void)
{
- if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {
- kclist_add(&kcore_modules, (void *)MODULES_VADDR,
- MODULES_END - MODULES_VADDR, KCORE_VMALLOC);
+ void *start = (void *)MODULES_VADDR;
+ size_t len = MODULES_END - MODULES_VADDR;
+
+ if (start != (void *)VMALLOC_START && len != VMALLOC_END - VMALLOC_START) {
+ kclist_add(&kcore_modules, start, len, KCORE_VMALLOC);
}
}
#else
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
From: Arnd Bergmann @ 2017-07-14 9:25 UTC (permalink / raw)
To: linux-kernel, Michael Hennerich, Dmitry Torokhov
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
linux-input, Tejun Heo, akpm, Linus Torvalds, Guenter Roeck,
linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
FIFO_MODE is an macro expression with a '<<' operator, which
gcc points out could be misread as a '<':
drivers/input/misc/adxl34x.c: In function 'adxl34x_probe':
drivers/input/misc/adxl34x.c:799:36: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
This converts the test to an explicit comparison with zero,
making it clearer to gcc and the reader what is intended.
Fixes: e27c729219ad ("Input: add driver for ADXL345/346 Digital Accelerometers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/input/misc/adxl34x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index 2b2d02f408bb..e0caaa0de454 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -796,7 +796,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
if (pdata->watermark) {
ac->int_mask |= WATERMARK;
- if (!FIFO_MODE(pdata->fifo_mode))
+ if (FIFO_MODE(pdata->fifo_mode) == 0)
ac->pdata.fifo_mode |= FIFO_STREAM;
} else {
ac->int_mask |= DATA_READY;
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 09/14] SFI: fix tautological-compare warning
From: Arnd Bergmann @ 2017-07-14 9:30 UTC (permalink / raw)
To: linux-kernel, Len Brown
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Tejun Heo, akpm, Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
With ccache in combination with gcc-6, we get a harmless warning for the sfi subsystem,
as ccache only sees the preprocessed source:
drivers/sfi/sfi_core.c: In function ‘sfi_map_table’:
drivers/sfi/sfi_core.c:175:53: error: self-comparison always evaluates to true [-Werror=tautological-compare]
Using an inline function to do the comparison tells the compiler what is
going on even for preprocessed files, and avoids the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/sfi/sfi_core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c
index 296db7a69c27..a8f2313a2613 100644
--- a/drivers/sfi/sfi_core.c
+++ b/drivers/sfi/sfi_core.c
@@ -71,9 +71,12 @@
#include "sfi_core.h"
-#define ON_SAME_PAGE(addr1, addr2) \
- (((unsigned long)(addr1) & PAGE_MASK) == \
- ((unsigned long)(addr2) & PAGE_MASK))
+static inline bool on_same_page(unsigned long addr1, unsigned long addr2)
+{
+ return (addr1 & PAGE_MASK) == (addr2 & PAGE_MASK);
+}
+
+#define ON_SAME_PAGE(addr1, addr2) on_same_page((unsigned long)addr1, (unsigned long)addr2)
#define TABLE_ON_PAGE(page, table, size) (ON_SAME_PAGE(page, table) && \
ON_SAME_PAGE(page, table + size))
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 10/14] staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read
From: Arnd Bergmann @ 2017-07-14 9:31 UTC (permalink / raw)
To: linux-kernel, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Greg Kroah-Hartman
Cc: devel, Arnd Bergmann, linux-iio, dri-devel, linux-ide, stable,
Peter Meerwald-Stadler, Hartmut Knaack, Tejun Heo, akpm,
Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
gcc-7 points out an older regression:
drivers/staging/iio/resolver/ad2s1210.c: In function 'ad2s1210_read_raw':
drivers/staging/iio/resolver/ad2s1210.c:515:42: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
The original code had 'unsigned short' here, but incorrectly got
converted to 'bool'. This reverts the regression and uses a normal
type instead.
Fixes: 29148543c521 ("staging:iio:resolver:ad2s1210 minimal chan spec conversion.")
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/iio/resolver/ad2s1210.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index a6a8393d6664..3e00df74b18c 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -472,7 +472,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
long m)
{
struct ad2s1210_state *st = iio_priv(indio_dev);
- bool negative;
+ u16 negative;
int ret = 0;
u16 pos;
s16 vel;
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 11/14] IB/uverbs: fix gcc-7 type warning
From: Arnd Bergmann @ 2017-07-14 9:31 UTC (permalink / raw)
To: linux-kernel, Doug Ledford, Sean Hefty, Hal Rosenstock
Cc: Leon Romanovsky, Arnd Bergmann, linux-rdma, Greg Kroah-Hartman,
Yishai Hadas, Matan Barak, dri-devel, linux-ide, Tejun Heo, akpm,
Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
When using ccache, we get a harmless warning about the fact that
we use the result of a multiplication as a condition:
drivers/infiniband/core/uverbs_main.c: In function 'ib_uverbs_write':
drivers/infiniband/core/uverbs_main.c:787:40: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:787:117: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:790:50: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:790:151: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
This changes the macro to explicitly check the number for a positive
length, which avoids the warning.
Fixes: a96e4e2ffe43 ("IB/uverbs: New macro to set pointers to NULL if length is 0 in INIT_UDATA()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/infiniband/core/uverbs.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 64d494a64daf..364d7de05721 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -55,12 +55,14 @@
(udata)->outlen = (olen); \
} while (0)
-#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \
- do { \
- (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \
- (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \
- (udata)->inlen = (ilen); \
- (udata)->outlen = (olen); \
+#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \
+ do { \
+ (udata)->inbuf = (ilen) > 0 ? \
+ (const void __user *) (ibuf) : NULL; \
+ (udata)->outbuf = (olen) > 0 ? \
+ (void __user *) (obuf) : NULL; \
+ (udata)->inlen = (ilen); \
+ (udata)->outlen = (olen); \
} while (0)
/*
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 12/14] drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning
From: Arnd Bergmann @ 2017-07-14 9:31 UTC (permalink / raw)
To: linux-kernel, Ben Skeggs, David Airlie
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide, nouveau,
Tejun Heo, akpm, Linus Torvalds, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
gcc thinks that interpreting a multiplication result as a bool
is confusing:
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c: In function 'read_pll':
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c:133:8: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
In this instance, I think using multiplication is more intuitive
than '&&', so I'm adding a comparison to zero instead to shut up
the warning. To further improve readability, I also make the
error case indented and leave the normal case as the final 'return'
statement.
Fixes: 7632b30e4b8b ("drm/nouveau/clk: namespace + nvidia gpu names (no binary change)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
index 96e0941c8edd..04b4f4ccf186 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
@@ -130,10 +130,10 @@ read_pll(struct gt215_clk *clk, int idx, u32 pll)
sclk = read_clk(clk, 0x10 + idx, false);
}
- if (M * P)
- return sclk * N / (M * P);
+ if (M * P == 0)
+ return 0;
- return 0;
+ return sclk * N / (M * P);
}
static int
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning
From: Arnd Bergmann @ 2017-07-14 9:31 UTC (permalink / raw)
To: linux-kernel, Mark Brown, Andrew Morton
Cc: Arnd Bergmann, Masahiro Yamada, Greg Kroah-Hartman, dri-devel,
linux-ide, Tejun Heo, Charles Keepax, Linus Torvalds,
Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
When we pass the result of a multiplication as the timeout, we
can get a warning:
drivers/mmc/host/bcm2835.c:596:149: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/mfd/arizona-core.c:247:195: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
This is easy to avoid by comparing the timeout to zero instead,
making it a boolean expression.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/iopoll.h | 6 ++++--
include/linux/regmap.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index d29e1e21bf3f..7a17ba02253b 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -48,7 +48,8 @@
(val) = op(addr); \
if (cond) \
break; \
- if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
+ if ((timeout_us) > 0 && \
+ ktime_compare(ktime_get(), timeout) > 0) { \
(val) = op(addr); \
break; \
} \
@@ -82,7 +83,8 @@
(val) = op(addr); \
if (cond) \
break; \
- if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
+ if ((timeout_us) > 0 && \
+ ktime_compare(ktime_get(), timeout) > 0) { \
(val) = op(addr); \
break; \
} \
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 1474ab0a3922..0889dbf37161 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -129,7 +129,7 @@ struct reg_sequence {
break; \
if (cond) \
break; \
- if ((timeout_us) && \
+ if ((timeout_us) > 0 && \
ktime_compare(ktime_get(), __timeout) > 0) { \
__ret = regmap_read((map), (addr), &(val)); \
break; \
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result interpreted as bool
From: Arnd Bergmann @ 2017-07-14 9:36 UTC (permalink / raw)
To: linux-kernel, Mauro Carvalho Chehab, Hans Verkuil
Cc: devel, Niklas Söderlund, Arnd Bergmann, Greg Kroah-Hartman,
Robert Jarzmik, adi-buildroot-devel, dri-devel, linux-renesas-soc,
linux-ide, linux-arm-kernel, Tejun Heo, akpm, Alan Cox,
Linus Torvalds, Daeseok Youn, Guenter Roeck, linux-media
In-Reply-To: <20170714092540.1217397-1-arnd@arndb.de>
v4l2_subdev_call is a macro returning whatever the callback return
type is, usually 'int'. With gcc-7 and ccache, this can lead to
many wanings like:
media/platform/pxa_camera.c: In function 'pxa_mbus_build_fmts_xlate':
media/platform/pxa_camera.c:766:27: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context]
while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) {
media/atomisp/pci/atomisp2/atomisp_cmd.c: In function 'atomisp_s_ae_window':
media/atomisp/pci/atomisp2/atomisp_cmd.c:6414:52: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context]
if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
The best workaround I could come up with is to change all the
callers that use the return code from v4l2_subdev_call() in an
'if' or 'while' condition.
In case of simple 'if' checks, adding a temporary variable is
usually ok, and sometimes this can be used to propagate or
print an error code, so I do that.
For the 'while' loops, I ended up adding an otherwise useless
comparison with zero, which unfortunately makes the code a little
uglied.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/pci/cx18/cx18-ioctl.c | 6 ++++--
drivers/media/pci/saa7146/mxb.c | 5 +++--
drivers/media/platform/atmel/atmel-isc.c | 4 ++--
drivers/media/platform/atmel/atmel-isi.c | 4 ++--
drivers/media/platform/blackfin/bfin_capture.c | 4 ++--
drivers/media/platform/omap3isp/ispccdc.c | 5 +++--
drivers/media/platform/pxa_camera.c | 3 ++-
drivers/media/platform/rcar-vin/rcar-core.c | 2 +-
drivers/media/platform/rcar-vin/rcar-dma.c | 4 +++-
drivers/media/platform/soc_camera/soc_camera.c | 4 ++--
drivers/media/platform/stm32/stm32-dcmi.c | 4 ++--
drivers/media/platform/ti-vpe/cal.c | 6 ++++--
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 13 +++++++------
13 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index 80b902b12a78..1803f28fc501 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -188,6 +188,7 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
{
struct cx18 *cx = fh2id(fh)->cx;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
+ int ret;
/* sane, V4L2 spec compliant, defaults */
vbifmt->reserved[0] = 0;
@@ -201,8 +202,9 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
* digitizer/slicer. Note, cx18_av_vbi() wipes the passed in
* fmt->fmt.sliced under valid calling conditions
*/
- if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced))
- return -EINVAL;
+ ret = v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced);
+ if (ret)
+ return ret;
vbifmt->service_set = cx18_get_service_set(vbifmt);
return 0;
diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c
index 504d78807639..d2d843c38579 100644
--- a/drivers/media/pci/saa7146/mxb.c
+++ b/drivers/media/pci/saa7146/mxb.c
@@ -525,8 +525,9 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
return err;
/* switch video in saa7111a */
- if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
- pr_err("VIDIOC_S_INPUT: could not address saa7111a\n");
+ err = saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0);
+ if (err)
+ pr_err("VIDIOC_S_INPUT: could not address saa7111a: %d\n", err);
mxb->cur_audinput = video_audio_connect[input];
/* switch the audio-source only if necessary */
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index d6534252cdcd..704b34a0cc00 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -1475,8 +1475,8 @@ static int isc_formats_init(struct isc_device *isc)
fmt++;
}
- while (!v4l2_subdev_call(subdev, pad, enum_mbus_code,
- NULL, &mbus_code)) {
+ while (v4l2_subdev_call(subdev, pad, enum_mbus_code,
+ NULL, &mbus_code) == 0) {
mbus_code.index++;
fmt = find_format_by_code(mbus_code.code, &i);
if (!fmt)
diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index 891fa2505efa..30b7e6f298ed 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1013,8 +1013,8 @@ static int isi_formats_init(struct atmel_isi *isi)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
- while (!v4l2_subdev_call(subdev, pad, enum_mbus_code,
- NULL, &mbus_code)) {
+ while (v4l2_subdev_call(subdev, pad, enum_mbus_code,
+ NULL, &mbus_code) == 0) {
for (i = 0; i < ARRAY_SIZE(isi_formats); i++) {
if (isi_formats[i].mbus_code != mbus_code.code)
continue;
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 1c5166df46f5..864c98f21a0e 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -157,8 +157,8 @@ static int bcap_init_sensor_formats(struct bcap_device *bcap_dev)
unsigned int num_formats = 0;
int i, j;
- while (!v4l2_subdev_call(bcap_dev->sd, pad,
- enum_mbus_code, NULL, &code)) {
+ while (v4l2_subdev_call(bcap_dev->sd, pad,
+ enum_mbus_code, NULL, &code) == 0) {
num_formats++;
code.index++;
}
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 7207558d722c..a94157461f58 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1132,6 +1132,7 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
unsigned int sph;
u32 syn_mode;
u32 ccdc_pattern;
+ int ret;
ccdc->bt656 = false;
ccdc->fields = 0;
@@ -1140,7 +1141,6 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
sensor = media_entity_to_v4l2_subdev(pad->entity);
if (ccdc->input == CCDC_INPUT_PARALLEL) {
struct v4l2_mbus_config cfg;
- int ret;
ret = v4l2_subdev_call(sensor, video, g_mbus_config, &cfg);
if (!ret)
@@ -1158,7 +1158,8 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
*/
fmt_src.pad = pad->index;
fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE;
- if (!v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src)) {
+ ret = v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src);
+ if (!ret) {
fmt_info = omap3isp_video_format_info(fmt_src.format.code);
depth_in = fmt_info->width;
}
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 399095170b6e..5236c7b171ea 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -763,7 +763,8 @@ static struct soc_camera_format_xlate *pxa_mbus_build_fmts_xlate(
};
struct soc_camera_format_xlate *user_formats;
- while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) {
+ while (v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code) ==
+ 0) {
raw_fmts++;
code.index++;
}
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 77dff047c41c..a41f4a3d9b69 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -54,7 +54,7 @@ static bool rvin_mbus_supported(struct rvin_graph_entity *entity)
code.index = 0;
code.pad = entity->source_pad;
- while (!v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &code)) {
+ while (v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &code) == 0) {
code.index++;
switch (code.code) {
case MEDIA_BUS_FMT_YUYV8_1X16:
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index b136844499f6..ee16e9886041 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -143,6 +143,7 @@ static int rvin_setup(struct rvin_dev *vin)
u32 vnmc, dmr, dmr2, interrupts;
v4l2_std_id std;
bool progressive = false, output_is_yuv = false, input_is_yuv = false;
+ int ret;
switch (vin->format.field) {
case V4L2_FIELD_TOP:
@@ -155,7 +156,8 @@ static int rvin_setup(struct rvin_dev *vin)
/* Default to TB */
vnmc = VNMC_IM_FULL;
/* Use BT if video standard can be read and is 60 Hz format */
- if (!v4l2_subdev_call(vin_to_source(vin), video, g_std, &std)) {
+ ret = v4l2_subdev_call(vin_to_source(vin), video, g_std, &std);
+ if (ret) {
if (std & V4L2_STD_525_60)
vnmc = VNMC_IM_FULL | VNMC_FOC;
}
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 45a0429d75bb..3ef648fc2db6 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -454,7 +454,7 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
- while (!v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &code)) {
+ while (v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &code) == 0) {
raw_fmts++;
code.index++;
}
@@ -1202,7 +1202,7 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
goto evidstart;
/* Try to improve our guess of a reasonable window format */
- if (!v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt)) {
+ if (v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt) == 0) {
icd->user_width = mf->width;
icd->user_height = mf->height;
icd->colorspace = mf->colorspace;
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 83d32a5d0f40..96084dfd5d11 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1034,8 +1034,8 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
- while (!v4l2_subdev_call(subdev, pad, enum_mbus_code,
- NULL, &mbus_code)) {
+ while (v4l2_subdev_call(subdev, pad, enum_mbus_code,
+ NULL, &mbus_code) == 0) {
for (i = 0; i < ARRAY_SIZE(dcmi_formats); i++) {
if (dcmi_formats[i].mbus_code != mbus_code.code)
continue;
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 177faa36bc16..df0216a6367c 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1348,9 +1348,11 @@ static void cal_stop_streaming(struct vb2_queue *vq)
struct cal_dmaqueue *dma_q = &ctx->vidq;
struct cal_buffer *buf, *tmp;
unsigned long flags;
+ int ret;
- if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
- ctx_err(ctx, "stream off failed in subdev\n");
+ ret = v4l2_subdev_call(ctx->sensor, video, s_stream, 0);
+ if (ret)
+ ctx_err(ctx, "stream off failed in subdev: %d\n", ret);
csi2_ppi_disable(ctx);
disable_irqs(ctx);
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 97093baf28ac..fe56a037f065 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -6405,19 +6405,20 @@ int atomisp_s_ae_window(struct atomisp_sub_device *asd,
struct atomisp_device *isp = asd->isp;
/* Coverity CID 298071 - initialzize struct */
struct v4l2_subdev_selection sel = { 0 };
+ int ret;
sel.r.left = arg->x_left;
sel.r.top = arg->y_top;
sel.r.width = arg->x_right - arg->x_left + 1;
sel.r.height = arg->y_bottom - arg->y_top + 1;
- if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
- pad, set_selection, NULL, &sel)) {
- dev_err(isp->dev, "failed to call sensor set_selection.\n");
- return -EINVAL;
- }
+ ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+ pad, set_selection, NULL, &sel);
+ if (ret)
+ dev_err(isp->dev, "failed to call sensor set_selection: %d\n",
+ ret);
- return 0;
+ return ret;
}
int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames)
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related
* Re: [PATCH 11/14] IB/uverbs: fix gcc-7 type warning
From: Leon Romanovsky @ 2017-07-14 9:46 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-kernel, Doug Ledford, Sean Hefty, Hal Rosenstock,
Greg Kroah-Hartman, Linus Torvalds, Tejun Heo, Guenter Roeck,
linux-ide, linux-media, akpm, dri-devel, Matan Barak,
Yishai Hadas, linux-rdma
In-Reply-To: <20170714093129.1366900-2-arnd@arndb.de>
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
On Fri, Jul 14, 2017 at 11:31:04AM +0200, Arnd Bergmann wrote:
> When using ccache, we get a harmless warning about the fact that
> we use the result of a multiplication as a condition:
>
> drivers/infiniband/core/uverbs_main.c: In function 'ib_uverbs_write':
> drivers/infiniband/core/uverbs_main.c:787:40: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:787:117: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:790:50: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:790:151: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
>
> This changes the macro to explicitly check the number for a positive
> length, which avoids the warning.
>
> Fixes: a96e4e2ffe43 ("IB/uverbs: New macro to set pointers to NULL if length is 0 in INIT_UDATA()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/infiniband/core/uverbs.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning
From: Joe Perches @ 2017-07-14 9:55 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel, Mark Brown, Andrew Morton
Cc: Greg Kroah-Hartman, Linus Torvalds, Tejun Heo, Guenter Roeck,
linux-ide, linux-media, dri-devel, Masahiro Yamada,
Charles Keepax
In-Reply-To: <20170714093129.1366900-4-arnd@arndb.de>
On Fri, 2017-07-14 at 11:31 +0200, Arnd Bergmann wrote:
> When we pass the result of a multiplication as the timeout, we
> can get a warning:
>
> drivers/mmc/host/bcm2835.c:596:149: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/mfd/arizona-core.c:247:195: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
>
> This is easy to avoid by comparing the timeout to zero instead,
> making it a boolean expression.
Perhaps this is better as != 0 if the multiply is signed.
> diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
[]
> @@ -48,7 +48,8 @@
> (val) = op(addr); \
> if (cond) \
> break; \
> - if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
> + if ((timeout_us) > 0 && \
> + ktime_compare(ktime_get(), timeout) > 0) { \
> (val) = op(addr); \
> break; \
> } \
etc...
^ permalink raw reply
* Re: [PATCH, RESEND 03/14] drm/vmwgfx: avoid gcc-7 parentheses warning
From: Jani Nikula @ 2017-07-14 10:11 UTC (permalink / raw)
To: linux-kernel, VMware Graphics, Sinclair Yeh, Thomas Hellstrom,
David Airlie
Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
Brian Paul, Tejun Heo, akpm, Linus Torvalds, Guenter Roeck,
linux-media
In-Reply-To: <20170714092540.1217397-4-arnd@arndb.de>
On Fri, 14 Jul 2017, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc-7 warns about slightly suspicious code in vmw_cmd_invalid:
>
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c: In function 'vmw_cmd_invalid':
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:522:23: error: the omitted middle operand in ?: will always be 'true', suggest explicit middle operand [-Werror=parentheses]
>
> The problem is that it is mixing boolean and integer values here.
> I assume that the code actually works correctly, so making it use
> a literal '1' instead of the implied 'true' makes it more readable
> and avoids the warning.
>
> The code has been in this file since the start, but it could
> make sense to backport this patch to stable to make it build cleanly
> with gcc-7.
>
> Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Originally submitted on Nov 16, but for some reason it never appeared
> upstream. The patch is still needed as of v4.11-rc2
See also the thread starting at
http://lkml.kernel.org/r/CA+55aFwZV-QirBTY8y4y+h796V2CzpWdL=tWB27rJ1u3rojXYQ@mail.gmail.com
BR,
Jani.
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index c7b53d987f06..3f343e55972a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -519,7 +519,7 @@ static int vmw_cmd_invalid(struct vmw_private *dev_priv,
> struct vmw_sw_context *sw_context,
> SVGA3dCmdHeader *header)
> {
> - return capable(CAP_SYS_ADMIN) ? : -EINVAL;
> + return capable(CAP_SYS_ADMIN) ? 1 : -EINVAL;
> }
>
> static int vmw_cmd_ok(struct vmw_private *dev_priv,
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply
* Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning
From: Joe Perches @ 2017-07-14 10:08 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel, Karsten Keil, David S. Miller
Cc: Greg Kroah-Hartman, Linus Torvalds, Tejun Heo, Guenter Roeck,
linux-ide, linux-media, akpm, dri-devel, netdev
In-Reply-To: <20170714092540.1217397-6-arnd@arndb.de>
On Fri, 2017-07-14 at 11:25 +0200, Arnd Bergmann wrote:
> We test whether a bit is set in a mask here, which is correct
> but gcc warns about it as it thinks it might be confusing:
>
> drivers/isdn/isdnloop/isdnloop.c:412:37: error: ?: using integer constants in boolean context, the expression will always evaluate to 'true' [-Werror=int-in-bool-context]
>
> This replaces the negation of an integer with an equivalent
> comparison to zero, which gets rid of the warning.
[]
> diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
[]
> @@ -409,7 +409,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card *card)
> return -EINVAL;
> }
> if (len) {
> - if (!(card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE))
> + if ((card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE) == 0)
> return 0;
> if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
> return 0;
The if as written can not be zero.
drivers/isdn/isdnloop/isdnloop.h:#define ISDNLOOP_FLAGS_B1ACTIVE 1 /* B-Channel-1 is open */
drivers/isdn/isdnloop/isdnloop.h:#define ISDNLOOP_FLAGS_B2ACTIVE 2 /* B-Channel-2 is open */
Perhaps this is a logic defect and should be:
if (!(card->flags & ((channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE)))
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox