Wrap osmo_strlcpy() calls
Using following semantic patch:
@@ expression A, B, C; @@
- osmo_strlcpy(A, B, sizeof(A));
+ OSMO_STRLCPY_ARRAY(A, B);
Which was applied using following command:
spatch --dir src -I src --sp-file strlcpy.spatch --in-place --recursive-includes
All the calls to osmo_strlcpy() which use destination buffer obtained
via sizeof() were replaced with the corresponding wrapper macro.
Change-Id: I67b482dedfa11237ac21894fc5930039e12434ab
Related: OS#2864
diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 8605040..be8e768 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -75,7 +75,7 @@
return NULL;
io = talloc_zero(ctx, struct imsi_op);
- osmo_strlcpy(io->imsi, imsi, sizeof(io->imsi));
+ OSMO_STRLCPY_ARRAY(io->imsi, imsi);
io->type = type;
osmo_timer_setup(&io->timer, imsi_op_timer_cb, io);
llist_add(&io->list, &g_imsi_ops);
@@ -107,7 +107,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+ OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
osmo_gsup_encode(msg, &gsup);
@@ -122,7 +122,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+ OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
osmo_gsup_encode(msg, &gsup);
@@ -135,7 +135,7 @@
struct osmo_gsup_message gsup = {0};
struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
+ OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
osmo_gsup_encode(msg, &gsup);