From 45b4ef924b30935ca6c7677d3973ef9b64ae762e Mon Sep 17 00:00:00 2001 From: Vladimir Rutsky Date: Mon, 1 Feb 2016 00:23:50 +0300 Subject: [PATCH 1/2] fix loopback example building with -DNDEBUG --- loopback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/loopback.c b/loopback.c index 4df4e6b..57c3767 100644 --- a/loopback.c +++ b/loopback.c @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) /* Figure out the size of the underlying block device. */ err = ioctl(fd, BLKGETSIZE64, &size); assert(err != -1); + (void)err; fprintf(stderr, "The size of this device is %ld bytes.\n", size); bop.size = size; From 2abde7a3f34399b1ca6164d04c94447d39bb94f6 Mon Sep 17 00:00:00 2001 From: Vladimir Rutsky Date: Mon, 1 Feb 2016 00:35:34 +0300 Subject: [PATCH 2/2] fix use of assert() when NDEBUG is defined assert() body is not executed if NDEBUG is defined. --- buse.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/buse.c b/buse.c index 69039b7..3cd3a27 100644 --- a/buse.c +++ b/buse.c @@ -91,13 +91,16 @@ int buse_main(const char* dev_file, const struct buse_operations *aop, void *use struct nbd_reply reply; void *chunk; - assert(!socketpair(AF_UNIX, SOCK_STREAM, 0, sp)); + err = socketpair(AF_UNIX, SOCK_STREAM, 0, sp); + assert(!err); nbd = open(dev_file, O_RDWR); assert(nbd != -1); - assert(ioctl(nbd, NBD_SET_SIZE, aop->size) != -1); - assert(ioctl(nbd, NBD_CLEAR_SOCK) != -1); + err = ioctl(nbd, NBD_SET_SIZE, aop->size); + assert(err != -1); + err = ioctl(nbd, NBD_CLEAR_SOCK); + assert(err != -1); if (!fork()) { /* The child needs to continue setting things up. */