summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-04-27 18:21:16 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-29 13:10:37 +0200
commit5d547a4358edbd18744d1996d6ecb40328f09061 (patch)
tree866489ca9f7ec7be7ee8016e41680d61a819bb29
parentd8aa412c46638abea05488ebb2e9d70ca7fd628a (diff)
osmo_oap_decode(): Use common argument ordering
In general, if a function generates output data like a msgb (or in this case filling an osmo_oap_message structure), the output argument precedes the source. This is what we use all over libosmo*, and it is modelled after memcpy(), where dst is the first argument, before src. Let's align osmo_oap_decode(). Intestingly, osmo_oap_encode was already correct, so the encode/decode functions used different conventions before.
-rw-r--r--openbsc/include/openbsc/oap_messages.h4
-rw-r--r--openbsc/src/gprs/oap.c2
-rw-r--r--openbsc/src/gprs/oap_messages.c4
-rw-r--r--openbsc/tests/oap/oap_test.c4
4 files changed, 7 insertions, 7 deletions
diff --git a/openbsc/include/openbsc/oap_messages.h b/openbsc/include/openbsc/oap_messages.h
index 496a6de88..ecb66df34 100644
--- a/openbsc/include/openbsc/oap_messages.h
+++ b/openbsc/include/openbsc/oap_messages.h
@@ -64,7 +64,7 @@ struct osmo_oap_message {
uint8_t auts[16];
};
-int osmo_oap_decode(const uint8_t *data, size_t data_len,
- struct osmo_oap_message *oap_msg);
+int osmo_oap_decode(struct osmo_oap_message *oap_msg,
+ const uint8_t *data, size_t data_len);
void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);
diff --git a/openbsc/src/gprs/oap.c b/openbsc/src/gprs/oap.c
index a9fee566b..c7c97774d 100644
--- a/openbsc/src/gprs/oap.c
+++ b/openbsc/src/gprs/oap.c
@@ -214,7 +214,7 @@ int oap_handle(struct oap_state *state, const struct msgb *msg_rx, struct msgb *
OSMO_ASSERT(data);
- rc = osmo_oap_decode(data, data_len, &oap_msg);
+ rc = osmo_oap_decode(&oap_msg, data, data_len);
if (rc < 0) {
LOGP(DGPRS, LOGL_ERROR,
"Decoding OAP message failed with error '%s' (%d)\n",
diff --git a/openbsc/src/gprs/oap_messages.c b/openbsc/src/gprs/oap_messages.c
index 53ea9ac84..d81723fd6 100644
--- a/openbsc/src/gprs/oap_messages.c
+++ b/openbsc/src/gprs/oap_messages.c
@@ -31,8 +31,8 @@
#include <stdint.h>
-int osmo_oap_decode(const uint8_t *const_data, size_t data_len,
- struct osmo_oap_message *oap_msg)
+int osmo_oap_decode(struct osmo_oap_message *oap_msg,
+ const uint8_t *const_data, size_t data_len)
{
int rc;
uint8_t tag;
diff --git a/openbsc/tests/oap/oap_test.c b/openbsc/tests/oap/oap_test.c
index 625d8d892..339d77430 100644
--- a/openbsc/tests/oap/oap_test.c
+++ b/openbsc/tests/oap/oap_test.c
@@ -168,7 +168,7 @@ static void test_oap_api(void)
/* Expect the challenge response in msg_tx */
OSMO_ASSERT(msg_tx);
- OSMO_ASSERT(osmo_oap_decode(msg_tx->data, msg_tx->len, &oap_tx) == 0);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT);
OSMO_ASSERT(strcmp("e2d05b598c61d9ba",
osmo_hexdump_nospc(oap_tx.xres, sizeof(oap_tx.xres)))
@@ -191,7 +191,7 @@ static void test_oap_api(void)
OSMO_ASSERT(oap_handle(state, msg_rx, &msg_tx) == 0);
OSMO_ASSERT(state->registration_failures == 1);
OSMO_ASSERT(msg_tx);
- OSMO_ASSERT(osmo_oap_decode(msg_tx->data, msg_tx->len, &oap_tx) == 0);
+ OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_REGISTER_REQUEST);
OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE);
msgb_free(msg_tx);