diff options
author | John Levon <john.levon@nutanix.com> | 2020-11-19 09:37:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 09:37:28 +0000 |
commit | f54581b9d4837e92cf644b48505e5419d8df72cb (patch) | |
tree | 6bef3a27f37ecc7422e291028f085e61740644aa /samples/gpio-pci-idio-16.c | |
parent | 58b89f9e0f7cd7847606fb22d2c0b9a38735cd62 (diff) | |
download | libvfio-user-f54581b9d4837e92cf644b48505e5419d8df72cb.zip libvfio-user-f54581b9d4837e92cf644b48505e5419d8df72cb.tar.gz libvfio-user-f54581b9d4837e92cf644b48505e5419d8df72cb.tar.bz2 |
enable assert() in release builds (#98)
Diffstat (limited to 'samples/gpio-pci-idio-16.c')
-rw-r--r-- | samples/gpio-pci-idio-16.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index 3e9b1ed..c8d5454 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -67,7 +67,8 @@ static void _sa_handler(UNUSED int signum) { } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int ret; bool verbose = false; @@ -107,23 +108,28 @@ int main(int argc, char *argv[]) sigemptyset(&act.sa_mask); if (sigaction(SIGINT, &act, NULL) == -1) { - fprintf(stderr, "warning: failed to register signal handler: %m\n"); + err(EXIT_FAILURE, "failed to register signal handler"); } lm_ctx = lm_ctx_create(&dev_info); if (lm_ctx == NULL) { - fprintf(stderr, "failed to initialize device emulation: %m\n"); - return -1; + if (errno == EINTR) { + printf("interrupted\n"); + exit(EXIT_SUCCESS); + } + err(EXIT_FAILURE, "failed to initialize device emulation"); } + ret = lm_ctx_drive(lm_ctx); + if (ret != 0) { if (ret != -ENOTCONN && ret != -EINTR) { - fprintf(stderr, "failed to realize device emulation: %m\n"); + err(EXIT_FAILURE, "failed to realize device emulation"); } } lm_ctx_destroy(lm_ctx); - return ret; + return EXIT_SUCCESS; } /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ |