Skip to content

Commit 48fbcd4

Browse files
walaclenticularis39
authored andcommitted
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>
1 parent ea5ea83 commit 48fbcd4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools/tracing/rtla/src/timerlat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ int
2828
timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)
2929
{
3030
int retval;
31+
const char *const rtla_no_bpf = getenv("RTLA_NO_BPF");
3132

3233
/*
3334
* Try to enable BPF, unless disabled explicitly.
3435
* If BPF enablement fails, fall back to tracefs mode.
3536
*/
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) {
3738
debug_msg("RTLA_NO_BPF set, disabling BPF\n");
3839
params->mode = TRACING_MODE_TRACEFS;
3940
} else if (!tep_find_event_by_name(tool->trace.tep, "osnoise", "timerlat_sample")) {

0 commit comments

Comments
 (0)