Skip to content

Commit 056a9e6

Browse files
committed
Revert "These changes are a contribution from Robert Boisvert and the Alpine Linux team to address an issue that was encountered while testing with valgrind. The reported problem was that of an 'uninitialized value', and Robert Boisvert's statement was that the changes came from 'upstream'... although clearly he was not referring to upstream spandsp proper. By 'upstream' he may simply have been reporting what was told to him by others, and 'upstream' may actually mean some other fork of spandsp somewhere. That said, the claim was that this change resolved the issue as reported by valgrind. I'm not sure why the code needed to be so refactored as it was in order to resolve an uninitialized value, and as many times as I've examined this I've never really understood the uninitialized value issue here. However, admittedly the changed code is easier to follow, and as at_cmd_plus_VSID() was the only function to utilize parse_string_out(), I ultimately felt good about adopting it."
This reverts commit a701c59. Discussion with Steve Underwood indicates that whatever the uninitialized value issue was here, it has been remedied previously, and the code refactoring is undesireable.
1 parent 461bf79 commit 056a9e6

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

src/at_interpreter.c

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,43 @@ static int parse_string_list_out(at_state_t *s, const char **t, int *target, int
748748
}
749749
/*- End of function --------------------------------------------------------*/
750750

751+
static int parse_string_out(at_state_t *s, const char **t, char **target, const char *prefix)
752+
{
753+
char buf[100];
754+
755+
switch (*(*t)++)
756+
{
757+
case '=':
758+
switch (**t)
759+
{
760+
case '?':
761+
/* Show possible values */
762+
(*t)++;
763+
snprintf(buf, sizeof(buf), "%s", (prefix) ? prefix : "");
764+
at_put_response(s, buf);
765+
break;
766+
default:
767+
/* Set value */
768+
if (*target)
769+
span_free(*target);
770+
/* If this strdup fails, it should be harmless */
771+
*target = strdup(*t);
772+
break;
773+
}
774+
break;
775+
case '?':
776+
/* Show current index value */
777+
at_put_response(s, (*target) ? *target : "");
778+
break;
779+
default:
780+
return false;
781+
}
782+
while (**t)
783+
(*t)++;
784+
return true;
785+
}
786+
/*- End of function --------------------------------------------------------*/
787+
751788
static const char *s_reg_handler(at_state_t *s, const char *t, int reg)
752789
{
753790
int val;
@@ -5012,31 +5049,10 @@ static const char *at_cmd_plus_VSID(at_state_t *s, const char *t)
50125049
{
50135050
/* Extension of V.253 +VCID, Set calling number ID */
50145051
t += 5;
5015-
switch (*t)
5016-
{
5017-
case '=':
5018-
switch (*(t+1))
5019-
{
5020-
case '?':
5021-
/* Show possible values */
5022-
at_put_response(s, "");
5023-
break;
5024-
default:
5025-
/* Set value */
5026-
s->local_id = strdup(t + 1);
5027-
if (at_modem_control(s, AT_MODEM_CONTROL_SETID, s->local_id) < 0)
5028-
return NULL;
5029-
break;
5030-
}
5031-
break;
5032-
case '?':
5033-
/* Show current index value */
5034-
at_put_response(s, (s->local_id) ? s->local_id : "");
5035-
break;
5036-
default:
5052+
if (!parse_string_out(s, &t, &s->local_id, NULL))
5053+
return NULL;
5054+
if (at_modem_control(s, AT_MODEM_CONTROL_SETID, s->local_id) < 0)
50375055
return NULL;
5038-
}
5039-
while (*t) t++;
50405056
return t;
50415057
}
50425058
/*- End of function --------------------------------------------------------*/

0 commit comments

Comments
 (0)