Skip to contentSkip to conversation

blktap2: use abort() instead of custom crash

PATCH In review Doug Goldstein 3 participants 3 messages Apr 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blktap2: use abort() instead of custom crash

Instead of trying to write a snippet of code that crashes the process just use abort() directly. This is to fix the build on clang which detects that the snippet of code will crash and fails to compile. At the same time removed extraneous whitespace in the macro.

---
Honestly this whole macro could get replaced with assert(3) but I wanted to make the smallest change possible. If that's preferrable I'll do that. The man page claims that assert(3) will print the following to stderr:

"assertion \"%s\" failed: file \"%s\", line %d\n", \
        "expression", __FILE__, __LINE__);
---
 tools/blktap2/drivers/tapdisk-vbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/blktap2/drivers/tapdisk-vbd.c +3 -3
index 31bc2fe..e2e9cd5 100644
@@ -49,18 +49,18 @@
 #define DBG(_level, _f, _a...) tlog_write(_level, _f, ##_a)
 #define ERR(_err, _f, _a...) tlog_error(_err, _f, ##_a)
 
-#if 1                                                                        
+#if 1
 #define ASSERT(p)							\
 	do {								\
 		if (!(p)) {						\
 			DPRINTF("Assertion '%s' failed, line %d, "	\
 				"file %s", #p, __LINE__, __FILE__);	\
-			*(int*)0 = 0;					\
+			abort();					\
 		}							\
 	} while (0)
 #else
 #define ASSERT(p) ((void)0)
-#endif 
+#endif
 
 
 #define TD_VBD_EIO_RETRIES          10
Signature · 7 lines
2.7.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Doug Goldstein

Instead of trying to write a snippet of code that crashes the process just use abort() directly. This is to fix the build on clang which detects that the snippet of code will crash and fails to compile. At the same time removed extraneous whitespace in the macro.

I definitely remember encountering this issue when trying to do clang builds in the past. I wonder where the patch went...

Quoted 27 lines

---
Honestly this whole macro could get replaced with assert(3) but I wanted to make the smallest change possible. If that's preferrable I'll do that. The man page claims that assert(3) will print the following to stderr:

"assertion \"%s\" failed: file \"%s\", line %d\n", \
        "expression", __FILE__, __LINE__);
---
 tools/blktap2/drivers/tapdisk-vbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/blktap2/drivers/tapdisk-vbd.c +1 -2
index 31bc2fe..e2e9cd5 100644
@@ -49,18 +49,18 @@
 #define DBG(_level, _f, _a...) tlog_write(_level, _f, ##_a)
 #define ERR(_err, _f, _a...) tlog_error(_err, _f, ##_a)
 
-#if 1                                                                        
+#if 1
 #define ASSERT(p)							\
 	do {								\
 		if (!(p)) {						\
 			DPRINTF("Assertion '%s' failed, line %d, "	\
 				"file %s", #p, __LINE__, __FILE__);	\
-			*(int*)0 = 0;					\

tools/blktap2/drivers/tapdisk-vbd.c line 66

Quoted 10 lines
tools/blktap2/drivers/tapdisk-vbd.c +2 -1
+			abort();					\
 		}							\
 	} while (0)
 #else
 #define ASSERT(p) ((void)0)
-#endif 
+#endif
 
 
 #define TD_VBD_EIO_RETRIES          10

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#2 lore raw
In reply to Doug Goldstein
Quoted 6 lines · Doug Goldstein

Instead of trying to write a snippet of code that crashes the process just use abort() directly. This is to fix the build on clang which detects that the snippet of code will crash and fails to compile. At the same time removed extraneous whitespace in the macro.

And queued.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel