about summary refs log tree commit diff
path: root/src/libstd/rand
diff options
context:
space:
mode:
authorMichael McConville <mmcco@mykolab.com>2015-12-17 00:21:11 -0500
committerMichael McConville <mmcco@mykolab.com>2015-12-18 19:26:10 -0500
commit3ee3a784bf4ff7157a84e16026f19c4bf059de47 (patch)
tree8cec68a7b80b6b951a3812fc6b971c5908c2c316 /src/libstd/rand
parenta51b70b8169df7d2199b100fae1c1da8f8d299e3 (diff)
downloadrust-3ee3a784bf4ff7157a84e16026f19c4bf059de47.tar.gz
rust-3ee3a784bf4ff7157a84e16026f19c4bf059de47.zip
Use a const for getentropy(2)'s syscall number
Reported by Sebastien Marie.
Diffstat (limited to 'src/libstd/rand')
-rw-r--r--src/libstd/rand/os.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs
index a1c1244d397..7b1cbdb7eac 100644
--- a/src/libstd/rand/os.rs
+++ b/src/libstd/rand/os.rs
@@ -208,6 +208,8 @@ mod imp {
         fn syscall(number: c_long, ...) -> c_long;
     }
 
+    const NR_GETENTROPY: libc::c_long = 7;
+
     impl OsRng {
         /// Create a new `OsRng`.
         pub fn new() -> io::Result<OsRng> {
@@ -231,7 +233,9 @@ mod imp {
 
             // getentropy(2) permits a maximum buffer size of 256 bytes
             for s in v.chunks_mut(256) {
-                unsafe { ret = syscall(7, s.as_mut_ptr(), s.len()); }
+                unsafe {
+                    ret = syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len());
+                }
                 if ret == -1 {
                     panic!("unexpected getentropy error: {}", errno());
                 }