[S] Change in libosmocore[master]: msgb: Add helper macro to decide if a segment is incomplete
arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/33655 ) Change subject: msgb: Add helper macro to decide if a segment is incomplete ...................................................................... msgb: Add helper macro to decide if a segment is incomplete This helps avoid common logical fallacies that that happen quickly during coding (i.e. giving a false logical condition) for a condition any segmentation callback will need. Related: OS#5753 Change-Id: Ifc7cf0629e93864bfb3e36c64143d4ccc777e4b6 --- M include/osmocom/core/msgb.h 1 file changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/33655/1 diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 5c58c84..372b85b 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -773,4 +773,11 @@ return osmo_hexdump((const unsigned char*) msgb_l4(msg), msgb_l4len(msg)); } +/*! Macro for checking a simple condition (to avoid accidental bugs) + * \param[in] msg Target 'struct msg *' + * \param[in] len_from_msg_metadata Length of data as expected from metadata of msg + * \returns boolean indicating if the data segment starting at msg->data is incomplete + */ +#define msgb_segment_is_incomplete(len_from_msg_metadata, msg)\ + (len_from_msg_metadata > (msg)->len) /*! @} */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33655 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ifc7cf0629e93864bfb3e36c64143d4ccc777e4b6 Gerrit-Change-Number: 33655 Gerrit-PatchSet: 1 Gerrit-Owner: arehbein <arehbein@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
arehbein