Re: [PATCH v1] binder: convert `BINDER_*` ioctl `#define`s into an `enum`

From: Arnd Bergmann
Date: Wed May 18 2022 - 03:52:55 EST


On Mon, May 16, 2022 at 11:04 AM Miguel Ojeda <ojeda@xxxxxxxxxx> wrote:
>
> -#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
> -#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
> -#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
> -#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
> -#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
> -#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
> -#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
> -#define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
> -#define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref)
> -#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
> -#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
> -#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
> -#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
> +enum {
> + BINDER_WRITE_READ = _IOWR('b', 1, struct binder_write_read),
> + BINDER_SET_IDLE_TIMEOUT = _IOW('b', 3, __s64),
> + BINDER_SET_MAX_THREADS = _IOW('b', 5, __u32),
> + BINDER_SET_IDLE_PRIORITY = _IOW('b', 6, __s32),
> + BINDER_SET_CONTEXT_MGR = _IOW('b', 7, __s32),
> + BINDER_THREAD_EXIT = _IOW('b', 8, __s32),
> + BINDER_VERSION = _IOWR('b', 9, struct binder_version),

I wonder if that breaks any tools that extract ioctl command number definitions
from kernel headers. I see one other header using enum, but everything else
has the #define. The main user of ioctl command definitions that comes to
mind is 'strace', but I don't know where they get the numbers from.

It's probably not a big deal as long as it's limited to binder, but it
may become
more of a problem if we do this for more subsystems over time.

Arnd