Go to file
Steven Rostedt (Google) 7604256cec tracing: Add __string_src() helper to help compilers not to get confused
The __string() helper macro of the TRACE_EVENT() macro is used to
determine how much of the ring buffer needs to be allocated to fit the
given source string. Some trace events have a string that is dependent on
another variable that could be NULL, and in those cases the string is
passed in to be NULL.

The __string() macro can handle being passed in a NULL pointer for which
it will turn it into "(null)". It does that with:

  strlen((src) ? (const char *)(src) : "(null)") + 1

But if src itself has the same conditional type it can confuse the
compiler. That is:

  __string(r ? dev(r)->name : NULL)

Would turn into:

 strlen((r ? dev(r)->name : NULL) ? (r ? dev(r)->name : NULL) : "(null)" + 1

For which the compiler thinks that NULL is being passed to strlen() and
gives this kind of warning:

./include/trace/stages/stage5_get_offsets.h:50:21: warning: argument 1 null where non-null expected [-Wnonnull]
   50 |                     strlen((src) ? (const char *)(src) : "(null)") + 1)

Instead, create a static inline function that takes the src string and
will return the string if it is not NULL and will return "(null)" if it
is. This will then make the strlen() line:

 strlen(__string_src(src)) + 1

Where the compiler can see that strlen() will not end up with NULL and
does not warn about it.

Note that this depends on commit 51270d573a ("tracing/net_sched: Fix
tracepoints that save qdisc_dev() as a string") being applied, as passing
the qdisc_dev() into __string_src() will give an error.

Link: https://lore.kernel.org/all/ZfNmfCmgCs4Nc+EH@aschofie-mobl2/
Link: https://lore.kernel.org/linux-trace-kernel/20240314232754.345cea82@rorschach.local.home

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reported-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2024-03-18 10:33:06 -04:00
Documentation tracing: Support to dump instance traces by ftrace_dump_on_oops 2024-03-18 10:33:06 -04:00
LICENSES LICENSES: Add the copyleft-next-0.3.1 license 2022-11-08 15:44:01 +01:00
arch Probes updates for v6.9: 2024-03-14 16:16:33 -07:00
block Revert "dm: use queue_limits_set" 2024-03-11 17:11:28 -07:00
certs This update includes the following changes: 2023-11-02 16:15:30 -10:00
crypto crypto: lskcipher - Copy IV in lskcipher glue code always 2024-02-24 08:37:24 +08:00
drivers cxl/trace: Properly initialize cxl_poison region name 2024-03-18 10:26:03 -04:00
fs tracing: Remove __assign_str_len() 2024-03-18 10:33:05 -04:00
include tracing: Add __string_src() helper to help compilers not to get confused 2024-03-18 10:33:06 -04:00
init Modules changes for v6.9-rc1 2024-03-13 12:40:58 -07:00
io_uring for-6.9/io_uring-20240310 2024-03-11 11:35:31 -07:00
ipc shm: Slim down dependencies 2023-12-20 19:26:31 -05:00
kernel tracing: Use div64_u64() instead of do_div() 2024-03-18 10:33:06 -04:00
lib pci-v6.9-changes 2024-03-14 10:58:27 -07:00
mm \n 2024-03-13 14:30:58 -07:00
net mm, slab: remove last vestiges of SLAB_MEM_SPREAD 2024-03-12 20:32:19 -07:00
rust arm64 updates for 6.9: 2024-03-14 15:35:42 -07:00
samples tracing: Remove second parameter to __assign_rel_str() 2024-03-18 10:33:05 -04:00
scripts arm64 updates for 6.9: 2024-03-14 15:35:42 -07:00
security lsm/stable-6.9 PR 20240314 2024-03-14 16:05:20 -07:00
sound sound updates for 6.9-rc1 2024-03-14 11:10:43 -07:00
tools selftests/user_events: Test multi-format events 2024-03-18 10:13:12 -04:00
usr Kbuild updates for v6.8 2024-01-18 17:57:07 -08:00
virt KVM: Make KVM_MEM_GUEST_MEMFD mutually exclusive with KVM_MEM_READONLY 2024-02-22 17:07:06 -08:00
.clang-format clang-format: Update with v6.7-rc4's `for_each` macro list 2023-12-08 23:54:38 +01:00
.cocciconfig
.editorconfig Add .editorconfig file for basic formatting 2023-12-28 16:22:47 +09:00
.get_maintainer.ignore Add Jeff Kirsher to .get_maintainer.ignore 2024-03-08 11:36:54 +00:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore Add .editorconfig file for basic formatting 2023-12-28 16:22:47 +09:00
.mailmap Networking changes for 6.9. 2024-03-12 17:44:08 -07:00
.rustfmt.toml rust: add `.rustfmt.toml` 2022-09-28 09:02:20 +02:00
COPYING
CREDITS vfs-6.9.ntfs 2024-03-11 09:55:17 -07:00
Kbuild Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS arm64 updates for 6.9: 2024-03-14 15:35:42 -07:00
Makefile arm64 updates for 6.9: 2024-03-14 15:35:42 -07:00
README README: Fix spelling/capitalization 2024-02-12 16:42:13 -07:00

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the ReStructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.