Skip to content

Commit

Permalink
drivers/cps-hid.c: cps_fix_report_desc(): simplify sizeMax now that o…
Browse files Browse the repository at this point in the history
…riginal error was caught [#2718]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
  • Loading branch information
jimklimov committed Dec 17, 2024
1 parent 2699838 commit b249c99
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/cps-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,10 @@ static int cps_fix_report_desc(HIDDevice_t *pDev, HIDDesc_t *pDesc_arg) {
* note that in HIDParse() we likely
* set 65535 here in that case. See
* also comments there (hidparser.c).
* Also had to split last "-1" due to
* misfire of "-Werror=parentheses".
*/
long sizeMax = 1L << (input_pData->Size - 1);
if (input_logmax >= sizeMax) {
input_logmax = sizeMax - 1;
long sizeMax = (1L << (input_pData->Size - 1)) - 1;
if (input_logmax > sizeMax) {
input_logmax = sizeMax;
}
}

Expand All @@ -473,9 +471,9 @@ static int cps_fix_report_desc(HIDDevice_t *pDev, HIDDesc_t *pDesc_arg) {
&& output_pData->Size <= sizeof(long)*8
) {
/* See comment above */
long sizeMax = 1L << (output_pData->Size - 1);
if (output_logmax >= sizeMax) {
output_logmax = sizeMax - 1;
long sizeMax = (1L << (output_pData->Size - 1)) - 1;
if (output_logmax > sizeMax) {
output_logmax = sizeMax;
}
}

Expand Down

0 comments on commit b249c99

Please sign in to comment.