Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vmci_host: print unexpanded names of ioctl requests in debug messages

__stringify macro function expands its arguments, but in this messages
we expect to see ioctl request name instead of it's _IOC macro
expansion.

$ cat stringify.c

#include <stdio.h>
#include <asm/ioctl.h>

#define __stringify_1(x) #x
#define __stringify(x) __stringify_1(x)

#define VMCI_DO_IOCTL(ioctl_name) \
char *name = __stringify(IOCTL_VMCI_ ## ioctl_name);

int main() {
VMCI_DO_IOCTL(INIT_CONTEXT)
printf("%s\n", name);
}
$ cc stringify.c
$ ./a.out
(((0U) << (((0+8)+8)+14)) | (((7)) << (0+8)) | (((0xa0)) << 0) | ((0) << ((0+8)+8)))

Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Link: https://lore.kernel.org/r/20210302153346.300416-1-glebfm@altlinux.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Gleb Fotengauer-Malinovskiy and committed by
Greg Kroah-Hartman
7b7d2261 ac41ae0b

+1 -1
+1 -1
drivers/misc/vmw_vmci/vmci_host.c
··· 908 908 unsigned int iocmd, unsigned long ioarg) 909 909 { 910 910 #define VMCI_DO_IOCTL(ioctl_name, ioctl_fn) do { \ 911 - char *name = __stringify(IOCTL_VMCI_ ## ioctl_name); \ 911 + char *name = "IOCTL_VMCI_" # ioctl_name; \ 912 912 return vmci_host_do_ ## ioctl_fn( \ 913 913 vmci_host_dev, name, uptr); \ 914 914 } while (0)