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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/17084 ) Change subject: csn1.cpp: Rework ProcessError() function to print errors ...................................................................... csn1.cpp: Rework ProcessError() function to print errors Same API is kept to more easily keep code compatibility with wireshark's packet-csn1.c implementation. Change-Id: I1ce2c52e2357841aa1f31babfdce9011435f866b --- M src/csn1.cpp 1 file changed, 26 insertions(+), 23 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/src/csn1.cpp b/src/csn1.cpp index 1a3a530..d358286 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -37,6 +37,10 @@ #include "csn1.h" #include <gprs_debug.h> +extern "C" { +#include <osmocom/core/logging.h> +#include <osmocom/core/utils.h> +} #define pvDATA(_pv, _offset) ((void*) ((unsigned char*)_pv + _offset)) #define pui8DATA(_pv, _offset) ((guint8*) pvDATA(_pv, _offset)) @@ -92,35 +96,34 @@ ar->direction = 0; } -static const char* ErrCodes[] = -{ - "General 0", - "General -1", - "DATA_NOT VALID", - "IN SCRIPT", - "INVALID UNION INDEX", - "NEED_MORE BITS TO UNPACK", - "ILLEGAL BIT VALUE", - "Internal", - "STREAM_NOT_SUPPORTED", - "MESSAGE_TOO_LONG" +static const struct value_string csn1_error_names[] = { + { CSN_OK, "General 0" }, + { CSN_ERROR_GENERAL, "General -1" }, + { CSN_ERROR_DATA_NOT_VALID, "DATA_NOT VALID" }, + { CSN_ERROR_IN_SCRIPT, "IN SCRIPT" }, + { CSN_ERROR_INVALID_UNION_INDEX, "INVALID UNION INDEX" }, + { CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, "NEED_MORE BITS TO UNPACK" }, + { CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, "ILLEGAL BIT VALUE" }, + { CSN_ERROR_ILLEGAL_BIT_VALUE, "Internal" }, + { CSN_ERROR_STREAM_NOT_SUPPORTED, "STREAM_NOT_SUPPORTED" }, + { CSN_ERROR_MESSAGE_TOO_LONG, "MESSAGE_TOO_LONG" }, + { 0, NULL } }; -static gint16 -ProcessError( unsigned readIndex, const char* sz, gint16 err, const CSN_DESCR* pDescr) + +static gint16 ProcessError_impl(const char *file, int line, unsigned readIndex, + const char* sz, gint16 err, const CSN_DESCR* pDescr) { - gint16 i = MIN(-err, ((gint16) ElementsOf(ErrCodes)-1)); - if (i >= 0) - { - //LOG(ERR) << sz << "Error code: "<< ErrCodes[i] << pDescr?(pDescr->sz):"-"; - } - else - { - //LOG(ERR) << sz << ": " << pDescr?(pDescr->sz):"-"; - } + if (err != CSN_OK) + LOGPSRC(DCSN1, LOGL_ERROR, file, line, "%s: error %s (%d) at %s (idx %d)\n", + sz, get_value_string(csn1_error_names, err), err, + pDescr ? pDescr->sz : "-", readIndex); return err; } +#define ProcessError(readIndex, sz, err, pDescr) \ + ProcessError_impl(__FILE__, __LINE__, readIndex, sz, err, pDescr) + /** * ================================================================================================ -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/17084 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I1ce2c52e2357841aa1f31babfdce9011435f866b Gerrit-Change-Number: 17084 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <axilirator at gmail.com> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200205/e915cec9/attachment.htm>