]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: avoid new chmod.c warnings from upcoming GCC12
authorJim Meyering <meyering@fb.com>
Thu, 16 Sep 2021 20:23:46 +0000 (13:23 -0700)
committerJim Meyering <meyering@fb.com>
Thu, 16 Sep 2021 22:22:15 +0000 (15:22 -0700)
Here are the warnings:
src/chmod.c:175:3: error: 'ch.new_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  175 |   strmode (ch->new_mode, perms);
src/chmod.c:178:3: error: 'ch.old_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  178 |   strmode (ch->old_mode, old_perms);

* src/chmod.c (process_file): Initialize ch.  Its new_mode and
old_mode fields could indeed be used uninitialized to form mode
strings, but those are used only when built from initialized members.

src/chmod.c

index 4447e784e13802e3d559eefd57d17215100f2775..37b04f5006bbcd049b2ae1be1b2e0f73730e2dd5 100644 (file)
@@ -206,7 +206,7 @@ process_file (FTS *fts, FTSENT *ent)
   char const *file_full_name = ent->fts_path;
   char const *file = ent->fts_accpath;
   const struct stat *file_stats = ent->fts_statp;
-  struct change_status ch;
+  struct change_status ch = { 0, };
   ch.status = CH_NO_STAT;
 
   switch (ent->fts_info)