ALSA: compat_ioctl: use correct snd_ctl_elem_type_t type
PATCH 1/1 ALSA: compat_ioctl: use correct snd_ctl_elem_type_t type
SNDRV_CTL_ELEM_TYPE_* are type of snd_ctl_elem_type_t, we have to __force cast them to int when comparing them with int to fix the following sparse warnings.
sound/core/control_compat.c:203:14: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:205:14: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:207:14: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:209:14: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:237:21: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:238:21: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:270:21: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/core/control_compat.c:271:21: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer
--- sound/core/control_compat.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/core/control_compat.c +7 -7
@@ -197,7 +197,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,return err; } -static int get_elem_size (int type,int count) +static int get_elem_size (snd_ctl_elem_type_t type,int count) {switch (type) {case SNDRV_CTL_ELEM_TYPE_INTEGER64 :
@@ -234,8 +234,8 @@ static int copy_ctl_value_from_user(struct snd_card *card,if (type <0 )return type; -if (type ==SNDRV_CTL_ELEM_TYPE_BOOLEAN || - type ==SNDRV_CTL_ELEM_TYPE_INTEGER ) { +if (type == (__force int )SNDRV_CTL_ELEM_TYPE_BOOLEAN || + type == (__force int )SNDRV_CTL_ELEM_TYPE_INTEGER ) {for (i =0 ; i < count; i++) {s32 __user *intp = valuep;int val;
@@ -244,7 +244,7 @@ static int copy_ctl_value_from_user(struct snd_card *card, data->value.integer.value[i] = val; } }else { - size =get_elem_size (type, count); + size =get_elem_size ((__force snd_ctl_elem_type_t )type, count);if (size <0 ) {dev_err (card->dev,"snd_ioctl32_ctl_elem_value: unknown type %d\n" , type);return -EINVAL ;
@@ -267,8 +267,8 @@ static int copy_ctl_value_to_user(void __user *userdata,struct snd_ctl_elem_value32 __user *data32 = userdata;int i, size; -if (type ==SNDRV_CTL_ELEM_TYPE_BOOLEAN || - type ==SNDRV_CTL_ELEM_TYPE_INTEGER ) { +if (type == (__force int )SNDRV_CTL_ELEM_TYPE_BOOLEAN || + type == (__force int )SNDRV_CTL_ELEM_TYPE_INTEGER ) {for (i =0 ; i < count; i++) {s32 __user *intp = valuep;int val;
@@ -277,7 +277,7 @@ static int copy_ctl_value_to_user(void __user *userdata,return -EFAULT ; } }else { - size =get_elem_size (type, count); + size =get_elem_size ((__force snd_ctl_elem_type_t )type, count);if (copy_to_user (valuep, data->value.bytes.data, size))return -EFAULT ; }
Signature · 1 line
2.34.1
Takashi Iwai
AppliedQuoted 14 lines · Min-Hua Chen
SNDRV_CTL_ELEM_TYPE_* are type of
snd_ctl_elem_type_t, we have to__forcecast them to int when comparing them with int to fix the following sparse warnings.
sound/core/control_compat.c:203:14: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:205:14: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:207:14: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:209:14: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:237:21: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:238:21: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:270:21: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integersound/core/control_compat.c:271:21: sparse: warning: restrictedsnd_ctl_elem_type_tdegrades to integer
Quoted 1 line
Signed-off-by Min-Hua Chen <[email protected]>
Thanks, applied.
Takashi