Commit 005874c5 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Greg Kroah-Hartman

vfio-mdev/samples: Use u8 instead of char for handle functions

[ Upstream commit 8ba35b3a ]

Clang warns:

samples/vfio-mdev/mtty.c:592:39: warning: implicit conversion from 'int'
to 'char' changes value from 162 to -94 [-Wconstant-conversion]
                *buf = UART_MSR_DSR | UART_MSR_DDSR | UART_MSR_DCD;
                     ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
1 warning generated.

Turns out that all uses of buf in this function ultimately end up stored
or cast to an unsigned type. Just use u8, which has the same number of
bits but can store this larger number so Clang no longer warns.
Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 962b1f6b
...@@ -171,7 +171,7 @@ static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid) ...@@ -171,7 +171,7 @@ static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid)
return NULL; return NULL;
} }
void dump_buffer(char *buf, uint32_t count) void dump_buffer(u8 *buf, uint32_t count)
{ {
#if defined(DEBUG) #if defined(DEBUG)
int i; int i;
...@@ -250,7 +250,7 @@ static void mtty_create_config_space(struct mdev_state *mdev_state) ...@@ -250,7 +250,7 @@ static void mtty_create_config_space(struct mdev_state *mdev_state)
} }
static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset, static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count) u8 *buf, u32 count)
{ {
u32 cfg_addr, bar_mask, bar_index = 0; u32 cfg_addr, bar_mask, bar_index = 0;
...@@ -304,7 +304,7 @@ static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset, ...@@ -304,7 +304,7 @@ static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
} }
static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
u16 offset, char *buf, u32 count) u16 offset, u8 *buf, u32 count)
{ {
u8 data = *buf; u8 data = *buf;
...@@ -475,7 +475,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -475,7 +475,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
} }
static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state, static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
u16 offset, char *buf, u32 count) u16 offset, u8 *buf, u32 count)
{ {
/* Handle read requests by guest */ /* Handle read requests by guest */
switch (offset) { switch (offset) {
...@@ -650,7 +650,7 @@ static void mdev_read_base(struct mdev_state *mdev_state) ...@@ -650,7 +650,7 @@ static void mdev_read_base(struct mdev_state *mdev_state)
} }
} }
static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,
loff_t pos, bool is_write) loff_t pos, bool is_write)
{ {
struct mdev_state *mdev_state; struct mdev_state *mdev_state;
...@@ -698,7 +698,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, ...@@ -698,7 +698,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
#if defined(DEBUG_REGS) #if defined(DEBUG_REGS)
pr_info("%s: BAR%d WR @0x%llx %s val:0x%02x dlab:%d\n", pr_info("%s: BAR%d WR @0x%llx %s val:0x%02x dlab:%d\n",
__func__, index, offset, wr_reg[offset], __func__, index, offset, wr_reg[offset],
(u8)*buf, mdev_state->s[index].dlab); *buf, mdev_state->s[index].dlab);
#endif #endif
handle_bar_write(index, mdev_state, offset, buf, count); handle_bar_write(index, mdev_state, offset, buf, count);
} else { } else {
...@@ -708,7 +708,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, ...@@ -708,7 +708,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
#if defined(DEBUG_REGS) #if defined(DEBUG_REGS)
pr_info("%s: BAR%d RD @0x%llx %s val:0x%02x dlab:%d\n", pr_info("%s: BAR%d RD @0x%llx %s val:0x%02x dlab:%d\n",
__func__, index, offset, rd_reg[offset], __func__, index, offset, rd_reg[offset],
(u8)*buf, mdev_state->s[index].dlab); *buf, mdev_state->s[index].dlab);
#endif #endif
} }
break; break;
...@@ -827,7 +827,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count, ...@@ -827,7 +827,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
if (count >= 4 && !(*ppos % 4)) { if (count >= 4 && !(*ppos % 4)) {
u32 val; u32 val;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, false); *ppos, false);
if (ret <= 0) if (ret <= 0)
goto read_err; goto read_err;
...@@ -839,7 +839,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count, ...@@ -839,7 +839,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
} else if (count >= 2 && !(*ppos % 2)) { } else if (count >= 2 && !(*ppos % 2)) {
u16 val; u16 val;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, false); *ppos, false);
if (ret <= 0) if (ret <= 0)
goto read_err; goto read_err;
...@@ -851,7 +851,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count, ...@@ -851,7 +851,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
} else { } else {
u8 val; u8 val;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, false); *ppos, false);
if (ret <= 0) if (ret <= 0)
goto read_err; goto read_err;
...@@ -889,7 +889,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf, ...@@ -889,7 +889,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
if (copy_from_user(&val, buf, sizeof(val))) if (copy_from_user(&val, buf, sizeof(val)))
goto write_err; goto write_err;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, true); *ppos, true);
if (ret <= 0) if (ret <= 0)
goto write_err; goto write_err;
...@@ -901,7 +901,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf, ...@@ -901,7 +901,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
if (copy_from_user(&val, buf, sizeof(val))) if (copy_from_user(&val, buf, sizeof(val)))
goto write_err; goto write_err;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, true); *ppos, true);
if (ret <= 0) if (ret <= 0)
goto write_err; goto write_err;
...@@ -913,7 +913,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf, ...@@ -913,7 +913,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
if (copy_from_user(&val, buf, sizeof(val))) if (copy_from_user(&val, buf, sizeof(val)))
goto write_err; goto write_err;
ret = mdev_access(mdev, (char *)&val, sizeof(val), ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
*ppos, true); *ppos, true);
if (ret <= 0) if (ret <= 0)
goto write_err; goto write_err;
......
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