Re: lib: Introduce tst_path_defs.h to consolidate system paths

[email protected]
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.