lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 25 Oct 2022 22:56:11 +0800 (GMT+08:00)
From:   wangkailong@...i.cn
To:     perex@...ex.cz, tiwai@...e.com, lgirdwood@...il.com,
        broonie@...nel.org, motolav@...il.com, cezary.rojewski@...el.com,
        mkumard@...dia.com, pierre-louis.bossart@...ux.intel.com,
        kai.vehmanen@...ux.intel.com, peter.ujfalusi@...ux.intel.com
Cc:     alsa-devel@...a-project.org, linux-kernel@...r.kernel.org
Subject: [PATCH] ALSA/ASoC: replace ternary operator with min()

Fix the following coccicheck warning:

sound/soc/soc-ops.c:817: WARNING opportunity for min()
sound/core/vmaster.c:73: WARNING opportunity for min()
sound/pci/hda/hda_codec.c:337: WARNING opportunity for min()
sound/pci/ctxfi/ctatc.c:448: WARNING opportunity for min()
sound/pci/ctxfi/ctatc.c:387: WARNING opportunity for min()

Signed-off-by: KaiLong Wang <wangkailong@...i.cn>
---
 sound/core/vmaster.c      | 2 +-
 sound/pci/ctxfi/ctatc.c   | 4 ++--
 sound/pci/hda/hda_codec.c | 2 +-
 sound/soc/soc-ops.c       | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index d0f11f37889b..704a09f4bfd6 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -70,7 +70,7 @@ static int follower_update(struct link_follower *follower)
 		follower->vals[ch] = uctl->value.integer.value[ch];
  error:
 	kfree(uctl);
-	return err < 0 ? err : 0;
+	return min(err, 0);
 }
 
 /* get the follower ctl info and save the initial values */
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index fbdb8a3d5b8e..9fea50b72cfb 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -384,7 +384,7 @@ static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
 	apcm->started = 1;
 
 	max_cisz = src->multi * src->rsc.msr;
-	max_cisz = 0x80 * (max_cisz < 8 ? max_cisz : 8);
+	max_cisz = 0x80 * min(max_cisz, 8);
 
 	src->ops->set_sa(src, apcm->vm_block->addr);
 	src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size);
@@ -445,7 +445,7 @@ atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm)
 
 	size = apcm->vm_block->size;
 	max_cisz = src->multi * src->rsc.msr;
-	max_cisz = 128 * (max_cisz < 8 ? max_cisz : 8);
+	max_cisz = 128 * min(max_cisz, 8);
 
 	return (position + size - max_cisz - apcm->vm_block->addr) % size;
 }
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index b4d1e658c556..c195f99bd8d5 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -334,7 +334,7 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
 		return 0;
 
 	dev_len = parm + 1;
-	dev_len = dev_len < max_devices ? dev_len : max_devices;
+	dev_len = min(dev_len, max_devices);
 
 	devices = 0;
 	while (devices < dev_len) {
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index bd88de056358..d71d10055ed7 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -814,7 +814,7 @@ int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
 				unsigned int size, unsigned int __user *tlv)
 {
 	struct soc_bytes_ext *params = (void *)kcontrol->private_value;
-	unsigned int count = size < params->max ? size : params->max;
+	unsigned int count = min_t(unsigned int, size, params->max);
 	int ret = -ENXIO;
 
 	switch (op_flag) {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