Bug 46561 - korg1212.c: Weird range checking tests
Summary: korg1212.c: Weird range checking tests
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Takashi Iwai
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-28 16:56 UTC by David Binderman
Modified: 2012-10-15 21:23 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.6-rc3
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description David Binderman 2012-08-28 16:56:43 UTC
I just tried out the linux kernel 3.6-rc3 with
the extra compiler flag -Wlogical-op. 

I found the following warning messages

1.

sound/pci/korg1212/korg1212.c: In function ‘snd_korg1212_control_put’:
sound/pci/korg1212/korg1212.c:1941:6: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
      u->value.integer.value[0] <= k1212MaxADCSens &&
      ^
The source code is

    if (u->value.integer.value[0] >= k1212MinADCSens &&
        u->value.integer.value[0] <= k1212MaxADCSens &&

but

#define k1212MinADCSens     0x7f
#define k1212MaxADCSens     0x00

so the test is for >= 127 and <= 0. No wonder the compiler complains.
Suggest code rework.

2.

sound/pci/korg1212/korg1212.c:1947:6: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
      u->value.integer.value[1] <= k1212MaxADCSens &&
      ^

Duplicate.
Comment 1 Takashi Iwai 2012-08-30 15:02:08 UTC
Thanks, fixed the min/max range now in sound git tree.
Comment 2 Florian Mickler 2012-10-15 21:23:08 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc1:

commit fbaf6a5a35a830c2ae0449210efa31c165445735
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Aug 30 07:57:38 2012 -0700

    ALSA: korg1212: Fix reverted min/max ADC sense range

Note You need to log in before you can comment on or make changes to this bug.