mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
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 Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com> Link: https://lore.kernel.org/r/20230516223806.185683-1-minhuadotchen@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
committed by
Takashi Iwai
parent
bcdbd3b788
commit
24cdfcb4cc
@@ -197,7 +197,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
|
|||||||
return err;
|
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) {
|
switch (type) {
|
||||||
case SNDRV_CTL_ELEM_TYPE_INTEGER64:
|
case SNDRV_CTL_ELEM_TYPE_INTEGER64:
|
||||||
@@ -234,8 +234,8 @@ static int copy_ctl_value_from_user(struct snd_card *card,
|
|||||||
if (type < 0)
|
if (type < 0)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
|
if (type == (__force int)SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
|
||||||
type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
|
type == (__force int)SNDRV_CTL_ELEM_TYPE_INTEGER) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
s32 __user *intp = valuep;
|
s32 __user *intp = valuep;
|
||||||
int val;
|
int val;
|
||||||
@@ -244,7 +244,7 @@ static int copy_ctl_value_from_user(struct snd_card *card,
|
|||||||
data->value.integer.value[i] = val;
|
data->value.integer.value[i] = val;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size = get_elem_size(type, count);
|
size = get_elem_size((__force snd_ctl_elem_type_t)type, count);
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
dev_err(card->dev, "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
|
dev_err(card->dev, "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -267,8 +267,8 @@ static int copy_ctl_value_to_user(void __user *userdata,
|
|||||||
struct snd_ctl_elem_value32 __user *data32 = userdata;
|
struct snd_ctl_elem_value32 __user *data32 = userdata;
|
||||||
int i, size;
|
int i, size;
|
||||||
|
|
||||||
if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
|
if (type == (__force int)SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
|
||||||
type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
|
type == (__force int)SNDRV_CTL_ELEM_TYPE_INTEGER) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
s32 __user *intp = valuep;
|
s32 __user *intp = valuep;
|
||||||
int val;
|
int val;
|
||||||
@@ -277,7 +277,7 @@ static int copy_ctl_value_to_user(void __user *userdata,
|
|||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
if (copy_to_user(valuep, data->value.bytes.data, size))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user