summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-03-11 12:31:39 -0800
committerbors <bors@rust-lang.org>2016-03-11 12:31:39 -0800
commit493d79b2ea504a17452223d75c8793e9b0e5058b (patch)
treeb34bd092d7e43dbb483ed987680f295c431131ea
parentef979ef4d81d3bb1814f9434ba964c1010ae6f40 (diff)
parent66c337532663ae3673cdffd0949dab6c865dd694 (diff)
downloadrust-libc-493d79b2ea504a17452223d75c8793e9b0e5058b.tar.gz
Auto merge of #224 - kamalmarhubi:safer-cfg, r=alexcrichton
Make cfg_if uses more explicit and consistent This commit changes most uses of cfg_if as follows: - fallthrough `else` usage is avoided for architecture or OS specific items - a comment is added in the final `else` clause to signal intent someone modifying It is safer to omit items than include ones for the wrong platform or architecture.
-rw-r--r--src/lib.rs4
-rw-r--r--src/unix/bsd/apple/mod.rs2
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs2
-rw-r--r--src/unix/bsd/mod.rs2
-rw-r--r--src/unix/bsd/openbsdlike/mod.rs4
-rw-r--r--src/unix/mod.rs2
-rw-r--r--src/unix/notbsd/android/mod.rs2
-rw-r--r--src/unix/notbsd/linux/musl/b32/mod.rs4
-rw-r--r--src/unix/notbsd/linux/other/b32/mod.rs2
-rw-r--r--src/unix/notbsd/linux/other/b64/mod.rs4
-rw-r--r--src/unix/notbsd/linux/other/mod.rs2
-rw-r--r--src/unix/notbsd/mod.rs3
-rw-r--r--src/windows.rs4
13 files changed, 24 insertions, 13 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 57919c59f9..2593e3ba6b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -258,8 +258,10 @@ cfg_if! {
if #[cfg(windows)] {
mod windows;
pub use windows::*;
- } else {
+ } else if #[cfg(unix)] {
mod unix;
pub use unix::*;
+ } else {
+ // Unknown target_family
}
}
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index ec0fe7c111..e96f433f18 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -946,6 +946,6 @@ cfg_if! {
mod b64;
pub use self::b64::*;
} else {
- // unknown arch...
+ // Unknown target_arch
}
}
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 0d913c6d93..5171735343 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -89,6 +89,6 @@ cfg_if! {
mod x86_64;
pub use self::x86_64::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 139edf717d..b633003aa5 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -350,6 +350,6 @@ cfg_if! {
mod freebsdlike;
pub use self::freebsdlike::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs
index 1cd6eb816a..1a2bdffa8b 100644
--- a/src/unix/bsd/openbsdlike/mod.rs
+++ b/src/unix/bsd/openbsdlike/mod.rs
@@ -402,8 +402,10 @@ cfg_if! {
} else if #[cfg(target_os = "netbsd")] {
mod netbsd;
pub use self::netbsd::*;
- } else {
+ } else if #[cfg(target_os = "openbsd")] {
mod openbsd;
pub use self::openbsd::*;
+ } else {
+ // Unknown target_os
}
}
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 3ffb3b79cf..77b24f229f 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -733,6 +733,6 @@ cfg_if! {
mod solaris;
pub use self::solaris::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index f039683a7e..0a01bcc1c5 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -657,6 +657,6 @@ cfg_if! {
mod b64;
pub use self::b64::*;
} else {
- // ...
+ // Unknown target_pointer_width
}
}
diff --git a/src/unix/notbsd/linux/musl/b32/mod.rs b/src/unix/notbsd/linux/musl/b32/mod.rs
index 668e8fc95c..ad74e8816d 100644
--- a/src/unix/notbsd/linux/musl/b32/mod.rs
+++ b/src/unix/notbsd/linux/musl/b32/mod.rs
@@ -38,5 +38,7 @@ cfg_if! {
} else if #[cfg(any(target_arch = "asmjs"))] {
mod asmjs;
pub use self::asmjs::*;
- } else { }
+ } else {
+ // Unknown target_arch
+ }
}
diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs
index 908fa40a56..b39ff683f6 100644
--- a/src/unix/notbsd/linux/other/b32/mod.rs
+++ b/src/unix/notbsd/linux/other/b32/mod.rs
@@ -90,6 +90,6 @@ cfg_if! {
mod powerpc;
pub use self::powerpc::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/linux/other/b64/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs
index 28d9e4d00f..663b09333c 100644
--- a/src/unix/notbsd/linux/other/b64/mod.rs
+++ b/src/unix/notbsd/linux/other/b64/mod.rs
@@ -25,8 +25,10 @@ cfg_if! {
} else if #[cfg(any(target_arch = "powerpc64"))] {
mod powerpc64;
pub use self::powerpc64::*;
- } else {
+ } else if #[cfg(any(target_arch = "x86_64"))] {
mod x86_64;
pub use self::x86_64::*;
+ } else {
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs
index 09d7e355c5..3ac57fe7e9 100644
--- a/src/unix/notbsd/linux/other/mod.rs
+++ b/src/unix/notbsd/linux/other/mod.rs
@@ -491,6 +491,6 @@ cfg_if! {
mod b64;
pub use self::b64::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index 6106438739..7cdd63cea9 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -133,6 +133,7 @@ cfg_if! {
} else if #[cfg(target_pointer_width = "64")] {
const ULONG_SIZE: usize = 64;
} else {
+ // Unknown target_pointer_width
}
}
@@ -680,6 +681,6 @@ cfg_if! {
mod android;
pub use self::android::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/windows.rs b/src/windows.rs
index 3f7f160ff3..21b6e13b74 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -72,9 +72,11 @@ cfg_if! {
if #[cfg(all(target_env = "gnu"))] {
pub const L_tmpnam: ::c_uint = 14;
pub const TMP_MAX: ::c_uint = 0x7fff;
- } else {
+ } else if #[cfg(all(target_env = "msvc"))] {
pub const L_tmpnam: ::c_uint = 260;
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
+ } else {
+ // Unknown target_env
}
}