Commit 137c171c authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm: Fix assignment in if condition

There are a few places doing assignments in if condition in ALSA PCM
core code, which is a bad coding style that may confuse readers and
occasionally lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-55-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e3ded899
...@@ -239,7 +239,8 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, ...@@ -239,7 +239,8 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
int err; int err;
if (! (runtime = substream->runtime)) runtime = substream->runtime;
if (!runtime)
return -ENOTTY; return -ENOTTY;
data = kmalloc(sizeof(*data), GFP_KERNEL); data = kmalloc(sizeof(*data), GFP_KERNEL);
...@@ -343,7 +344,8 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, ...@@ -343,7 +344,8 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN)
return -EBADFD; return -EBADFD;
if ((ch = substream->runtime->channels) > 128) ch = substream->runtime->channels;
if (ch > 128)
return -EINVAL; return -EINVAL;
if (get_user(buf, &data32->bufs) || if (get_user(buf, &data32->bufs) ||
get_user(frames, &data32->frames)) get_user(frames, &data32->frames))
......
...@@ -266,7 +266,8 @@ int snd_pcm_format_signed(snd_pcm_format_t format) ...@@ -266,7 +266,8 @@ int snd_pcm_format_signed(snd_pcm_format_t format)
int val; int val;
if (!valid_format(format)) if (!valid_format(format))
return -EINVAL; return -EINVAL;
if ((val = pcm_formats[(INT)format].signd) < 0) val = pcm_formats[(INT)format].signd;
if (val < 0)
return -EINVAL; return -EINVAL;
return val; return val;
} }
...@@ -314,7 +315,8 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format) ...@@ -314,7 +315,8 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format)
int val; int val;
if (!valid_format(format)) if (!valid_format(format))
return -EINVAL; return -EINVAL;
if ((val = pcm_formats[(INT)format].le) < 0) val = pcm_formats[(INT)format].le;
if (val < 0)
return -EINVAL; return -EINVAL;
return val; return val;
} }
...@@ -350,7 +352,8 @@ int snd_pcm_format_width(snd_pcm_format_t format) ...@@ -350,7 +352,8 @@ int snd_pcm_format_width(snd_pcm_format_t format)
int val; int val;
if (!valid_format(format)) if (!valid_format(format))
return -EINVAL; return -EINVAL;
if ((val = pcm_formats[(INT)format].width) == 0) val = pcm_formats[(INT)format].width;
if (!val)
return -EINVAL; return -EINVAL;
return val; return val;
} }
...@@ -368,7 +371,8 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format) ...@@ -368,7 +371,8 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format)
int val; int val;
if (!valid_format(format)) if (!valid_format(format))
return -EINVAL; return -EINVAL;
if ((val = pcm_formats[(INT)format].phys) == 0) val = pcm_formats[(INT)format].phys;
if (!val)
return -EINVAL; return -EINVAL;
return val; return val;
} }
......
...@@ -768,7 +768,8 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -768,7 +768,8 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req))
cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); cpu_latency_qos_remove_request(&substream->latency_pm_qos_req);
if ((usecs = period_to_usecs(runtime)) >= 0) usecs = period_to_usecs(runtime);
if (usecs >= 0)
cpu_latency_qos_add_request(&substream->latency_pm_qos_req, cpu_latency_qos_add_request(&substream->latency_pm_qos_req,
usecs); usecs);
return 0; return 0;
...@@ -2658,7 +2659,8 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, ...@@ -2658,7 +2659,8 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
goto error; goto error;
} }
if ((err = substream->ops->open(substream)) < 0) err = substream->ops->open(substream);
if (err < 0)
goto error; goto error;
substream->hw_opened = 1; substream->hw_opened = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment