From: Zhongjun Tan <[email protected]>
Fix unsigned expression compared with zero
Signed-off-by: Zhongjun Tan <[email protected]>
---
sound/usb/pcm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index e692ae04436a..e461715a43bd 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -766,8 +766,8 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
struct snd_usb_audio *chip = subs->stream->chip;
const struct audioformat *fp;
struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- unsigned int rmin, rmax, r;
- int i;
+ unsigned int rmin, rmax;
+ int i, r;
hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
rmin = UINT_MAX;
--
2.29.0
Hi Zhongjun,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on linus/master v5.19-rc5 next-20220705]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Zhongjun-Tan/ALSA-usb-audio-Fix-unsigned-expression-compared-with-zero/20220706-150825
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: hexagon-randconfig-r045-20220703 (https://download.01.org/0day-ci/archive/20220706/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project f553287b588916de09c66e3e32bf75e5060f967f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/10d09dc3ad3a9b823d9097a68058698be90c7a74
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhongjun-Tan/ALSA-usb-audio-Fix-unsigned-expression-compared-with-zero/20220706-150825
git checkout 10d09dc3ad3a9b823d9097a68058698be90c7a74
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash sound/usb/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
>> sound/usb/pcm.c:782:11: warning: comparison of distinct pointer types ('typeof (rmin) *' (aka 'unsigned int *') and 'typeof (r) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
rmin = min(rmin, r);
^~~~~~~~~~~~
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
>> sound/usb/pcm.c:783:11: warning: comparison of distinct pointer types ('typeof (rmax) *' (aka 'unsigned int *') and 'typeof (r) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
rmax = max(rmax, r);
^~~~~~~~~~~~
include/linux/minmax.h:52:19: note: expanded from macro 'max'
#define max(x, y) __careful_cmp(x, y, >)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
sound/usb/pcm.c:791:12: warning: comparison of distinct pointer types ('typeof (rmin) *' (aka 'unsigned int *') and 'typeof (r) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
rmin = min(rmin, r);
^~~~~~~~~~~~
include/linux/minmax.h:45:19: note: expanded from macro 'min'
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
sound/usb/pcm.c:792:12: warning: comparison of distinct pointer types ('typeof (rmax) *' (aka 'unsigned int *') and 'typeof (r) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
rmax = max(rmax, r);
^~~~~~~~~~~~
include/linux/minmax.h:52:19: note: expanded from macro 'max'
#define max(x, y) __careful_cmp(x, y, >)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
4 warnings generated.
vim +782 sound/usb/pcm.c
7726dce14c5e7e Takashi Iwai 2020-11-23 761
e5779998bf8b70 Daniel Mack 2010-03-04 762 static int hw_rule_rate(struct snd_pcm_hw_params *params,
e5779998bf8b70 Daniel Mack 2010-03-04 763 struct snd_pcm_hw_rule *rule)
e5779998bf8b70 Daniel Mack 2010-03-04 764 {
e5779998bf8b70 Daniel Mack 2010-03-04 765 struct snd_usb_substream *subs = rule->private;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 766 struct snd_usb_audio *chip = subs->stream->chip;
cab941b7e5cf05 Takashi Iwai 2020-11-23 767 const struct audioformat *fp;
e5779998bf8b70 Daniel Mack 2010-03-04 768 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
10d09dc3ad3a9b Zhongjun Tan 2022-07-06 769 unsigned int rmin, rmax;
10d09dc3ad3a9b Zhongjun Tan 2022-07-06 770 int i, r;
e5779998bf8b70 Daniel Mack 2010-03-04 771
e5779998bf8b70 Daniel Mack 2010-03-04 772 hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 773 rmin = UINT_MAX;
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 774 rmax = 0;
88766f04c4142c Eldad Zack 2013-04-03 775 list_for_each_entry(fp, &subs->fmt_list, list) {
e5779998bf8b70 Daniel Mack 2010-03-04 776 if (!hw_check_valid_format(subs, params, fp))
e5779998bf8b70 Daniel Mack 2010-03-04 777 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 778 r = snd_usb_endpoint_get_clock_rate(chip, fp->clock);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 779 if (r > 0) {
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 780 if (!snd_interval_test(it, r))
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 781 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 @782 rmin = min(rmin, r);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 @783 rmax = max(rmax, r);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 784 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 785 }
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 786 if (fp->rate_table && fp->nr_rates) {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 787 for (i = 0; i < fp->nr_rates; i++) {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 788 r = fp->rate_table[i];
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 789 if (!snd_interval_test(it, r))
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 790 continue;
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 791 rmin = min(rmin, r);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 792 rmax = max(rmax, r);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 793 }
e5779998bf8b70 Daniel Mack 2010-03-04 794 } else {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 795 rmin = min(rmin, fp->rate_min);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 796 rmax = max(rmax, fp->rate_max);
e5779998bf8b70 Daniel Mack 2010-03-04 797 }
e5779998bf8b70 Daniel Mack 2010-03-04 798 }
e5779998bf8b70 Daniel Mack 2010-03-04 799
7726dce14c5e7e Takashi Iwai 2020-11-23 800 return apply_hw_params_minmax(it, rmin, rmax);
e5779998bf8b70 Daniel Mack 2010-03-04 801 }
e5779998bf8b70 Daniel Mack 2010-03-04 802
--
0-DAY CI Kernel Test Service
https://01.org/lkp
On Wed, 06 Jul 2022 09:06:27 +0200,
Zhongjun Tan wrote:
>
> From: Zhongjun Tan <[email protected]>
>
> Fix unsigned expression compared with zero
>
> Signed-off-by: Zhongjun Tan <[email protected]>
Could you give more detailed description about what you're trying to
fix? The patch itself looks rather problematic as 0day bot already
reported.
thanks,
Takashi
Hi Zhongjun,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on linus/master v5.19-rc5 next-20220708]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zhongjun-Tan/ALSA-usb-audio-Fix-unsigned-expression-compared-with-zero/20220706-150825
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: s390-randconfig-s031-20220710 (https://download.01.org/0day-ci/archive/20220710/[email protected]/config)
compiler: s390-linux-gcc (GCC) 11.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/10d09dc3ad3a9b823d9097a68058698be90c7a74
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhongjun-Tan/ALSA-usb-audio-Fix-unsigned-expression-compared-with-zero/20220706-150825
git checkout 10d09dc3ad3a9b823d9097a68058698be90c7a74
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=s390 SHELL=/bin/bash sound/usb/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> sound/usb/pcm.c:782:32: sparse: sparse: incompatible types in comparison expression (different signedness):
>> sound/usb/pcm.c:782:32: sparse: unsigned int *
>> sound/usb/pcm.c:782:32: sparse: int *
sound/usb/pcm.c:783:32: sparse: sparse: incompatible types in comparison expression (different signedness):
sound/usb/pcm.c:783:32: sparse: unsigned int *
sound/usb/pcm.c:783:32: sparse: int *
sound/usb/pcm.c:791:40: sparse: sparse: incompatible types in comparison expression (different signedness):
sound/usb/pcm.c:791:40: sparse: unsigned int *
sound/usb/pcm.c:791:40: sparse: int *
sound/usb/pcm.c:792:40: sparse: sparse: incompatible types in comparison expression (different signedness):
sound/usb/pcm.c:792:40: sparse: unsigned int *
sound/usb/pcm.c:792:40: sparse: int *
vim +782 sound/usb/pcm.c
7726dce14c5e7e Takashi Iwai 2020-11-23 761
e5779998bf8b70 Daniel Mack 2010-03-04 762 static int hw_rule_rate(struct snd_pcm_hw_params *params,
e5779998bf8b70 Daniel Mack 2010-03-04 763 struct snd_pcm_hw_rule *rule)
e5779998bf8b70 Daniel Mack 2010-03-04 764 {
e5779998bf8b70 Daniel Mack 2010-03-04 765 struct snd_usb_substream *subs = rule->private;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 766 struct snd_usb_audio *chip = subs->stream->chip;
cab941b7e5cf05 Takashi Iwai 2020-11-23 767 const struct audioformat *fp;
e5779998bf8b70 Daniel Mack 2010-03-04 768 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
10d09dc3ad3a9b Zhongjun Tan 2022-07-06 769 unsigned int rmin, rmax;
10d09dc3ad3a9b Zhongjun Tan 2022-07-06 770 int i, r;
e5779998bf8b70 Daniel Mack 2010-03-04 771
e5779998bf8b70 Daniel Mack 2010-03-04 772 hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 773 rmin = UINT_MAX;
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 774 rmax = 0;
88766f04c4142c Eldad Zack 2013-04-03 775 list_for_each_entry(fp, &subs->fmt_list, list) {
e5779998bf8b70 Daniel Mack 2010-03-04 776 if (!hw_check_valid_format(subs, params, fp))
e5779998bf8b70 Daniel Mack 2010-03-04 777 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 778 r = snd_usb_endpoint_get_clock_rate(chip, fp->clock);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 779 if (r > 0) {
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 780 if (!snd_interval_test(it, r))
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 781 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 @782 rmin = min(rmin, r);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 783 rmax = max(rmax, r);
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 784 continue;
4e7cf1fbb34ecb Takashi Iwai 2021-09-29 785 }
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 786 if (fp->rate_table && fp->nr_rates) {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 787 for (i = 0; i < fp->nr_rates; i++) {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 788 r = fp->rate_table[i];
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 789 if (!snd_interval_test(it, r))
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 790 continue;
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 791 rmin = min(rmin, r);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 792 rmax = max(rmax, r);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 793 }
e5779998bf8b70 Daniel Mack 2010-03-04 794 } else {
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 795 rmin = min(rmin, fp->rate_min);
bc4e94aa8e72e7 Takashi Iwai 2020-11-23 796 rmax = max(rmax, fp->rate_max);
e5779998bf8b70 Daniel Mack 2010-03-04 797 }
e5779998bf8b70 Daniel Mack 2010-03-04 798 }
e5779998bf8b70 Daniel Mack 2010-03-04 799
7726dce14c5e7e Takashi Iwai 2020-11-23 800 return apply_hw_params_minmax(it, rmin, rmax);
e5779998bf8b70 Daniel Mack 2010-03-04 801 }
e5779998bf8b70 Daniel Mack 2010-03-04 802
--
0-DAY CI Kernel Test Service
https://01.org/lkp