Commit dd1fc3c5 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: synth: Fix assignment in if condition

EMUx synth driver code contains lots of assignments in if condition,
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-64-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d0ad13ef
...@@ -104,7 +104,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch ...@@ -104,7 +104,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
if (emu->sflist == NULL) if (emu->sflist == NULL)
return -ENOMEM; return -ENOMEM;
if ((err = snd_emux_init_hwdep(emu)) < 0) err = snd_emux_init_hwdep(emu);
if (err < 0)
return err; return err;
snd_emux_init_voices(emu); snd_emux_init_voices(emu);
......
...@@ -181,7 +181,10 @@ snd_emux_send_effect(struct snd_emux_port *port, struct snd_midi_channel *chan, ...@@ -181,7 +181,10 @@ snd_emux_send_effect(struct snd_emux_port *port, struct snd_midi_channel *chan,
fx->flag[type] = mode; fx->flag[type] = mode;
/* do we need to modify the register in realtime ? */ /* do we need to modify the register in realtime ? */
if (! parm_defs[type].update || (offset = parm_defs[type].offset) < 0) if (!parm_defs[type].update)
return;
offset = parm_defs[type].offset;
if (offset < 0)
return; return;
#ifdef SNDRV_LITTLE_ENDIAN #ifdef SNDRV_LITTLE_ENDIAN
...@@ -223,13 +226,17 @@ snd_emux_setup_effect(struct snd_emux_voice *vp) ...@@ -223,13 +226,17 @@ snd_emux_setup_effect(struct snd_emux_voice *vp)
unsigned char *srcp; unsigned char *srcp;
int i; int i;
if (! (fx = chan->private)) fx = chan->private;
if (!fx)
return; return;
/* modify the register values via effect table */ /* modify the register values via effect table */
for (i = 0; i < EMUX_FX_END; i++) { for (i = 0; i < EMUX_FX_END; i++) {
int offset; int offset;
if (! fx->flag[i] || (offset = parm_defs[i].offset) < 0) if (!fx->flag[i])
continue;
offset = parm_defs[i].offset;
if (offset < 0)
continue; continue;
#ifdef SNDRV_LITTLE_ENDIAN #ifdef SNDRV_LITTLE_ENDIAN
if (parm_defs[i].type & PARM_IS_ALIGN_HI) if (parm_defs[i].type & PARM_IS_ALIGN_HI)
......
...@@ -116,7 +116,8 @@ snd_emux_init_hwdep(struct snd_emux *emu) ...@@ -116,7 +116,8 @@ snd_emux_init_hwdep(struct snd_emux *emu)
struct snd_hwdep *hw; struct snd_hwdep *hw;
int err; int err;
if ((err = snd_hwdep_new(emu->card, SNDRV_EMUX_HWDEP_NAME, emu->hwdep_idx, &hw)) < 0) err = snd_hwdep_new(emu->card, SNDRV_EMUX_HWDEP_NAME, emu->hwdep_idx, &hw);
if (err < 0)
return err; return err;
emu->hwdep = hw; emu->hwdep = hw;
strcpy(hw->name, SNDRV_EMUX_HWDEP_NAME); strcpy(hw->name, SNDRV_EMUX_HWDEP_NAME);
...@@ -127,7 +128,8 @@ snd_emux_init_hwdep(struct snd_emux *emu) ...@@ -127,7 +128,8 @@ snd_emux_init_hwdep(struct snd_emux *emu)
hw->ops.ioctl_compat = snd_emux_hwdep_ioctl; hw->ops.ioctl_compat = snd_emux_hwdep_ioctl;
hw->exclusive = 1; hw->exclusive = 1;
hw->private_data = emu; hw->private_data = emu;
if ((err = snd_card_register(emu->card)) < 0) err = snd_card_register(emu->card);
if (err < 0)
return err; return err;
return 0; return 0;
......
...@@ -349,7 +349,8 @@ sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) ...@@ -349,7 +349,8 @@ sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf)
{ {
struct snd_sf_zone *zp; struct snd_sf_zone *zp;
if ((zp = kzalloc(sizeof(*zp), GFP_KERNEL)) == NULL) zp = kzalloc(sizeof(*zp), GFP_KERNEL);
if (!zp)
return NULL; return NULL;
zp->next = sf->zones; zp->next = sf->zones;
sf->zones = zp; sf->zones = zp;
...@@ -381,7 +382,8 @@ sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) ...@@ -381,7 +382,8 @@ sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf)
{ {
struct snd_sf_sample *sp; struct snd_sf_sample *sp;
if ((sp = kzalloc(sizeof(*sp), GFP_KERNEL)) == NULL) sp = kzalloc(sizeof(*sp), GFP_KERNEL);
if (!sp)
return NULL; return NULL;
sp->next = sf->samples; sp->next = sf->samples;
...@@ -451,7 +453,8 @@ load_map(struct snd_sf_list *sflist, const void __user *data, int count) ...@@ -451,7 +453,8 @@ load_map(struct snd_sf_list *sflist, const void __user *data, int count)
} }
/* create a new zone */ /* create a new zone */
if ((zp = sf_zone_new(sflist, sf)) == NULL) zp = sf_zone_new(sflist, sf);
if (!zp)
return -ENOMEM; return -ENOMEM;
zp->bank = map.map_bank; zp->bank = map.map_bank;
...@@ -514,7 +517,8 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count) ...@@ -514,7 +517,8 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
int i; int i;
/* patch must be opened */ /* patch must be opened */
if ((sf = sflist->currsf) == NULL) sf = sflist->currsf;
if (!sf)
return -EINVAL; return -EINVAL;
if (is_special_type(sf->type)) if (is_special_type(sf->type))
...@@ -579,9 +583,9 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count) ...@@ -579,9 +583,9 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
init_voice_parm(&tmpzone.v.parm); init_voice_parm(&tmpzone.v.parm);
/* create a new zone */ /* create a new zone */
if ((zone = sf_zone_new(sflist, sf)) == NULL) { zone = sf_zone_new(sflist, sf);
if (!zone)
return -ENOMEM; return -ENOMEM;
}
/* copy the temporary data */ /* copy the temporary data */
zone->bank = tmpzone.bank; zone->bank = tmpzone.bank;
...@@ -700,7 +704,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) ...@@ -700,7 +704,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count)
long off; long off;
/* patch must be opened */ /* patch must be opened */
if ((sf = sflist->currsf) == NULL) sf = sflist->currsf;
if (!sf)
return -EINVAL; return -EINVAL;
if (is_special_type(sf->type)) if (is_special_type(sf->type))
...@@ -723,7 +728,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) ...@@ -723,7 +728,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count)
} }
/* Allocate a new sample structure */ /* Allocate a new sample structure */
if ((sp = sf_sample_new(sflist, sf)) == NULL) sp = sf_sample_new(sflist, sf);
if (!sp)
return -ENOMEM; return -ENOMEM;
sp->v = sample_info; sp->v = sample_info;
...@@ -958,7 +964,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, ...@@ -958,7 +964,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL); sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL);
if (sf == NULL) if (sf == NULL)
return -ENOMEM; return -ENOMEM;
if ((smp = sf_sample_new(sflist, sf)) == NULL) smp = sf_sample_new(sflist, sf);
if (!smp)
return -ENOMEM; return -ENOMEM;
sample_id = sflist->sample_counter; sample_id = sflist->sample_counter;
smp->v.sample = sample_id; smp->v.sample = sample_id;
...@@ -996,7 +1003,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, ...@@ -996,7 +1003,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
smp->v.sf_id = sf->id; smp->v.sf_id = sf->id;
/* set up voice info */ /* set up voice info */
if ((zone = sf_zone_new(sflist, sf)) == NULL) { zone = sf_zone_new(sflist, sf);
if (!zone) {
sf_sample_delete(sflist, sf, smp); sf_sample_delete(sflist, sf, smp);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1181,7 +1189,8 @@ add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) ...@@ -1181,7 +1189,8 @@ add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur)
} }
/* prepend this zone */ /* prepend this zone */
if ((index = get_index(cur->bank, cur->instr, cur->v.low)) < 0) index = get_index(cur->bank, cur->instr, cur->v.low);
if (index < 0)
return; return;
cur->next_zone = zone; /* zone link */ cur->next_zone = zone; /* zone link */
cur->next_instr = sflist->presets[index]; /* preset table link */ cur->next_instr = sflist->presets[index]; /* preset table link */
...@@ -1197,7 +1206,8 @@ delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp) ...@@ -1197,7 +1206,8 @@ delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp)
int index; int index;
struct snd_sf_zone *p; struct snd_sf_zone *p;
if ((index = get_index(zp->bank, zp->instr, zp->v.low)) < 0) index = get_index(zp->bank, zp->instr, zp->v.low);
if (index < 0)
return; return;
for (p = sflist->presets[index]; p; p = p->next_instr) { for (p = sflist->presets[index]; p; p = p->next_instr) {
while (p->next_instr == zp) { while (p->next_instr == zp) {
...@@ -1257,7 +1267,8 @@ search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key) ...@@ -1257,7 +1267,8 @@ search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key)
int index; int index;
struct snd_sf_zone *zp; struct snd_sf_zone *zp;
if ((index = get_index(bank, preset, key)) < 0) index = get_index(bank, preset, key);
if (index < 0)
return NULL; return NULL;
for (zp = sflist->presets[index]; zp; zp = zp->next_instr) { for (zp = sflist->presets[index]; zp; zp = zp->next_instr) {
if (zp->instr == preset && zp->bank == bank) if (zp->instr == preset && zp->bank == bank)
...@@ -1386,7 +1397,8 @@ snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr) ...@@ -1386,7 +1397,8 @@ snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr)
{ {
struct snd_sf_list *sflist; struct snd_sf_list *sflist;
if ((sflist = kzalloc(sizeof(*sflist), GFP_KERNEL)) == NULL) sflist = kzalloc(sizeof(*sflist), GFP_KERNEL);
if (!sflist)
return NULL; return NULL;
mutex_init(&sflist->presets_mutex); mutex_init(&sflist->presets_mutex);
......
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