Skip to content

Commit c8fd8e5

Browse files
committed
Replace strlen with sizeof
We know the size of the ps/2 init bytes at compile time. No need to call strlen.
1 parent 5f3cd22 commit c8fd8e5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kdrive/linux/mouse.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,7 @@ static const KmouseProt exps2Prot = {
386386
#define PSM_4DPLUS_ID 8
387387

388388
static const unsigned char ps2_init[] = {
389-
PSMC_ENABLE_DEV,
390-
0,
389+
PSMC_ENABLE_DEV
391390
};
392391

393392
#define NINIT_PS2 1
@@ -397,7 +396,6 @@ static const unsigned char wheel_3button_init[] = {
397396
PSMC_SET_SAMPLING_RATE, 100,
398397
PSMC_SET_SAMPLING_RATE, 80,
399398
PSMC_SEND_DEV_ID,
400-
0,
401399
};
402400

403401
#define NINIT_IMPS2 4
@@ -410,7 +408,6 @@ static const unsigned char wheel_5button_init[] = {
410408
PSMC_SET_SAMPLING_RATE, 200,
411409
PSMC_SET_SAMPLING_RATE, 80,
412410
PSMC_SEND_DEV_ID,
413-
0
414411
};
415412

416413
#define NINIT_EXPS2 7
@@ -419,7 +416,6 @@ static const unsigned char intelli_init[] = {
419416
PSMC_SET_SAMPLING_RATE, 200,
420417
PSMC_SET_SAMPLING_RATE, 100,
421418
PSMC_SET_SAMPLING_RATE, 80,
422-
0
423419
};
424420

425421
#define NINIT_INTELLI 3
@@ -456,9 +452,10 @@ static Bool ps2Init(KdMouseInfo * mi)
456452
int id;
457453
const unsigned char *init;
458454
int ninit;
455+
int len;
459456

460457
/* Send Intellimouse initialization sequence */
461-
MouseWriteBytes(km->iob.fd, intelli_init, strlen((char *)intelli_init),
458+
MouseWriteBytes(km->iob.fd, intelli_init, sizeof(intelli_init),
462459
100);
463460
/*
464461
* Send ID command
@@ -471,20 +468,23 @@ static Bool ps2Init(KdMouseInfo * mi)
471468
init = wheel_3button_init;
472469
ninit = NINIT_IMPS2;
473470
km->prot = &imps2Prot;
471+
len = sizeof(wheel_3button_init);
474472
break;
475473
case 4:
476474
init = wheel_5button_init;
477475
ninit = NINIT_EXPS2;
478476
km->prot = &exps2Prot;
477+
len = sizeof(wheel_5button_init);
479478
break;
480479
default:
481480
init = ps2_init;
482481
ninit = NINIT_PS2;
483482
km->prot = &ps2Prot;
483+
len = sizeof(ps2_init);
484484
break;
485485
}
486486
if (init)
487-
MouseWriteBytes(km->iob.fd, init, strlen((char *)init), 100);
487+
MouseWriteBytes(km->iob.fd, init, len, 100);
488488
/*
489489
* Flush out the available data to eliminate responses to the
490490
* initialization string. Make sure any partial event is

0 commit comments

Comments
 (0)