Skip to content

Commit 42565b8

Browse files
authored
Cast (mode_t)mode for POSIX functions (libarchive#2476)
1 parent 743bbe9 commit 42565b8

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

libarchive/archive_write_disk_posix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3788,7 +3788,7 @@ set_mode(struct archive_write_disk *a, int mode)
37883788
* permissions on symlinks, so a failure here has no
37893789
* impact.
37903790
*/
3791-
if (lchmod(a->name, mode) != 0) {
3791+
if (lchmod(a->name, (mode_t)mode) != 0) {
37923792
switch (errno) {
37933793
case ENOTSUP:
37943794
case ENOSYS:
@@ -3818,12 +3818,12 @@ set_mode(struct archive_write_disk *a, int mode)
38183818
*/
38193819
#ifdef HAVE_FCHMOD
38203820
if (a->fd >= 0)
3821-
r2 = fchmod(a->fd, mode);
3821+
r2 = fchmod(a->fd, (mode_t)mode);
38223822
else
38233823
#endif
38243824
/* If this platform lacks fchmod(), then
38253825
* we'll just use chmod(). */
3826-
r2 = chmod(a->name, mode);
3826+
r2 = chmod(a->name, (mode_t)mode);
38273827

38283828
if (r2 != 0) {
38293829
archive_set_error(&a->archive, errno,

test_utils/test_main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ int
611611
assertion_chmod(const char *file, int line, const char *pathname, int mode)
612612
{
613613
assertion_count(file, line);
614-
if (chmod(pathname, mode) == 0)
614+
if (chmod(pathname, (mode_t)mode) == 0)
615615
return (1);
616616
failure_start(file, line, "chmod(\"%s\", %4.o)", pathname,
617617
(unsigned int)mode);
@@ -1950,8 +1950,8 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
19501950
if (0 == _mkdir(dirname))
19511951
return (1);
19521952
#else
1953-
if (0 == mkdir(dirname, mode)) {
1954-
if (0 == chmod(dirname, mode)) {
1953+
if (0 == mkdir(dirname, (mode_t)mode)) {
1954+
if (0 == chmod(dirname, (mode_t)mode)) {
19551955
assertion_file_mode(file, line, dirname, mode);
19561956
return (1);
19571957
}
@@ -2005,9 +2005,9 @@ assertion_make_file(const char *file, int line,
20052005
return (0);
20062006
}
20072007
#ifdef HAVE_FCHMOD
2008-
if (0 != fchmod(fd, mode))
2008+
if (0 != fchmod(fd, (mode_t)mode))
20092009
#else
2010-
if (0 != chmod(path, mode))
2010+
if (0 != chmod(path, (mode_t)mode))
20112011
#endif
20122012
{
20132013
failure_start(file, line, "Could not chmod %s", path);
@@ -2096,7 +2096,7 @@ assertion_umask(const char *file, int line, int mask)
20962096
assertion_count(file, line);
20972097
(void)file; /* UNUSED */
20982098
(void)line; /* UNUSED */
2099-
umask(mask);
2099+
umask((mode_t)mask);
21002100
return (1);
21012101
}
21022102

@@ -3568,7 +3568,7 @@ test_run(int i, const char *tmpdir)
35683568
char logfilename[64];
35693569
int failures_before = failures;
35703570
int skips_before = skips;
3571-
int oldumask;
3571+
mode_t oldumask;
35723572

35733573
switch (verbosity) {
35743574
case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */

unzip/bsdunzip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ make_dir(const char *path, int mode)
356356
*/
357357
(void)unlink(path);
358358
}
359-
if (mkdir(path, mode) != 0 && errno != EEXIST)
359+
if (mkdir(path, (mode_t)mode) != 0 && errno != EEXIST)
360360
error("mkdir('%s')", path);
361361
}
362362

@@ -700,7 +700,7 @@ extract_file(struct archive *a, struct archive_entry *e, char **path)
700700
error("symlink('%s')", *path);
701701
info(" extracting: %s -> %s\n", *path, linkname);
702702
#ifdef HAVE_LCHMOD
703-
if (lchmod(*path, mode) != 0)
703+
if (lchmod(*path, (mode_t)mode) != 0)
704704
warning("Cannot set mode for '%s'", *path);
705705
#endif
706706
/* set access and modification time */

0 commit comments

Comments
 (0)