diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-02-12 07:19:40 -0500 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2020-02-25 16:21:59 +0000 |
commit | 57afddacf037fa96a91a6397124ede67ad51d287 (patch) | |
tree | b0fe1e62ce5f22e16bdd35b5857862ed0b6e1835 /samples/gpio-pci-idio-16.c | |
parent | 0c3466564e209ed8e35a2d54a9c93902c4de204e (diff) | |
download | libvfio-user-57afddacf037fa96a91a6397124ede67ad51d287.zip libvfio-user-57afddacf037fa96a91a6397124ede67ad51d287.tar.gz libvfio-user-57afddacf037fa96a91a6397124ede67ad51d287.tar.bz2 |
gpio sample: print error message when device UUID is missing
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/gpio-pci-idio-16.c')
-rw-r--r-- | samples/gpio-pci-idio-16.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index cf44ab9..285b600 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -34,6 +34,8 @@ /* gpio-pci-idio-16 */ #include <stdio.h> +#include <err.h> +#include <stdlib.h> #include "../lib/muser.h" @@ -51,7 +53,11 @@ bar2_access(void *pvt, char * const buf, size_t count, loff_t offset, int main(int argc, char **argv) { - int err; + int ret; + + if (argc != 2) { + err(EXIT_FAILURE, "missing MUSER device UUID"); + } lm_dev_info_t dev_info = { .pci_info = { @@ -66,11 +72,11 @@ int main(int argc, char **argv) .uuid = argv[1], }; - err = lm_ctx_run(&dev_info); - if (err != 0) { + ret = lm_ctx_run(&dev_info); + if (ret != 0) { fprintf(stderr, "failed to realize device emulation: %m\n"); } - return err; + return ret; } /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ |