diff options
author | Shravan Narayan <shravanrn@gmail.com> | 2022-10-31 18:33:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 15:33:48 -0700 |
commit | f797049f3e10ed04af8fd6e43184e565b95abe6f (patch) | |
tree | e874d0cf3c5fbe98977446ab29a80764ae18cb03 /wasm2c/examples | |
parent | 59b1b69300c2ed6c2ae4ee95cad5fbddcc86e752 (diff) | |
download | wabt-f797049f3e10ed04af8fd6e43184e565b95abe6f.tar.gz wabt-f797049f3e10ed04af8fd6e43184e565b95abe6f.tar.bz2 wabt-f797049f3e10ed04af8fd6e43184e565b95abe6f.zip |
wasm2c examples print usage messages for missing arguments (#2028)
Diffstat (limited to 'wasm2c/examples')
-rw-r--r-- | wasm2c/examples/fac/main.c | 5 | ||||
-rw-r--r-- | wasm2c/examples/rot13/main.c | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/wasm2c/examples/fac/main.c b/wasm2c/examples/fac/main.c index 5a91b161..30bf5d0a 100644 --- a/wasm2c/examples/fac/main.c +++ b/wasm2c/examples/fac/main.c @@ -5,7 +5,10 @@ int main(int argc, char** argv) { /* Make sure there is at least one command-line argument. */ - if (argc < 2) return 1; + if (argc < 2) { + printf("Invalid argument. Expected '%s NUMBER'\n", argv[0]); + return 1; + } /* Convert the argument from a string to an int. We'll implicitly cast the int to a `u32`, which is what `fac` expects. */ diff --git a/wasm2c/examples/rot13/main.c b/wasm2c/examples/rot13/main.c index 2980324e..8081f697 100644 --- a/wasm2c/examples/rot13/main.c +++ b/wasm2c/examples/rot13/main.c @@ -45,6 +45,11 @@ void Z_hostZ_buf_done(struct Z_host_instance_t* instance, u32 ptr, u32 size) { } int main(int argc, char** argv) { + /* Make sure there is at least one command-line argument. */ + if (argc < 2) { + printf("Invalid argument. Expected '%s WORD'\n", argv[0]); + return 1; + } /* Initialize the Wasm runtime. */ wasm_rt_init(); |