Skip to content

Commit

Permalink
HID: rmi: replace ternary operator with min()
Browse files Browse the repository at this point in the history
Fix the following coccicheck warning:

drivers/hid/hid-rmi.c:240: WARNING opportunity for min().
drivers/hid/hid-rmi.c:350: WARNING opportunity for min().

min() macro is defined in include/linux/minmax.h. It avoids
multiple evaluations of the arguments when non-constant and performs
strict type-checking.

Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiangshan Yi authored and Jiri Kosina committed Aug 25, 2022
1 parent 8d9420c commit 486da11
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/hid/hid-rmi.c
Original file line number Diff line number Diff line change
@@ -237,8 +237,7 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,

read_input_count = data->readReport[1];
memcpy(buf + bytes_read, &data->readReport[2],
read_input_count < bytes_needed ?
read_input_count : bytes_needed);
min(read_input_count, bytes_needed));

bytes_read += read_input_count;
bytes_needed -= read_input_count;
@@ -347,8 +346,7 @@ static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size)
return 0;
}

memcpy(hdata->readReport, data, size < hdata->input_report_size ?
size : hdata->input_report_size);
memcpy(hdata->readReport, data, min((u32)size, hdata->input_report_size));
set_bit(RMI_READ_DATA_PENDING, &hdata->flags);
wake_up(&hdata->wait);

0 comments on commit 486da11

Please sign in to comment.