linux/samples
Arnd Bergmann 56af94aace samples: user-trap: fix strict-aliasing warning
I started getting warnings for this one file, though I can't see what changed
since it was originally introduced in commit fec7b66905 ("samples: add an
example of seccomp user trap").

samples/seccomp/user-trap.c: In function 'send_fd':
samples/seccomp/user-trap.c:50:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   50 |         *((int *)CMSG_DATA(cmsg)) = fd;
      |          ~^~~~~~~~~~~~~~~~~~~~~~~
samples/seccomp/user-trap.c: In function 'recv_fd':
samples/seccomp/user-trap.c:83:18: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   83 |         return *((int *)CMSG_DATA(cmsg));
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~

Using a temporary pointer variable avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240212111737.917428-1-arnd@kernel.org
Acked-by: Tycho Andersen <tandersen@netflix.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
2024-02-12 10:42:02 -08:00
..
acrn virt: acrn: Replace obsolete memalign() with posix_memalign() 2023-04-20 14:20:51 +02:00
auxdisplay
binderfs
bpf samples/bpf: Use %lu format specifier for unsigned long values 2023-12-20 15:28:59 +01:00
cgroup samples/cgroup: add .gitignore file for generated samples 2024-01-24 11:52:40 -08:00
configfs
connector
coresight
fanotify
fprobe fprobe: Pass return address to the handlers 2023-06-06 21:39:55 +09:00
ftrace RISC-V Patches for the 6.8 Merge Window, Part 4 2024-01-20 11:06:04 -08:00
hid bpf: Replace deprecated -target with --target= for Clang 2023-06-29 15:46:17 +02:00
hidraw
hw_breakpoint samples/hw_breakpoint: mark sample_hbp as static 2023-07-26 11:17:19 -07:00
kdb
kfifo
kmemleak kmemleak-test: drop __init to get better backtrace 2023-06-09 16:25:40 -07:00
kobject samples/kobject: make kobj_type structure constant 2023-02-08 13:34:41 +01:00
kprobes samples: kprobes: Fixes a typo 2023-10-10 01:00:50 +09:00
landlock samples/landlock: Support TCP restrictions 2023-10-26 21:07:17 +02:00
livepatch
mei
nitro_enclaves
pfsm samples: Add userspace example for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
pidfd
pktgen samples: pktgen: fix append mode failed issue 2023-07-03 09:15:26 +01:00
qmi
rpmsg
rust samples: rust: print: Add sample code for Arc printing 2023-04-10 05:05:43 +02:00
seccomp samples: user-trap: fix strict-aliasing warning 2024-02-12 10:42:02 -08:00
timers
trace_events samples: Replace strlcpy() with strscpy() 2023-11-30 12:20:53 -08:00
trace_printk
uhid
user_events tracing/user_events: Use write ABI in example 2023-03-29 06:52:09 -04:00
v4l media updates for v6.8-rc1 2024-01-12 14:29:48 -08:00
vfio-mdev eventfd: simplify eventfd_signal() 2023-11-28 14:08:38 +01:00
vfs
watch_queue
watchdog
Kconfig samples: introduce new samples subdir for cgroup 2023-12-10 16:51:54 -08:00
Makefile samples: introduce new samples subdir for cgroup 2023-12-10 16:51:54 -08:00