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

Configure Feed

Select the types of activity you want to include in your feed.

rtla/timerlat: Simplify RTLA_NO_BPF environment variable check

The code that checks the RTLA_NO_BPF environment variable calls
getenv() twice and uses strncmp() with a length of 2 to compare
against the single-character string "1". This is inefficient and
the comparison length is unnecessarily long.

Store the result of getenv() in a local variable to avoid the
redundant call, and replace strncmp() with strncmp_static() for
the exact match comparison. This follows the same pattern
established in recent commits that improved string comparison
consistency throughout the rtla codebase.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260309195040.1019085-15-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>

authored by

Wander Lairson Costa and committed by
Tomas Glozar
48fbcd4d ea5ea835

+2 -1
+2 -1
tools/tracing/rtla/src/timerlat.c
··· 28 28 timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params) 29 29 { 30 30 int retval; 31 + const char *const rtla_no_bpf = getenv("RTLA_NO_BPF"); 31 32 32 33 /* 33 34 * Try to enable BPF, unless disabled explicitly. 34 35 * If BPF enablement fails, fall back to tracefs mode. 35 36 */ 36 - if (getenv("RTLA_NO_BPF") && strncmp(getenv("RTLA_NO_BPF"), "1", 2) == 0) { 37 + if (rtla_no_bpf && strncmp_static(rtla_no_bpf, "1") == 0) { 37 38 debug_msg("RTLA_NO_BPF set, disabling BPF\n"); 38 39 params->mode = TRACING_MODE_TRACEFS; 39 40 } else if (!tep_find_event_by_name(tool->trace.tep, "osnoise", "timerlat_sample")) {