Browse Source

evdev: remove additional indentation level for switch case labels

And while we are here, factor out evdev_write_ioctl_mpers call
out of the switch statement.

* evdev.c (bit_ioctl, evdev_read_ioctl, evdev_ioctl): Remove
one indentation level inside the switch statements.
(evedev_write_ioctl): Remove one indentation level inside the switch
statement; move default branch out of the switch statement.
Eugene Syromyatnikov 1 month ago
parent
commit
8e033aab60
2 changed files with 156 additions and 157 deletions
  1. 113
    114
      evdev.c
  2. 43
    43
      evdev_mpers.c

+ 113
- 114
evdev.c View File

@@ -259,47 +259,47 @@ bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr,
259 259
 	  const kernel_ulong_t arg)
260 260
 {
261 261
 	switch (ev_nr) {
262
-		case 0:
263
-			return decode_bitset(tcp, arg, evdev_ev,
264
-					     EV_MAX, "EV_???");
265
-		case EV_KEY:
266
-			return decode_bitset(tcp, arg, evdev_keycode,
267
-					     KEY_MAX, "KEY_???");
268
-		case EV_REL:
269
-			return decode_bitset(tcp, arg, evdev_relative_axes,
270
-					     REL_MAX, "REL_???");
271
-		case EV_ABS:
272
-			return decode_bitset(tcp, arg, evdev_abs,
273
-					     ABS_MAX, "ABS_???");
274
-		case EV_MSC:
275
-			return decode_bitset(tcp, arg, evdev_misc,
276
-					     MSC_MAX, "MSC_???");
277
-		case EV_SW:
278
-			return decode_bitset(tcp, arg, evdev_switch,
279
-					     SW_MAX, "SW_???");
280
-		case EV_LED:
281
-			return decode_bitset(tcp, arg, evdev_leds,
282
-					     LED_MAX, "LED_???");
283
-		case EV_SND:
284
-			return decode_bitset(tcp, arg, evdev_snd,
285
-					     SND_MAX, "SND_???");
286
-		case EV_REP:
287
-			return decode_bitset(tcp, arg, evdev_autorepeat,
288
-					     REP_MAX, "REP_???");
289
-		case EV_FF:
290
-			return decode_bitset(tcp, arg, evdev_ff_types,
291
-					     FF_MAX, "FF_???");
292
-		case EV_PWR:
293
-			tprints(", ");
294
-			printnum_int(tcp, arg, "%d");
295
-			return RVAL_IOCTL_DECODED;
296
-		case EV_FF_STATUS:
297
-			return decode_bitset(tcp, arg, evdev_ff_status,
298
-					     FF_STATUS_MAX, "FF_STATUS_???");
299
-		default:
300
-			tprints(", ");
301
-			printaddr(arg);
302
-			return RVAL_IOCTL_DECODED;
262
+	case 0:
263
+		return decode_bitset(tcp, arg, evdev_ev,
264
+				     EV_MAX, "EV_???");
265
+	case EV_KEY:
266
+		return decode_bitset(tcp, arg, evdev_keycode,
267
+				     KEY_MAX, "KEY_???");
268
+	case EV_REL:
269
+		return decode_bitset(tcp, arg, evdev_relative_axes,
270
+				     REL_MAX, "REL_???");
271
+	case EV_ABS:
272
+		return decode_bitset(tcp, arg, evdev_abs,
273
+				     ABS_MAX, "ABS_???");
274
+	case EV_MSC:
275
+		return decode_bitset(tcp, arg, evdev_misc,
276
+				     MSC_MAX, "MSC_???");
277
+	case EV_SW:
278
+		return decode_bitset(tcp, arg, evdev_switch,
279
+				     SW_MAX, "SW_???");
280
+	case EV_LED:
281
+		return decode_bitset(tcp, arg, evdev_leds,
282
+				     LED_MAX, "LED_???");
283
+	case EV_SND:
284
+		return decode_bitset(tcp, arg, evdev_snd,
285
+				     SND_MAX, "SND_???");
286
+	case EV_REP:
287
+		return decode_bitset(tcp, arg, evdev_autorepeat,
288
+				     REP_MAX, "REP_???");
289
+	case EV_FF:
290
+		return decode_bitset(tcp, arg, evdev_ff_types,
291
+				     FF_MAX, "FF_???");
292
+	case EV_PWR:
293
+		tprints(", ");
294
+		printnum_int(tcp, arg, "%d");
295
+		return RVAL_IOCTL_DECODED;
296
+	case EV_FF_STATUS:
297
+		return decode_bitset(tcp, arg, evdev_ff_status,
298
+				     FF_STATUS_MAX, "FF_STATUS_???");
299
+	default:
300
+		tprints(", ");
301
+		printaddr(arg);
302
+		return RVAL_IOCTL_DECODED;
303 303
 	}
304 304
 }
