Skip to content

Commit 66b5875

Browse files
nyuriktgross35
authored andcommitted
chore: minor cleanup mode_t usage
`crate::mode_t` is almost never needed because it is part of prelude. Moreover, in many cases `mode_t` was already used without the prefix - thus confusing if they are different or not. Keeping it the same helps readability. (backport <#4405>) [ Resolve conflict around vxworks S_* constants - Trevor ] (cherry picked from commit 1984cc2)
1 parent 952bc81 commit 66b5875

File tree

18 files changed

+207
-236
lines changed

18 files changed

+207
-236
lines changed

src/fuchsia/mod.rs

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,9 +1452,9 @@ pub const GRPQUOTA: c_int = 1;
14521452

14531453
pub const SIGIOT: c_int = 6;
14541454

1455-
pub const S_ISUID: crate::mode_t = 0o4000;
1456-
pub const S_ISGID: crate::mode_t = 0o2000;
1457-
pub const S_ISVTX: crate::mode_t = 0o1000;
1455+
pub const S_ISUID: mode_t = 0o4000;
1456+
pub const S_ISGID: mode_t = 0o2000;
1457+
pub const S_ISVTX: mode_t = 0o1000;
14581458

14591459
pub const IF_NAMESIZE: size_t = 16;
14601460
pub const IFNAMSIZ: size_t = IF_NAMESIZE;
@@ -1585,26 +1585,26 @@ pub const O_RDONLY: c_int = 0;
15851585
pub const O_WRONLY: c_int = 1;
15861586
pub const O_RDWR: c_int = 2;
15871587

1588-
pub const S_IFIFO: crate::mode_t = 0o1_0000;
1589-
pub const S_IFCHR: crate::mode_t = 0o2_0000;
1590-
pub const S_IFBLK: crate::mode_t = 0o6_0000;
1591-
pub const S_IFDIR: crate::mode_t = 0o4_0000;
1592-
pub const S_IFREG: crate::mode_t = 0o10_0000;
1593-
pub const S_IFLNK: crate::mode_t = 0o12_0000;
1594-
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
1595-
pub const S_IFMT: crate::mode_t = 0o17_0000;
1596-
pub const S_IRWXU: crate::mode_t = 0o0700;
1597-
pub const S_IXUSR: crate::mode_t = 0o0100;
1598-
pub const S_IWUSR: crate::mode_t = 0o0200;
1599-
pub const S_IRUSR: crate::mode_t = 0o0400;
1600-
pub const S_IRWXG: crate::mode_t = 0o0070;
1601-
pub const S_IXGRP: crate::mode_t = 0o0010;
1602-
pub const S_IWGRP: crate::mode_t = 0o0020;
1603-
pub const S_IRGRP: crate::mode_t = 0o0040;
1604-
pub const S_IRWXO: crate::mode_t = 0o0007;
1605-
pub const S_IXOTH: crate::mode_t = 0o0001;
1606-
pub const S_IWOTH: crate::mode_t = 0o0002;
1607-
pub const S_IROTH: crate::mode_t = 0o0004;
1588+
pub const S_IFIFO: mode_t = 0o1_0000;
1589+
pub const S_IFCHR: mode_t = 0o2_0000;
1590+
pub const S_IFBLK: mode_t = 0o6_0000;
1591+
pub const S_IFDIR: mode_t = 0o4_0000;
1592+
pub const S_IFREG: mode_t = 0o10_0000;
1593+
pub const S_IFLNK: mode_t = 0o12_0000;
1594+
pub const S_IFSOCK: mode_t = 0o14_0000;
1595+
pub const S_IFMT: mode_t = 0o17_0000;
1596+
pub const S_IRWXU: mode_t = 0o0700;
1597+
pub const S_IXUSR: mode_t = 0o0100;
1598+
pub const S_IWUSR: mode_t = 0o0200;
1599+
pub const S_IRUSR: mode_t = 0o0400;
1600+
pub const S_IRWXG: mode_t = 0o0070;
1601+
pub const S_IXGRP: mode_t = 0o0010;
1602+
pub const S_IWGRP: mode_t = 0o0020;
1603+
pub const S_IRGRP: mode_t = 0o0040;
1604+
pub const S_IRWXO: mode_t = 0o0007;
1605+
pub const S_IXOTH: mode_t = 0o0001;
1606+
pub const S_IWOTH: mode_t = 0o0002;
1607+
pub const S_IROTH: mode_t = 0o0004;
16081608
pub const F_OK: c_int = 0;
16091609
pub const R_OK: c_int = 4;
16101610
pub const W_OK: c_int = 2;
@@ -3726,12 +3726,7 @@ extern "C" {
37263726
pub fn rewinddir(dirp: *mut crate::DIR);
37273727

37283728
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
3729-
pub fn fchmodat(
3730-
dirfd: c_int,
3731-
pathname: *const c_char,
3732-
mode: crate::mode_t,
3733-
flags: c_int,
3734-
) -> c_int;
3729+
pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
37353730
pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
37363731
pub fn fchownat(
37373732
dirfd: c_int,
@@ -3748,7 +3743,7 @@ extern "C" {
37483743
newpath: *const c_char,
37493744
flags: c_int,
37503745
) -> c_int;
3751-
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
3746+
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
37523747
pub fn readlinkat(
37533748
dirfd: c_int,
37543749
pathname: *const c_char,
@@ -3966,7 +3961,7 @@ extern "C" {
39663961
pub fn gmtime(time_p: *const time_t) -> *mut tm;
39673962
pub fn localtime(time_p: *const time_t) -> *mut tm;
39683963

3969-
pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int;
3964+
pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
39703965
pub fn uname(buf: *mut crate::utsname) -> c_int;
39713966
pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
39723967
pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
@@ -4086,8 +4081,7 @@ extern "C" {
40864081

40874082
pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
40884083

4089-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
4090-
-> c_int;
4084+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
40914085
pub fn pthread_condattr_getclock(
40924086
attr: *const pthread_condattr_t,
40934087
clock_id: *mut clockid_t,
@@ -4214,7 +4208,7 @@ extern "C" {
42144208
pub fn setfsuid(uid: crate::uid_t) -> c_int;
42154209

42164210
// Not available now on Android
4217-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
4211+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
42184212
pub fn if_nameindex() -> *mut if_nameindex;
42194213
pub fn if_freenameindex(ptr: *mut if_nameindex);
42204214
pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;

src/unix/aix/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,9 +2881,8 @@ extern "C" {
28812881
) -> *mut c_void;
28822882
pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int;
28832883
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
2884-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
2885-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
2886-
-> c_int;
2884+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
2885+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
28872886
pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int;
28882887
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
28892888
pub fn mq_close(mqd: crate::mqd_t) -> c_int;
@@ -2977,7 +2976,7 @@ extern "C" {
29772976
fd: c_int,
29782977
path: *const c_char,
29792978
oflag: c_int,
2980-
mode: crate::mode_t,
2979+
mode: mode_t,
29812980
) -> c_int;
29822981
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
29832982
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
@@ -3142,7 +3141,7 @@ extern "C" {
31423141
pub fn shmdt(shmaddr: *const c_void) -> c_int;
31433142
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
31443143
pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int;
3145-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
3144+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
31463145
pub fn shm_unlink(name: *const c_char) -> c_int;
31473146
pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int;
31483147
pub fn srand(seed: c_uint);

src/unix/bsd/apple/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ s! {
775775
pub gid: crate::gid_t,
776776
pub cuid: crate::uid_t,
777777
pub cgid: crate::gid_t,
778-
pub mode: crate::mode_t,
778+
pub mode: mode_t,
779779
pub _seq: c_ushort,
780780
pub _key: crate::key_t,
781781
}
@@ -6341,7 +6341,7 @@ extern "C" {
63416341
fd: c_int,
63426342
path: *const c_char,
63436343
oflag: c_int,
6344-
mode: crate::mode_t,
6344+
mode: mode_t,
63456345
) -> c_int;
63466346
pub fn posix_spawn_file_actions_addclose(
63476347
actions: *mut posix_spawn_file_actions_t,
@@ -6660,9 +6660,8 @@ extern "C" {
66606660
pub fn dirname(path: *mut c_char) -> *mut c_char;
66616661
pub fn basename(path: *mut c_char) -> *mut c_char;
66626662

6663-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
6664-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
6665-
-> c_int;
6663+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
6664+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
66666665
pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int;
66676666
pub fn execvP(
66686667
file: *const c_char,

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ s! {
378378
pub cgid: crate::gid_t,
379379
pub uid: crate::uid_t,
380380
pub gid: crate::gid_t,
381-
pub mode: crate::mode_t,
381+
pub mode: mode_t,
382382
pub seq: c_ushort,
383383
pub key: crate::key_t,
384384
}
@@ -1602,13 +1602,12 @@ extern "C" {
16021602
pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int;
16031603
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
16041604
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
1605-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
1605+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
16061606
#[cfg_attr(
16071607
all(target_os = "freebsd", any(freebsd11, freebsd10)),
16081608
link_name = "mknodat@FBSD_1.1"
16091609
)]
1610-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
1611-
-> c_int;
1610+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
16121611
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
16131612
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
16141613
pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
@@ -1730,7 +1729,7 @@ extern "C" {
17301729
pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int;
17311730
pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
17321731
pub fn setutxent();
1733-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
1732+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
17341733
pub fn sigtimedwait(
17351734
set: *const sigset_t,
17361735
info: *mut siginfo_t,
@@ -1872,7 +1871,7 @@ extern "C" {
18721871
fd: c_int,
18731872
path: *const c_char,
18741873
oflag: c_int,
1875-
mode: crate::mode_t,
1874+
mode: mode_t,
18761875
) -> c_int;
18771876
pub fn posix_spawn_file_actions_addclose(
18781877
actions: *mut posix_spawn_file_actions_t,

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ s! {
7878
pub cgid: crate::gid_t,
7979
pub uid: crate::uid_t,
8080
pub gid: crate::gid_t,
81-
pub mode: crate::mode_t,
81+
pub mode: mode_t,
8282
#[cfg(target_os = "openbsd")]
8383
pub seq: c_ushort,
8484
#[cfg(target_os = "netbsd")]
@@ -689,7 +689,7 @@ extern "C" {
689689
#[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")]
690690
pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
691691
pub fn __errno() -> *mut c_int;
692-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
692+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
693693
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
694694
pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
695695
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;
@@ -707,9 +707,8 @@ extern "C" {
707707
pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
708708
pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
709709

710-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
711-
-> c_int;
712-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
710+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
711+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
713712
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
714713
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
715714
pub fn pthread_condattr_setclock(
@@ -830,7 +829,7 @@ extern "C" {
830829
fd: c_int,
831830
path: *const c_char,
832831
oflag: c_int,
833-
mode: crate::mode_t,
832+
mode: mode_t,
834833
) -> c_int;
835834
pub fn posix_spawn_file_actions_addclose(
836835
actions: *mut posix_spawn_file_actions_t,

src/unix/haiku/mod.rs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ s! {
420420
pub gid: crate::gid_t,
421421
pub cuid: crate::uid_t,
422422
pub cgid: crate::gid_t,
423-
pub mode: crate::mode_t,
423+
pub mode: mode_t,
424424
}
425425

426426
pub struct sembuf {
@@ -774,27 +774,27 @@ pub const O_NOFOLLOW: c_int = 0x00080000;
774774
pub const O_NOCACHE: c_int = 0x00100000;
775775
pub const O_DIRECTORY: c_int = 0x00200000;
776776

777-
pub const S_IFIFO: crate::mode_t = 0o1_0000;
778-
pub const S_IFCHR: crate::mode_t = 0o2_0000;
779-
pub const S_IFBLK: crate::mode_t = 0o6_0000;
780-
pub const S_IFDIR: crate::mode_t = 0o4_0000;
781-
pub const S_IFREG: crate::mode_t = 0o10_0000;
782-
pub const S_IFLNK: crate::mode_t = 0o12_0000;
783-
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
784-
pub const S_IFMT: crate::mode_t = 0o17_0000;
785-
786-
pub const S_IRWXU: crate::mode_t = 0o0700;
787-
pub const S_IRUSR: crate::mode_t = 0o0400;
788-
pub const S_IWUSR: crate::mode_t = 0o0200;
789-
pub const S_IXUSR: crate::mode_t = 0o0100;
790-
pub const S_IRWXG: crate::mode_t = 0o0070;
791-
pub const S_IRGRP: crate::mode_t = 0o0040;
792-
pub const S_IWGRP: crate::mode_t = 0o0020;
793-
pub const S_IXGRP: crate::mode_t = 0o0010;
794-
pub const S_IRWXO: crate::mode_t = 0o0007;
795-
pub const S_IROTH: crate::mode_t = 0o0004;
796-
pub const S_IWOTH: crate::mode_t = 0o0002;
797-
pub const S_IXOTH: crate::mode_t = 0o0001;
777+
pub const S_IFIFO: mode_t = 0o1_0000;
778+
pub const S_IFCHR: mode_t = 0o2_0000;
779+
pub const S_IFBLK: mode_t = 0o6_0000;
780+
pub const S_IFDIR: mode_t = 0o4_0000;
781+
pub const S_IFREG: mode_t = 0o10_0000;
782+
pub const S_IFLNK: mode_t = 0o12_0000;
783+
pub const S_IFSOCK: mode_t = 0o14_0000;
784+
pub const S_IFMT: mode_t = 0o17_0000;
785+
786+
pub const S_IRWXU: mode_t = 0o0700;
787+
pub const S_IRUSR: mode_t = 0o0400;
788+
pub const S_IWUSR: mode_t = 0o0200;
789+
pub const S_IXUSR: mode_t = 0o0100;
790+
pub const S_IRWXG: mode_t = 0o0070;
791+
pub const S_IRGRP: mode_t = 0o0040;
792+
pub const S_IWGRP: mode_t = 0o0020;
793+
pub const S_IXGRP: mode_t = 0o0010;
794+
pub const S_IRWXO: mode_t = 0o0007;
795+
pub const S_IROTH: mode_t = 0o0004;
796+
pub const S_IWOTH: mode_t = 0o0002;
797+
pub const S_IXOTH: mode_t = 0o0001;
798798

799799
pub const F_OK: c_int = 0;
800800
pub const R_OK: c_int = 4;
@@ -1733,9 +1733,8 @@ extern "C" {
17331733
bufferSize: size_t,
17341734
res: *mut *mut spwd,
17351735
) -> c_int;
1736-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
1737-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
1738-
-> c_int;
1736+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1737+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
17391738
pub fn sem_destroy(sem: *mut sem_t) -> c_int;
17401739
pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
17411740

@@ -1813,7 +1812,7 @@ extern "C" {
18131812
pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int;
18141813
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
18151814

1816-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
1815+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
18171816
pub fn shm_unlink(name: *const c_char) -> c_int;
18181817

18191818
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
@@ -2032,7 +2031,7 @@ extern "C" {
20322031
fildes: c_int,
20332032
path: *const c_char,
20342033
oflag: c_int,
2035-
mode: crate::mode_t,
2034+
mode: mode_t,
20362035
) -> c_int;
20372036
pub fn posix_spawn_file_actions_addclose(
20382037
file_actions: *mut posix_spawn_file_actions_t,

0 commit comments

Comments
 (0)