[bug report] selftests/hid: add tests for bpf_hid_hw_request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Benjamin Tissoires,

The patch 4f7153cf461e: "selftests/hid: add tests for
bpf_hid_hw_request" from Nov 3, 2022, leads to the following Smatch
static checker warning:

	./tools/testing/selftests/hid/hid_bpf.c:214 uhid_event()
	warn: assigning (-5) to unsigned variable 'answer.u.get_report_reply.err'

./tools/testing/selftests/hid/hid_bpf.c
    203         case UHID_CLOSE:
    204                 UHID_LOG("UHID_CLOSE from uhid-dev");
    205                 break;
    206         case UHID_OUTPUT:
    207                 UHID_LOG("UHID_OUTPUT from uhid-dev");
    208                 break;
    209         case UHID_GET_REPORT:
    210                 UHID_LOG("UHID_GET_REPORT from uhid-dev");
    211 
    212                 answer.type = UHID_GET_REPORT_REPLY;
    213                 answer.u.get_report_reply.id = ev.u.get_report.id;
--> 214                 answer.u.get_report_reply.err = ev.u.get_report.rnum == 1 ? 0 : -EIO;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a u16 so it can't hold negative error codes.

    215                 answer.u.get_report_reply.size = sizeof(feature_data);
    216                 memcpy(answer.u.get_report_reply.data, feature_data, sizeof(feature_data));
    217 
    218                 uhid_write(_metadata, fd, &answer);
    219 
    220                 break;
    221         case UHID_SET_REPORT:
    222                 UHID_LOG("UHID_SET_REPORT from uhid-dev");
    223                 break;
    224         default:

regards,
dan carpenter



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux