public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] util: In ASSERT(), use "fprintf(stderr, ...)" rather than err(...)
@ 2024-08-05 14:10 Laurent Vivier
  2024-08-05 14:34 ` Stefano Brivio
  2024-08-06  0:27 ` David Gibson
  0 siblings, 2 replies; 8+ messages in thread
From: Laurent Vivier @ 2024-08-05 14:10 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

We use our own implementation of assert() because the glic implementation
uses syscalls that aren't in our seccomp filter, see 7a8ed9459dfe
("Make assertions actually useful"). And we replaced it by an err(),
followed by an abort() (that is also catched by seccomp).
We don't have a coredump or a backtrace but we have at least the
error message... only if logging is enabled.

As this kind of information is needed in any case, replace the "err()"
function by an "fprintf(stderr, ...)".

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 util.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/util.h b/util.h
index b7541ce24e5a..b44b4bfdccd7 100644
--- a/util.h
+++ b/util.h
@@ -13,6 +13,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <signal.h>
+#include <stdio.h>
 #include <arpa/inet.h>
 
 #include "log.h"
@@ -67,8 +68,10 @@
 #define ASSERT(expr)							\
 	do {								\
 		if (!(expr)) {						\
-			err("ASSERTION FAILED in %s (%s:%d): %s",	\
-			    __func__, __FILE__, __LINE__, STRINGIFY(expr)); \
+			fprintf(stderr,					\
+				"ASSERTION FAILED in %s (%s:%d): %s\n",	\
+				__func__, __FILE__, __LINE__,		\
+				STRINGIFY(expr));			\
 			/* This may actually SIGSYS, due to seccomp,	\
 			 * but that will still get the job done		\
 			 */						\
-- 
@@ -13,6 +13,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <signal.h>
+#include <stdio.h>
 #include <arpa/inet.h>
 
 #include "log.h"
@@ -67,8 +68,10 @@
 #define ASSERT(expr)							\
 	do {								\
 		if (!(expr)) {						\
-			err("ASSERTION FAILED in %s (%s:%d): %s",	\
-			    __func__, __FILE__, __LINE__, STRINGIFY(expr)); \
+			fprintf(stderr,					\
+				"ASSERTION FAILED in %s (%s:%d): %s\n",	\
+				__func__, __FILE__, __LINE__,		\
+				STRINGIFY(expr));			\
 			/* This may actually SIGSYS, due to seccomp,	\
 			 * but that will still get the job done		\
 			 */						\
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-08-07  1:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-05 14:10 [PATCH] util: In ASSERT(), use "fprintf(stderr, ...)" rather than err(...) Laurent Vivier
2024-08-05 14:34 ` Stefano Brivio
2024-08-05 15:52   ` Laurent Vivier
2024-08-05 16:12     ` Stefano Brivio
2024-08-06  0:27 ` David Gibson
2024-08-06  9:27   ` Laurent Vivier
2024-08-06 11:43     ` Stefano Brivio
2024-08-06 12:28     ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).