[LTP] lib: Introduce tst_path_defs.h to consolidate system paths

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Thu Jun 4 13:37:11 CEST 2026


Hi Li,

On Thu Jun 4 17:41:59 2026 +0800, Li Wang wrote:
> lib: Introduce tst_path_defs.h to consolidate system paths

--- [PATCH 1/2] ---

> -		sprintf(g_hpage_path, "%s/%s/%s", PATH_HUGEPAGE,
> +		sprintf(g_hpage_path, "%s/%s/%s", PATH_MM_HUGEPAGES,
>  				ent->d_name, "nr_hugepages");

PATH_MM_HUGEPAGES is defined as "/sys/kernel/mm/hugepages/" (with a
trailing slash). The format string "%s/%s/%s" then adds another slash
between the first and second arguments, producing a path like:

  /sys/kernel/mm/hugepages//hugepages-2048kB/nr_hugepages

The old PATH_HUGEPAGE had no trailing slash, so this double slash is
a regression introduced by the patch.

Linux resolves double slashes transparently, so there is no runtime
failure, but the path is technically wrong. The fix is to drop the
extra slash from the format string:

  sprintf(g_hpage_path, "%s%s/%s", PATH_MM_HUGEPAGES,
                  ent->d_name, "nr_hugepages");

Verdict: Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list