The l_strv_append() function needlessly post-incremented an array
index value prior to returning. Drop the post-increment, and a
l_strv_append() unit test.
Ossama Othman (2):
unit: Add test for l_strv_append().
strv: Remove unnecessary post-increment.
ell/strv.c | 2 +-
unit/test-string.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
--
2.17.1
New subject: [PATCH 2/2] strv: Remove unnecessary post-increment.
Remove unecessary post-increment of a string array index in
l_strv_append(). The updated index value was not used after the
post-increment.
---
ell/strv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/strv.c b/ell/strv.c
index a507626..89f2df5 100644
--- a/ell/strv.c
+++ b/ell/strv.c
@@ -284,7 +284,7 @@ LIB_EXPORT char **l_strv_append(char **str_array, const char *str)
for (i = 0; i < len; i++)
ret[i] = str_array[i];
- ret[i++] = l_strdup(str);
+ ret[i] = l_strdup(str);
l_free(str_array);
--
2.17.1
The l_strv_append() function needlessly post-incremented an array
index value prior to returning. Drop the post-increment, and a
l_strv_append() unit test.