305 305
 
@@ -309,62 +309,62 @@ evdev_read_ioctl(struct tcb *const tcp, const unsigned int code,
309 309
 {
310 310
 	/* fixed-number fixed-length commands */
311 311
 	switch (code) {
312
-		case EVIOCGVERSION:
313
-			tprints(", ");
314
-			printnum_int(tcp, arg, "%#x");
315
-			return RVAL_IOCTL_DECODED;
316
-		case EVIOCGEFFECTS:
317
-			tprints(", ");
318
-			printnum_int(tcp, arg, "%u");
319
-			return RVAL_IOCTL_DECODED;
320
-		case EVIOCGID:
321
-			return getid_ioctl(tcp, arg);
312
+	case EVIOCGVERSION:
313
+		tprints(", ");
314
+		printnum_int(tcp, arg, "%#x");
315
+		return RVAL_IOCTL_DECODED;
316
+	case EVIOCGEFFECTS:
317
+		tprints(", ");
318
+		printnum_int(tcp, arg, "%u");
319
+		return RVAL_IOCTL_DECODED;
320
+	case EVIOCGID:
321
+		return getid_ioctl(tcp, arg);
322 322
 # ifdef EVIOCGREP
323
-		case EVIOCGREP:
324
-			return repeat_ioctl(tcp, arg);
323
+	case EVIOCGREP:
324
+		return repeat_ioctl(tcp, arg);
325 325
 # endif
326
-		case EVIOCGKEYCODE:
327
-			return keycode_ioctl(tcp, arg);
326
+	case EVIOCGKEYCODE:
327
+		return keycode_ioctl(tcp, arg);
328 328
 # ifdef EVIOCGKEYCODE_V2
329
-		case EVIOCGKEYCODE_V2:
330
-			return keycode_V2_ioctl(tcp, arg);
329
+	case EVIOCGKEYCODE_V2:
330
+		return keycode_V2_ioctl(tcp, arg);
331 331
 # endif
332 332
 	}
333 333
 
334 334
 	/* fixed-number variable-length commands */
335 335
 	switch (_IOC_NR(code)) {
336 336
 # ifdef EVIOCGMTSLOTS
337
-		case _IOC_NR(EVIOCGMTSLOTS(0)):
338
-			return mtslots_ioctl(tcp, code, arg);
337
+	case _IOC_NR(EVIOCGMTSLOTS(0)):
338
+		return mtslots_ioctl(tcp, code, arg);
339 339
 # endif
340
-		case _IOC_NR(EVIOCGNAME(0)):
341
-		case _IOC_NR(EVIOCGPHYS(0)):
342
-		case _IOC_NR(EVIOCGUNIQ(0)):
343
-			tprints(", ");
344
-			if (syserror(tcp))
345
-				printaddr(arg);
346
-			else
347
-				printstrn(tcp, arg, tcp->u_rval);
348
-			return RVAL_IOCTL_DECODED;
340
+	case _IOC_NR(EVIOCGNAME(0)):
341
+	case _IOC_NR(EVIOCGPHYS(0)):
342
+	case _IOC_NR(EVIOCGUNIQ(0)):
343
+		tprints(", ");
344
+		if (syserror(tcp))
345
+			printaddr(arg);
346
+		else
347
+			printstrn(tcp, arg, tcp->u_rval);
348
+		return RVAL_IOCTL_DECODED;
349 349
 # ifdef EVIOCGPROP
350
-		case _IOC_NR(EVIOCGPROP(0)):
351
-			return decode_bitset(tcp, arg, evdev_prop,
352
-					     INPUT_PROP_MAX, "PROP_???");
350
+	case _IOC_NR(EVIOCGPROP(0)):
351
+		return decode_bitset(tcp, arg, evdev_prop,
352
+				     INPUT_PROP_MAX, "PROP_???");
353 353
 # endif
354
-		case _IOC_NR(EVIOCGSND(0)):
355
-			return decode_bitset(tcp, arg, evdev_snd,
356
-					     SND_MAX, "SND_???");
354
+	case _IOC_NR(EVIOCGSND(0)):
355
+		return decode_bitset(tcp, arg, evdev_snd,
356
+				     SND_MAX, "SND_???");
357 357
 # ifdef EVIOCGSW
358
-		case _IOC_NR(EVIOCGSW(0)):
359
-			return decode_bitset(tcp, arg, evdev_switch,
360
-					     SW_MAX, "SW_???");
358
+	case _IOC_NR(EVIOCGSW(0)):
359
+		return decode_bitset(tcp, arg, evdev_switch,
360
+				     SW_MAX, "SW_???");
361 361
 # endif
362
-		case _IOC_NR(EVIOCGKEY(0)):
363
-			return decode_bitset(tcp, arg, evdev_keycode,
364
-					     KEY_MAX, "KEY_???");
365
-		case _IOC_NR(EVIOCGLED(0)):
366
-			return decode_bitset(tcp, arg, evdev_leds,
367
-					     LED_MAX, "LED_???");
362
+	case _IOC_NR(EVIOCGKEY(0)):
363
+		return decode_bitset(tcp, arg, evdev_keycode,
364
+				     KEY_MAX, "KEY_???");
365
+	case _IOC_NR(EVIOCGLED(0)):
366
+		return decode_bitset(tcp, arg, evdev_leds,
367
+				     LED_MAX, "LED_???");
368 368
 	}
369 369
 
370 370
 	/* multi-number fixed-length commands */
@@ -385,38 +385,37 @@ evdev_write_ioctl(struct tcb *const tcp, const unsigned int code,
385 385
 	/* fixed-number fixed-length commands */
386 386
 	switch (code) {
387 387
 # ifdef EVIOCSREP
388
-		case EVIOCSREP:
389
-			return repeat_ioctl(tcp, arg);
388
+	case EVIOCSREP:
389
+		return repeat_ioctl(tcp, arg);
390 390
 # endif
391
-		case EVIOCSKEYCODE:
392
-			return keycode_ioctl(tcp, arg);
391
+	case EVIOCSKEYCODE:
392
+		return keycode_ioctl(tcp, arg);
393 393
 # ifdef EVIOCSKEYCODE_V2
394
-		case EVIOCSKEYCODE_V2:
395
-			return keycode_V2_ioctl(tcp, arg);
394
+	case EVIOCSKEYCODE_V2:
395
+		return keycode_V2_ioctl(tcp, arg);
396 396
 # endif
397
-		case EVIOCRMFF:
398
-			tprintf(", %d", (int) arg);
399
-			return RVAL_IOCTL_DECODED;
400
-		case EVIOCGRAB:
397
+	case EVIOCRMFF:
398
+		tprintf(", %d", (int) arg);
399
+		return RVAL_IOCTL_DECODED;
400
+	case EVIOCGRAB:
401 401
 # ifdef EVIOCREVOKE
402
-		case EVIOCREVOKE:
402
+	case EVIOCREVOKE:
403 403
 # endif
404
-			tprintf(", %" PRI_klu, arg);
405
-			return RVAL_IOCTL_DECODED;
404
+		tprintf(", %" PRI_klu, arg);
405
+		return RVAL_IOCTL_DECODED;
406 406
 # ifdef EVIOCSCLOCKID
407
-		case EVIOCSCLOCKID:
408
-			tprints(", ");
409
-			printnum_int(tcp, arg, "%u");
410
-			return RVAL_IOCTL_DECODED;
407
+	case EVIOCSCLOCKID:
408
+		tprints(", ");
409
+		printnum_int(tcp, arg, "%u");
410
+		return RVAL_IOCTL_DECODED;
411 411
 # endif
412
-		default: {
413
-			int rc = evdev_write_ioctl_mpers(tcp, code, arg);
414
-
415
-			if (rc != RVAL_DECODED)
416
-				return rc;
417
-		}
418 412
 	}
419 413
 
414
+	int rc = evdev_write_ioctl_mpers(tcp, code, arg);
415
+
416
+	if (rc != RVAL_DECODED)
417
+		return rc;
418
+
420 419
 	/* multi-number fixed-length commands */
421 420
 	if ((_IOC_NR(code) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0)))
422 421
 		return abs_ioctl(tcp, arg);
@@ -435,14 +434,14 @@ evdev_ioctl(struct tcb *const tcp,
435 434
 	    const unsigned int code, const kernel_ulong_t arg)
436 435
 {
437 436
 	switch (_IOC_DIR(code)) {
438
-		case _IOC_READ:
439
-			if (entering(tcp))
440
-				return 0;
441
-			return evdev_read_ioctl(tcp, code, arg);
442
-		case _IOC_WRITE:
443
-			return evdev_write_ioctl(tcp, code, arg) | RVAL_DECODED;
444
-		default:
445
-			return RVAL_DECODED;
437
+	case _IOC_READ:
438
+		if (entering(tcp))
439
+			return 0;
440
+		return evdev_read_ioctl(tcp, code, arg);
441
+	case _IOC_WRITE:
442
+		return evdev_write_ioctl(tcp, code, arg) | RVAL_DECODED;
443
+	default:
444
+		return RVAL_DECODED;
446 445
 	}
447 446
 }
448 447
 

+ 43
- 43
evdev_mpers.c View File

@@ -71,45 +71,45 @@ ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
71 71
 		ffe.replay.delay);
72 72
 
73 73
 	switch (ffe.type) {
74
-		case FF_CONSTANT:
75
-			tprintf(", constant={level=%" PRId16,
76
-				ffe.u.constant.level);
77
-			decode_envelope(&ffe.u.constant.envelope);
78
-			tprints("}");
79
-			break;
80
-		case FF_RAMP:
81
-			tprintf(", ramp={start_level=%" PRId16
82
-				", end_level=%" PRId16,
83
-				ffe.u.ramp.start_level,
84
-				ffe.u.ramp.end_level);
85
-			decode_envelope(&ffe.u.ramp.envelope);
86
-			tprints("}");
87
-			break;
88
-		case FF_PERIODIC:
89
-			tprintf(", periodic={waveform=%" PRIu16
90
-				", period=%" PRIu16
91
-				", magnitude=%" PRId16
92
-				", offset=%" PRId16
93
-				", phase=%" PRIu16,
94
-				ffe.u.periodic.waveform,
95
-				ffe.u.periodic.period,
96
-				ffe.u.periodic.magnitude,
97
-				ffe.u.periodic.offset,
98
-				ffe.u.periodic.phase);
99
-			decode_envelope(&ffe.u.periodic.envelope);
100
-			tprintf(", custom_len=%u, custom_data=",
101
-				ffe.u.periodic.custom_len);
102
-			printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
103
-			tprints("}");
104
-			break;
105
-		case FF_RUMBLE:
106
-			tprintf(", rumble={strong_magnitude=%" PRIu16
107
-				", weak_magnitude=%" PRIu16 "}",
108
-				ffe.u.rumble.strong_magnitude,
109
-				ffe.u.rumble.weak_magnitude);
110
-			break;
111
-		default:
112
-			break;
74
+	case FF_CONSTANT:
75
+		tprintf(", constant={level=%" PRId16,
76
+			ffe.u.constant.level);
77
+		decode_envelope(&ffe.u.constant.envelope);
78
+		tprints("}");
79
+		break;
80
+	case FF_RAMP:
81
+		tprintf(", ramp={start_level=%" PRId16
82
+			", end_level=%" PRId16,
83
+			ffe.u.ramp.start_level,
84
+			ffe.u.ramp.end_level);
85
+		decode_envelope(&ffe.u.ramp.envelope);
86
+		tprints("}");
87
+		break;
88
+	case FF_PERIODIC:
89
+		tprintf(", periodic={waveform=%" PRIu16
90
+			", period=%" PRIu16
91
+			", magnitude=%" PRId16
92
+			", offset=%" PRId16
93
+			", phase=%" PRIu16,
94
+			ffe.u.periodic.waveform,
95
+			ffe.u.periodic.period,
96
+			ffe.u.periodic.magnitude,
97
+			ffe.u.periodic.offset,
98
+			ffe.u.periodic.phase);
99
+		decode_envelope(&ffe.u.periodic.envelope);
100
+		tprintf(", custom_len=%u, custom_data=",
101
+			ffe.u.periodic.custom_len);
102
+		printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
103
+		tprints("}");
104
+		break;
105
+	case FF_RUMBLE:
106
+		tprintf(", rumble={strong_magnitude=%" PRIu16
107
+			", weak_magnitude=%" PRIu16 "}",
108
+			ffe.u.rumble.strong_magnitude,
109
+			ffe.u.rumble.weak_magnitude);
110
+		break;
111
+	default:
112
+		break;
113 113
 	}
114 114
 
115 115
 	tprints("}");
@@ -121,10 +121,10 @@ MPERS_PRINTER_DECL(int, evdev_write_ioctl_mpers, struct tcb *const tcp,
121 121
 		   const unsigned int code, const kernel_ulong_t arg)
122 122
 {
123 123
 	switch (code) {
124
-		case EVIOCSFF:
125
-			return ff_effect_ioctl(tcp, arg);
126
-		default:
127
-			return RVAL_DECODED;
124
+	case EVIOCSFF:
125
+		return ff_effect_ioctl(tcp, arg);
126
+	default:
127
+		return RVAL_DECODED;
128 128
 	}
129 129
 }
130 130
 

Loading…
Cancel
Save