From 57afddacf037fa96a91a6397124ede67ad51d287 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Wed, 12 Feb 2020 07:19:40 -0500 Subject: gpio sample: print error message when device UUID is missing Signed-off-by: Thanos Makatos --- samples/gpio-pci-idio-16.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'samples') 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 +#include +#include #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: */ -- cgit v1.1