[Mesa-dev] [PATCH 1/8] util/disk_cache: fix bug with deleting old cache dirs
Grazvydas Ignotas
notasas at gmail.com
Wed Feb 22 10:43:22 UTC 2017
On Wed, Feb 22, 2017 at 5:45 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> If there was more than a single directory in the .cache/mesa dir
> then it would only remove one (or none) of the directories.
>
> Apparently Valgrind was also reporting:
> Conditional jump or move depends on uninitialised value
uninitialised -> uninitialized
Could you also fix the other problems along the way, like checking
stat() return, freeing full_path and adding missing closedir(dir)?
GraÅžvydas
> ---
> src/util/disk_cache.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 2f138da..b172b8b 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -152,14 +152,15 @@ remove_old_cache_directories(void *mem_ctx, char *path, const char *timestamp)
> struct dirent* d_entry;
> while((d_entry = readdir(dir)) != NULL)
> {
> + char *full_path =
> + ralloc_asprintf(mem_ctx, "%s/%s", path, d_entry->d_name);
> +
> struct stat sb;
> - stat(d_entry->d_name, &sb);
> + stat(full_path, &sb);
> if (S_ISDIR(sb.st_mode) &&
> strcmp(d_entry->d_name, timestamp) != 0 &&
> strcmp(d_entry->d_name, "..") != 0 &&
> strcmp(d_entry->d_name, ".") != 0) {
> - char *full_path =
> - ralloc_asprintf(mem_ctx, "%s/%s", path, d_entry->d_name);
> nftw(full_path, remove_dir, 20, FTW_DEPTH);
> }
> }
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list