Change in ...libosmocore[master]: utils.h: require a semi colon after OSMO_ASSERT

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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Jul 8 13:23:46 UTC 2019


lynxis lazus has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/14578 )

Change subject: utils.h: require a semi colon after OSMO_ASSERT
......................................................................

utils.h: require a semi colon after OSMO_ASSERT

When using `OSMO_ASSERT(exp);` clang will warn about
an empty expression because the semi colon was superflous.
Use do {} while (0) to enfore the need of a semi colon.
This might break other test.

Change-Id: I2272d29a81496164bebd1696a694383a28a86434
---
M include/osmocom/core/utils.h
M src/gsm/gsm0808_utils.c
M tests/ctrl/ctrl_test.c
3 files changed, 6 insertions(+), 6 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 601bb56..8585a6a 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -98,9 +98,9 @@
  *  the predicate evaluates to false (0).
  */
 #define OSMO_ASSERT(exp)    \
-	if (!(exp)) { \
+	do if (!(exp)) { \
 		osmo_panic("Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \
-	}
+	} while(0)
 
 /*! duplicate a string using talloc and release its prior content (if any)
  * \param[in] ctx Talloc context to use for allocation
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index afff59a..364a04f 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -273,7 +273,7 @@
 	case GSM0808_SCT_FR5:
 	case GSM0808_SCT_HR4:
 	case GSM0808_SCT_CSD:
-		OSMO_ASSERT((sc->cfg & 0xff00) == 0)
+		OSMO_ASSERT((sc->cfg & 0xff00) == 0);
 		msgb_put_u8(msg, (uint8_t) sc->cfg & 0xff);
 		break;
 	default:
@@ -874,7 +874,7 @@
 
 	msgb_put_u8(msg, cil->id_discr & 0x0f);
 
-	OSMO_ASSERT(cil->id_list_len <= GSM0808_CELL_ID_LIST2_MAXLEN)
+	OSMO_ASSERT(cil->id_list_len <= GSM0808_CELL_ID_LIST2_MAXLEN);
 	for (i = 0; i < cil->id_list_len; i++)
 		gsm0808_msgb_put_cell_id_u(msg, cil->id_discr, &cil->id_list[i]);
 
@@ -906,7 +906,7 @@
 
 	switch (cil->id_discr) {
 	case CELL_IDENT_LAC:
-		OSMO_ASSERT(cil->id_list_len <= CELL_ID_LIST_LAC_MAXLEN)
+		OSMO_ASSERT(cil->id_list_len <= CELL_ID_LIST_LAC_MAXLEN);
 		for (i=0;i<cil->id_list_len;i++) {
 			msgb_put_u16(msg, cil->id_list_lac[i]);
 		}
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index cffb803..b46e9ac 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -121,7 +121,7 @@
 
 		printf("replied: '%s'\n", osmo_escape_str((char*)msgb_l2(sent_msg), -1));
 		OSMO_ASSERT(t->reply_str);
-		OSMO_ASSERT(!strcmp(t->reply_str, (char*)msgb_l2(sent_msg)))
+		OSMO_ASSERT(!strcmp(t->reply_str, (char*)msgb_l2(sent_msg)));
 		msgb_free(sent_msg);
 	}
 	osmo_wqueue_clear(&ccon->write_queue);

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2272d29a81496164bebd1696a694383a28a86434
Gerrit-Change-Number: 14578
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190708/ce060d73/attachment.htm>


More information about the gerrit-log mailing list