Skip to content

Commit a419f7d

Browse files
committed
utils/misc/archivemount: fix warnings about unchecked return values of chdir and system
Signed-off-by: Brice Goglin <[email protected]>
1 parent 9b1d69a commit a419f7d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

utils/hwloc/misc.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,16 @@ hwloc_utils_enable_input_format(struct hwloc_topology *topology, unsigned long f
321321
snprintf(umntcmd, sizeof(umntcmd), "umount -l %s", mntpath);
322322

323323
/* enter the mount point and stay there so that we can umount+rmdir immediately but still use it later */
324-
chdir(mntpath);
325-
system(umntcmd);
324+
if (chdir(mntpath) < 0) {
325+
perror("Entering the archivemount'ed archive");
326+
if (system(umntcmd) < 0)
327+
perror("Unmounting the archivemount'ed archive (ignored)");
328+
rmdir(mntpath);
329+
close(sub_input_format.oldworkdir);
330+
return EXIT_FAILURE;
331+
}
332+
if (system(umntcmd) < 0)
333+
perror("Unmounting the archivemount'ed archive (ignored)");
326334
rmdir(mntpath);
327335

328336
/* there should be a single subdirectory in the archive */

0 commit comments

Comments
 (0)