Skip to content

Commit a5ddcb8

Browse files
committed
warning message for #2
1 parent b97d75f commit a5ddcb8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = "2018"
99
[dependencies]
1010
clap = { version = "3.2.22", features = ["derive"] }
1111
color-eyre = "0.6.2"
12+
colored = "2.1.0"
1213

1314
# Speed up `backtrace` even on a debug build. Suggested by `color-eyre`.
1415
[profile.dev.package.backtrace]

src/parser.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use crate::wasm::syntax::*;
55
use crate::Maybe;
66
use color_eyre::eyre::eyre;
7+
use colored::Colorize;
78
use std::collections::HashMap;
89
use std::convert::TryInto;
910

@@ -48,6 +49,12 @@ macro_rules! err {
4849
}}
4950
}
5051

52+
macro_rules! warn {
53+
($($args:tt)*) => {{
54+
eprintln!("{}", format_args!("WARNING -- {}", $($args)*).to_string().green());
55+
}}
56+
}
57+
5158
/// Little Endian Base 128 encoding of unsigned ints. Parses `bits` bits into a `u64`.
5259
fn leb128_u(mut inp: &[u8], bits: usize) -> Parsed<u64> {
5360
let n = inp[0] as u64;
@@ -880,11 +887,9 @@ generate! { module -> Module = {
880887
let mut data: &[u8] = data;
881888
let names = run_parser!(names(data));
882889
// below check seems broken, see https://github.com/secure-foundations/rWasm/issues/2
883-
// if data.len() == 0 {
884-
// names
885-
// } else {
886-
// err!("Unused bytes in the custom name section")
887-
// }
890+
if data.len() != 0 {
891+
warn!("Unused bytes in the custom name section; ingoring")
892+
}
888893
names
889894
} else {
890895
Names {

0 commit comments

Comments
 (0)