fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/30579 )

Change subject: gsm0808: remove over-defensive assert()s for function parameters
......................................................................

gsm0808: remove over-defensive assert()s for function parameters

I believe the gsm0808_* API is mature enough to avoid assert()ing
pointers accepted via function parameters.  We can assume the caller
never passes NULL, as we do in almost all public API.

Change-Id: If9b4c92ace68191f5ddcc0a8a340fccbfe0f3dc0
---
M src/gsm/gsm0808_utils.c
1 file changed, 0 insertions(+), 29 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  neels: Looks good to me, approved



diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 5b7fff2..a1f51eb 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -90,8 +90,6 @@
        const uint8_t len_tl = 2;
        uint8_t len_v = sizeof(port);

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(ss);
        OSMO_ASSERT(ss->ss_family == AF_INET || ss->ss_family == AF_INET6);

        switch (ss->ss_family) {
@@ -141,7 +139,6 @@
        struct sockaddr_in6 sin6;
        const uint8_t *old_elem = elem;

-       OSMO_ASSERT(ss);
        if (!elem)
                return -EINVAL;
        if (len == 0)
@@ -189,7 +186,6 @@
  *  \returns number of bytes parsed */
 int gsm0808_dec_osmux_cid(uint8_t *cid, const uint8_t *elem, uint8_t len)
 {
-       OSMO_ASSERT(cid);
        if (!elem)
                return -EINVAL;
        if (len != 1)
@@ -303,9 +299,6 @@
        uint8_t *old_tail;
        uint8_t *tlv_len;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(sc);
-
        msgb_put_u8(msg, GSM0808_IE_SPEECH_CODEC);
        tlv_len = msgb_put(msg, 1);
        old_tail = msg->tail;
@@ -328,7 +321,6 @@
        uint8_t header;
        const uint8_t *old_elem = elem;

-       OSMO_ASSERT(sc);
        if (!elem)
                return -EINVAL;
        if (len == 0)
@@ -411,9 +403,6 @@
        uint8_t rc;
        unsigned int bytes_used = 0;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(scl);
-
        msgb_put_u8(msg, GSM0808_IE_SPEECH_CODEC_LIST);
        tlv_len = msgb_put(msg, 1);
        old_tail = msg->tail;
@@ -443,7 +432,6 @@
        int rc;
        uint8_t decoded = 0;

-       OSMO_ASSERT(scl);
        if (!elem)
                return -EINVAL;

@@ -480,8 +468,6 @@
        uint8_t *old_tail;
        uint8_t *tlv_len;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(ct);
        OSMO_ASSERT(ct->perm_spch_len <= CHANNEL_TYPE_ELEMENT_MAXLEN - 2);

        /* FIXME: Implement encoding support for Data
@@ -522,7 +508,6 @@
        uint8_t byte;
        const uint8_t *old_elem = elem;

-       OSMO_ASSERT(ct);
        if (!elem)
                return -EINVAL;
        if (len < 3 || len > 11)
@@ -711,8 +696,6 @@
        uint8_t *old_tail;
        uint8_t *tlv_len;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(ei);
        OSMO_ASSERT(ei->key_len <= ARRAY_SIZE(ei->key));
        OSMO_ASSERT(ei->perm_algo_len <= ENCRY_INFO_PERM_ALGO_MAXLEN);

@@ -751,7 +734,6 @@
        unsigned int perm_algo_len = 0;
        const uint8_t *old_elem = elem;

-       OSMO_ASSERT(ei);
        if (!elem)
                return -EINVAL;
        if (len == 0)
@@ -1011,9 +993,6 @@
        unsigned int i;
        uint8_t id_discr;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(cil);
-
        msgb_put_u8(msg, GSM0808_IE_CELL_IDENTIFIER_LIST);
        tlv_len = msgb_put(msg, 1);
        old_tail = msg->tail;
@@ -1055,9 +1034,6 @@
        uint8_t *tlv_len;
        unsigned int i;

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(cil);
-
        msgb_put_u8(msg, GSM0808_IE_CELL_IDENTIFIER_LIST);
        tlv_len = msgb_put(msg, 1);
        old_tail = msg->tail;
@@ -1233,7 +1209,6 @@
        size_t bytes_elem = 0;
        int list_len = 0;

-       OSMO_ASSERT(cil);
        if (!elem)
                return -EINVAL;
        if (len == 0)
@@ -1301,7 +1276,6 @@
        const uint8_t *old_elem = elem;
        unsigned int item_count = 0;

-       OSMO_ASSERT(cil);
        if (!elem)
                return -EINVAL;
        if (len == 0)
@@ -1459,9 +1433,6 @@
                .id_list_len = 1,
        };

-       OSMO_ASSERT(msg);
-       OSMO_ASSERT(ci);
-
        ie_tag = msg->tail;
        rc = gsm0808_enc_cell_id_list2(msg, &cil);


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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If9b4c92ace68191f5ddcc0a8a340fccbfe0f3dc0
Gerrit-Change-Number: 30579
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-MessageType: merged

Reply via email to