Skip to content

Commit 74534ef

Browse files
wpwrakSebastien Bourdeauducq
authored and
Sebastien Bourdeauducq
committedNov 1, 2011
input.c: remove unnecessary casts
This patch to Flickernoise removes a number of casts that serve no purpose and - in the case of handle_midi_msg - clutter code that needs some more fixing. I didn't run the code but I checked that the assembler output is equivalent. It's not identical because the line numbers of four asserts changed. There is a bit more redundancy in the form of ... | (foo << bar) | ... which could be written as ... | foo << bar | ... I didn't touch these since some people prefer the parentheses as part of their coding style. If you want such things gone as well, please let me know. - Werner
1 parent 0239b6c commit 74534ef

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed
 

‎src/input.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ static int handle_mouse_event(mtk_event *e, unsigned char *msg)
6767
unsigned int mstate;
6868
int n;
6969

70-
mstate = ((unsigned int)msg[0] << 24)
71-
|((unsigned int)msg[1] << 16)
72-
|((unsigned int)msg[2] << 8)
73-
|((unsigned int)msg[3]);
70+
mstate = (msg[0] << 24) | (msg[1] << 16) | (msg[2] << 8) | msg[3];
7471

7572
n = 0;
7673
/* left mouse button pressed */
@@ -237,19 +234,19 @@ static int handle_ir_event(mtk_event *e, unsigned char *msg)
237234

238235
static int handle_midi_msg(mtk_event *e, unsigned char *msg)
239236
{
240-
e->press.code = ((unsigned int)(msg[0]) & 0x0f) << 16; /* set channel */
237+
e->press.code = (msg[0] & 0x0f) << 16; /* set channel */
241238
switch(msg[0] & 0xf0) {
242239
case 0x90: /* Note On */
243240
e->type = EVENT_TYPE_MIDI_NOTEON;
244-
e->press.code |= (unsigned int)msg[1];
241+
e->press.code |= msg[1];
245242
return 1;
246243
case 0xb0: /* Controller */
247244
e->type = EVENT_TYPE_MIDI_CONTROLLER;
248-
e->press.code |= ((unsigned int)msg[1] << 8) | (unsigned int)msg[2];
245+
e->press.code |= (msg[1] << 8) | msg[2];
249246
return 1;
250247
case 0xe0: /* Pitch */
251248
e->type = EVENT_TYPE_MIDI_PITCH;
252-
e->press.code |= (unsigned int)msg[2];
249+
e->press.code |= msg[2];
253250
return 1;
254251
default:
255252
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.