Skip to content

Commit 486da11

Browse files
Jiangshan YiJiri Kosina
authored andcommitted
HID: rmi: replace ternary operator with min()
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 8d9420c commit 486da11

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/hid/hid-rmi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
237237

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

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

350-
memcpy(hdata->readReport, data, size < hdata->input_report_size ?
351-
size : hdata->input_report_size);
349+
memcpy(hdata->readReport, data, min((u32)size, hdata->input_report_size));
352350
set_bit(RMI_READ_DATA_PENDING, &hdata->flags);
353351
wake_up(&hdata->wait);
354352

0 commit comments

Comments
 (0)