Re: [PATCH] perf tools: Remove unused is_executable_file

From: Dr. David Alan Gilbert
Date: Mon Dec 23 2024 - 11:42:44 EST


* Arnaldo Carvalho de Melo (acme@xxxxxxxxxx) wrote:
> On Mon, Dec 23, 2024 at 01:32:15PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Sun, Dec 22, 2024 at 09:58:31PM +0000, linux@xxxxxxxxxxx wrote:
> > > From: "Dr. David Alan Gilbert" <linux@xxxxxxxxxxx>
> > >
> > > is_executable_file() has been unused since 2022's
> > > commit 7391db645938 ("perf test: Refactor shell tests allowing subdirs")
> > >
> > > Remove it.
> >
> > Did you patch this on:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
> >
> > ?
> >
> > That function is still there, so I'll fixup your patch, keep your
> > credits and test it all.
>
> FYI, it fails on the .h file:

Ah, it's because of the new 'is_directory_at' is added just above.

Dave

> ⬢ [acme@toolbox perf-tools-next]$ patch -p1 < ./20241222_linux_perf_tools_remove_unused_is_executable_file.mbx
> patching file tools/perf/util/path.c
> Hunk #1 succeeded at 77 (offset 10 lines).
> patching file tools/perf/util/path.h
> Hunk #1 FAILED at 12.
> 1 out of 1 hunk FAILED -- saving rejects to file tools/perf/util/path.h.rej
> ⬢ [acme@toolbox perf-tools-next]$ git diff
> diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
> index 9712466c51e2f30e..2e62f272fda8671a 100644
> --- a/tools/perf/util/path.c
> +++ b/tools/perf/util/path.c
> @@ -77,15 +77,3 @@ bool is_directory_at(int dir_fd, const char *path)
>
> return S_ISDIR(st.st_mode);
> }
> -
> -bool is_executable_file(const char *base_path, const struct dirent *dent)
> -{
> - char path[PATH_MAX];
> - struct stat st;
> -
> - snprintf(path, sizeof(path), "%s/%s", base_path, dent->d_name);
> - if (stat(path, &st))
> - return false;
> -
> - return !S_ISDIR(st.st_mode) && (st.st_mode & S_IXUSR);
> -}
> ⬢ [acme@toolbox perf-tools-next]$
>
> ⬢ [acme@toolbox perf-tools-next]$ cat tools/perf/util/path.h.rej
> --- tools/perf/util/path.h
> +++ tools/perf/util/path.h
> @@ -12,6 +12,5 @@ int path__join3(char *bf, size_t size, const char *path1, const char *path2, con
>
> bool is_regular_file(const char *file);
> bool is_directory(const char *base_path, const struct dirent *dent);
> -bool is_executable_file(const char *base_path, const struct dirent *dent);
>
> #endif /* _PERF_PATH_H */
> ⬢ [acme@toolbox perf-tools-next]$
>
> Fixed up, thanks.
>
> - Arnaldo
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/