[PATCH v4] Add decoding for evdev ioctls.

Dmitry V. Levin ldv at altlinux.org
Tue Feb 17 21:01:25 UTC 2015


On Tue, Feb 17, 2015 at 08:04:06PM +0100, Etienne Gemsa wrote:
[...]
> +		case EVIOCGREP:
> +			if (!verbose(tcp) || umove(tcp, arg, &val) < 0)
> +				return 0;
> +
> +			tprintf(", [delay=%" PRIu32 ", period=%" PRIu32 "]",
> +				val[0], val[1]);
> +				return 1;
[...]
> +		case EVIOCSREP:
> +			if (!verbose(tcp) || umove(tcp, arg, (char *)val) < 0)
> +				return 0;
> +
> +			tprintf(", [delay=%" PRIu32 ", period=%" PRIu32 "]",
> +					val[0], val[1]);
> +			return 1;

These parsers look very similar, doesn't they?
Please create a local function to handle both cases.
Also, please do not confuse structures and arrays:
the former have named members and are marked with {} braces,
the latter have unnamed members and are marked with [] braces.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150218/03b79d6d/attachment.bin>


More information about the Strace-devel mailing list