[PATCH] libosmocore[master]: abis_nm_fail_evt_rep(): use va_list explicitly

Max gerrit-no-reply at lists.osmocom.org
Wed Jan 11 12:09:36 UTC 2017


Review at  https://gerrit.osmocom.org/1569

abis_nm_fail_evt_rep(): use va_list explicitly

Accept fixed number of arguments including va_list instead of variable
number of arguments. This allows this function to be used from another
vararg functions similar to vprintff() vs printf().

Related: OS#1615
Change-Id: Ib293dec1c2de9b664584a8456c782ea7b6dd8555
---
M include/osmocom/gsm/protocol/gsm_12_21.h
M src/gsm/abis_nm.c
2 files changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/1569/1

diff --git a/include/osmocom/gsm/protocol/gsm_12_21.h b/include/osmocom/gsm/protocol/gsm_12_21.h
index 1a95311..3281265 100644
--- a/include/osmocom/gsm/protocol/gsm_12_21.h
+++ b/include/osmocom/gsm/protocol/gsm_12_21.h
@@ -789,5 +789,6 @@
 struct msgb *abis_nm_fail_evt_rep(enum abis_nm_event_type t,
 				  enum abis_nm_severity s,
 				  enum abis_nm_pcause_type ct,
-				  uint16_t cause_value, const char *fmt, ...);
+				  uint16_t cause_value, const char *fmt,
+				  va_list ap);
 /*! @} */
diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c
index f50a54f..6695caf 100644
--- a/src/gsm/abis_nm.c
+++ b/src/gsm/abis_nm.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <errno.h>
+#include <stdarg.h>
 
 #include <osmocom/core/utils.h>
 #include <osmocom/core/logging.h>
@@ -528,11 +529,11 @@
 struct msgb *abis_nm_fail_evt_rep(enum abis_nm_event_type t,
 				  enum abis_nm_severity s,
 				  enum abis_nm_pcause_type ct,
-				  uint16_t cause_value, const char *fmt, ...)
+				  uint16_t cause_value, const char *fmt,
+				  va_list ap)
 {
 	uint8_t cause[3];
 	int len;
-	va_list ap;
 	char add_text[ABIS_NM_MSG_HEADROOM];
 	struct msgb *nmsg = msgb_alloc_headroom(ABIS_NM_MSG_SIZE,
 						ABIS_NM_MSG_HEADROOM,
@@ -548,9 +549,7 @@
 
 	msgb_tv_fixed_put(nmsg, NM_ATT_PROB_CAUSE, 3, cause);
 
-	va_start(ap, fmt);
 	len = vsnprintf(add_text, ABIS_NM_MSG_HEADROOM, fmt, ap);
-	va_end(ap);
 
 	if (len < 0) {
 		msgb_free(nmsg);

-- 
To view, visit https://gerrit.osmocom.org/1569
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib293dec1c2de9b664584a8456c782ea7b6dd8555
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>


More information about the gerrit-log mailing list