[PATCH] ioctl.c: fix the misuse of _IOC_NR

Dmitry V. Levin ldv at altlinux.org
Mon Jul 1 21:53:30 UTC 2019


On Sun, Jun 30, 2019 at 02:03:10PM +0800, Zhibin Li wrote:
> * ioctl.c: We should use _IOC_NR(code) instead of _IOC_NR(nr).
> ---
> This looks like a misuse of _IOC_NR. Though it doesn't change the output
> at all because the value of _IOC_NR(nr) is the same as _IOC_NR(code). I
> guess this is not intended but a typo?
>  ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ioctl.c b/ioctl.c
> index d3205b22..c2146e07 100644
> --- a/ioctl.c
> +++ b/ioctl.c
> @@ -91,7 +91,7 @@ evdev_decode_number(const unsigned int code)
>  		return 1;
>  	}
>  
> -	switch (_IOC_NR(nr)) {
> +	switch (_IOC_NR(code)) {

I agree with your analysis, but I think the fix should rather be

-	switch (_IOC_NR(nr)) {
+	switch (nr) {


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


More information about the Strace-devel mailing list