Change in libosmocore[master]: Don't call abort() directly, always use osmo_panic()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jun 29 17:53:52 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9760 )

Change subject: Don't call abort() directly, always use osmo_panic()
......................................................................

Don't call abort() directly, always use osmo_panic()

A loooong time ago, we introduced osmo_panic() as a wrapper around
abort().  The advantage is, that this wrapper can be overridden, and
that it will also work in embedded (bare iron) targets, where the
abort simply translates to an infinite loop.

Change-Id: I5a70eb65952cbc329bf96eacb428b07a9da32433
---
M include/osmocom/core/utils.h
M src/bitvec.c
M src/gsm/gsm0808_utils.c
3 files changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index cd22dfb..dd4461c 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -4,6 +4,7 @@
 
 #include <osmocom/core/backtrace.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/panic.h>
 
 /*! \defgroup utils General-purpose utility functions
  *  @{
@@ -77,9 +78,7 @@
  */
 #define OSMO_ASSERT(exp)    \
 	if (!(exp)) { \
-		fprintf(stderr, "Assert failed %s %s:%d\n", #exp, __BASE_FILE__, __LINE__); \
-		osmo_generate_backtrace(); \
-		abort(); \
+		osmo_panic("Assert failed %s %s:%d\n", #exp, __BASE_FILE__, __LINE__); \
 	}
 
 /*! duplicate a string using talloc and release its prior content (if any)
diff --git a/src/bitvec.c b/src/bitvec.c
index 884eb02..0f56e3e 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -44,6 +44,7 @@
 
 #include <osmocom/core/bits.h>
 #include <osmocom/core/bitvec.h>
+#include <osmocom/core/panic.h>
 
 #define BITNUM_FROM_COMP(byte, bit)	((byte*8)+bit)
 
@@ -530,7 +531,7 @@
 	case ONE: return '1';
 	case L: return 'L';
 	case H: return 'H';
-	default: abort();
+	default: osmo_panic("unexpected input in bit_value_to_char"); return 'X';
 	}
 }
 
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 080fc95..73f0234 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -155,7 +155,7 @@
 	/* See also 3GPP TS 48.008 3.2.2.103 Speech Codec List */
 	uint8_t header = 0;
 	uint8_t *old_tail;
-	bool type_extended;
+	bool type_extended = false;
 
 	/* Note: Extended codec types are codec types that require 8 instead
 	 * of 4 bit to fully specify the selected codec. In the following,

-- 
To view, visit https://gerrit.osmocom.org/9760
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5a70eb65952cbc329bf96eacb428b07a9da32433
Gerrit-Change-Number: 9760
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180629/9ae1ca9c/attachment.htm>


More information about the gerrit-log mailing list