Skip to content

Commit 9b5659a

Browse files
committed
Use a constant in utsname
1 parent 50484ed commit 9b5659a

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/unix/bsd/mod.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ pub type sa_family_t = u8;
1010
pub type pthread_t = ::uintptr_t;
1111
pub type nfds_t = ::c_uint;
1212

13+
#[cfg(not(target_os = "dragonfly"))]
14+
const UTSNAME_LEN: usize = 256;
15+
#[cfg(target_os = "dragonfly")]
16+
const UTSNAME_LEN: usize = 32;
17+
1318
s! {
1419
pub struct sockaddr {
1520
pub sa_len: u8,
@@ -85,26 +90,11 @@ s! {
8590
}
8691

8792
pub struct utsname {
88-
#[cfg(not(target_os = "dragonfly"))]
89-
pub sysname: [::c_char; 256],
90-
#[cfg(target_os = "dragonfly")]
91-
pub sysname: [::c_char; 32],
92-
#[cfg(not(target_os = "dragonfly"))]
93-
pub nodename: [::c_char; 256],
94-
#[cfg(target_os = "dragonfly")]
95-
pub nodename: [::c_char; 32],
96-
#[cfg(not(target_os = "dragonfly"))]
97-
pub release: [::c_char; 256],
98-
#[cfg(target_os = "dragonfly")]
99-
pub release: [::c_char; 32],
100-
#[cfg(not(target_os = "dragonfly"))]
101-
pub version: [::c_char; 256],
102-
#[cfg(target_os = "dragonfly")]
103-
pub version: [::c_char; 32],
104-
#[cfg(not(target_os = "dragonfly"))]
105-
pub machine: [::c_char; 256],
106-
#[cfg(target_os = "dragonfly")]
107-
pub machine: [::c_char; 32],
93+
pub sysname: [::c_char; UTSNAME_LEN],
94+
pub nodename: [::c_char; UTSNAME_LEN],
95+
pub release: [::c_char; UTSNAME_LEN],
96+
pub version: [::c_char; UTSNAME_LEN],
97+
pub machine: [::c_char; UTSNAME_LEN],
10898
}
10999

110100
pub struct msghdr {

0 commit comments

Comments
 (0)