From 6d6f6ed8fce70048712e16d70a6e936776e2e27d Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Tue, 12 May 2020 20:36:21 -0600 Subject: [PATCH] resolve warning messages (#495) --- Cargo.lock | 113 +++++++++++++++++++++++++++++ src/prolog/machine/system_calls.rs | 22 +++++- 2 files changed, 131 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9057ef28..e6625c81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,12 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "bumpalo" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" + [[package]] name = "cc" version = "1.0.52" @@ -257,6 +263,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -477,6 +492,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" + [[package]] name = "ordered-float" version = "0.5.2" @@ -571,6 +592,21 @@ version = "0.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" +[[package]] +name = "ring" +version = "0.16.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.8", +] + [[package]] name = "rug" version = "1.8.0" @@ -653,6 +689,7 @@ dependencies = [ "ordered-float", "prolog_parser", "ref_thread_local", + "ring", "rug", "rustyline", "unicode_reader", @@ -715,6 +752,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "static_assertions" version = "0.3.4" @@ -769,6 +812,12 @@ dependencies = [ "void", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "utf8parse" version = "0.2.0" @@ -787,6 +836,70 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasm-bindgen" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" + +[[package]] +name = "web-sys" +version = "0.3.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index dbf32f2b..3b8409a3 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -5183,10 +5183,24 @@ impl MachineState { } &SystemClauseType::CryptoRandomByte => { let arg = self[temp_v!(1)]; - let mut bytes: Vec = vec![0]; - rng().fill(&mut bytes); + let mut bytes: [u8; 1] = [0]; + + match rng().fill(&mut bytes) { + Ok(()) => { + } + Err(_) => { + // the error payload here is of type 'Unspecified', + // which contains no information whatsoever. So, for now, + // just fail. + self.fail = true; + return Ok(()); + } + } + + let byte = self.heap.to_unifiable( + HeapCellValue::Integer(Rc::new(Integer::from(bytes[0]))) + ); - let byte = self.heap.put_constant(Constant::Integer(Rc::new(Integer::from(bytes[0])))); self.unify(arg, byte); } }; @@ -5196,7 +5210,7 @@ impl MachineState { } -fn rng() -> &'static SecureRandom { +fn rng() -> &'static dyn SecureRandom { use std::ops::Deref; lazy_static! { -- 2.54.0