]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
stat,df: remove an unnecessary alloca
authorCollin Funk <collin.funk1@gmail.com>
Sun, 1 Feb 2026 20:34:36 +0000 (12:34 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 5 Feb 2026 00:42:26 +0000 (16:42 -0800)
* src/find-mount-point.c (find_mount_point): Don't call ASSIGN_STRDUPA
on the result of dir_name.

src/find-mount-point.c

index 6624f7f75f91eb5bb6b0053be9547303021ad2a4..f1666c93ff6d3f2df93e9b47858fef780ec764e1 100644 (file)
@@ -52,14 +52,12 @@ find_mount_point (char const *file, struct stat const *file_stat)
   else
     /* FILE is some other kind of file; use its directory.  */
     {
-      char *xdir = dir_name (file);
-      char *dir;
-      ASSIGN_STRDUPA (dir, xdir);
-      free (xdir);
+      char *dir = dir_name (file);
 
       if (chdir (dir) < 0)
         {
           error (0, errno, _("cannot change to directory %s"), quoteaf (dir));
+          free (dir);
           return NULL;
         }
 
@@ -67,8 +65,11 @@ find_mount_point (char const *file, struct stat const *file_stat)
         {
           error (0, errno, _("cannot stat current directory (now %s)"),
                  quoteaf (dir));
+          free (dir);
           goto done;
         }
+
+      free (dir);
     }
 
   /* Now walk up FILE's parents until we find another file system or /,