Skip to content

Commit facf712

Browse files
anhmoltnordicjm
authored andcommitted
lib: gcf_sms: pass NULL to strtok_r to continue parsing same string
The strtok_r documentation says that each subsequent call that should parse the same string should set the str arguement to NULL. Restarting the parsing based on the saveptr argument, as was previously done, only works because the context that the strtok_r function saves to saveptr happens to be the address where the function left off. Signed-off-by: Andreas Moltumyr <[email protected]>
1 parent 2db01d0 commit facf712

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/gcf_sms/gcf_sms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int gcf_sms_filter_callback(char *buf, size_t len, char *at_cmd)
202202
}
203203

204204
/* Get the next command. */
205-
msg = strtok_r(msg_rest, ";", &msg_rest);
205+
msg = strtok_r(NULL, ";", &msg_rest);
206206
/* Add AT for concatenated AT-commands. */
207207
if ((msg) && (msg - 2 * sizeof(char) >= at_cmd)) {
208208
msg = msg - 2 * sizeof(char);

0 commit comments

Comments
 (0)