[strace/strace] Add lirc ioctl decoding (PR #208)

Dmitry V. Levin notifications at github.com
Tue Feb 1 10:56:35 UTC 2022


@ldv-alt requested changes on this pull request.

Thank you for your contribution, but the decoder looks too old-fashioned,
please have a look at other ioctl decoders, e.g. src/gpio_ioctl.c and tests/*gpio*.

> @@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2022 Sean Young <sean at mess.org>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "defs.h"
+#include <linux/lirc.h>

<linux/lirc.h> was introduced by Linux kernel commit v4.5-rc1~115^2~360, but strace supports build with older kernel headers.  Consider bundling lirc.h into bundled/linux/include/uapi/linux/.

> +static const struct features {
+	int flag;
+	const char *name;
+} features[] = {
+	{ LIRC_CAN_REC_SCANCODE, "LIRC_CAN_REC_SCANCODE" },
+	{ LIRC_CAN_REC_MODE2, "LIRC_CAN_REC_MODE2" },
+	{ LIRC_CAN_GET_REC_RESOLUTION, "LIRC_CAN_GET_REC_RESOLUTION" },
+	{ LIRC_CAN_SEND_PULSE, "LIRC_CAN_SEND_PULSE" },
+	{ LIRC_CAN_SET_TRANSMITTER_MASK, "LIRC_CAN_SET_TRANSMITTER_MASK" },
+	{ LIRC_CAN_SET_SEND_CARRIER, "LIRC_CAN_SET_SEND_CARRIER" },
+	{ LIRC_CAN_SET_SEND_DUTY_CYCLE, "LIRC_CAN_SET_SEND_DUTY_CYCLE" },
+	{ LIRC_CAN_SET_REC_CARRIER, "LIRC_CAN_SET_REC_CARRIER" },
+	{ LIRC_CAN_SET_REC_CARRIER_RANGE, "LIRC_CAN_SET_REC_CARRIER_RANGE" },
+	{ LIRC_CAN_USE_WIDEBAND_RECEIVER, "LIRC_CAN_USE_WIDEBAND_RECEIVER" },
+	{ LIRC_CAN_MEASURE_CARRIER, "LIRC_CAN_MEASURE_CARRIER" },
+	{ LIRC_CAN_SET_REC_TIMEOUT, "LIRC_CAN_SET_REC_TIMEOUT" },
+};

We replaced this approach with xlat files roughly 8 years ago, please create a xlat file instead.

> +		bool needs_or = false;
+		unsigned long i;
+
+		tprintf(", features=");
+
+		for (i = 0; i < ARRAY_SIZE(features); i++) {
+			if (value & features[i].flag) {
+				if (needs_or)
+					tprintf("|");
+				tprintf("%s", features[i].name);
+				needs_or = true;
+			}
+		}

Please use printflags instead.

> +		switch (value) {
+		case LIRC_MODE_RAW:
+			tprintf(", mode=raw");
+			break;
+		case LIRC_MODE_PULSE:
+			tprintf(", mode=pulse");
+			break;
+		case LIRC_MODE_MODE2:
+			tprintf(", mode=mode2");
+			break;
+		case LIRC_MODE_SCANCODE:
+			tprintf(", mode=scancode");
+			break;
+		case LIRC_MODE_LIRCCODE:
+			tprintf(", mode=lirccode");
+			break;
+		default:
+			tprintf(", mode=%d", value);
+			break;
+		}

Please use printxval instead.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/strace/strace/pull/208#pullrequestreview-868945966
You are receiving this because you are subscribed to this thread.

Message ID: <strace/strace/pull/208/review/868945966 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20220201/fcbe72b9/attachment.htm>


More information about the Strace-devel mailing list