MT#55283 update parsing function to bool

... and improve resilience with sanity checks.

Change-Id: Ica45fb38e16df2ffdd8792071f6842d3ee824d60
pull/1759/head
Richard Fuchs 2 years ago
parent 48f98032d4
commit ea0d1775f3

@ -247,12 +247,15 @@ str *call_lookup_udp(char **out) {
}
static int info_parse_func(char **a, void **ret, void *p) {
static bool info_parse_func(char **a, void **ret, void *p) {
if (!a[0] || !a[1])
return false;
GHashTable *ih = p;
g_hash_table_replace(ih, strdup(a[0]), strdup(a[1]));
return -1;
return false;
}
static void info_parse(const char *s, GHashTable *ih) {
@ -260,7 +263,10 @@ static void info_parse(const char *s, GHashTable *ih) {
}
static int streams_parse_func(char **a, void **ret, void *p) {
static bool streams_parse_func(char **a, void **ret, void *p) {
if (!a[0] || !a[1])
return false;
struct stream_params *sp;
int *i;
@ -284,12 +290,12 @@ static int streams_parse_func(char **a, void **ret, void *p) {
goto fail;
*ret = sp;
return 0;
return true;
fail:
ilog(LOG_WARNING, "Failed to parse a media stream: %s%s:%s%s", FMT_M(a[0], a[1]));
g_slice_free1(sizeof(*sp), sp);
return -1;
return false;
}

@ -104,7 +104,7 @@ int pcre_multi_match(pcre *re, pcre_extra *ree, const char *s, unsigned int num,
el[i] = (ov[0] == -1) ? NULL : g_strndup(s + start + ov[0], ov[1] - ov[0]);
}
if (!f(el, &ins, p))
if (f(el, &ins, p))
g_queue_push_tail(q, ins);
for (i = 0; i < num; i++) {

@ -30,7 +30,7 @@
/*** PROTOTYPES ***/
typedef int (*parse_func)(char **, void **, void *);
typedef bool (*parse_func)(char **, void **, void *);
int pcre_multi_match(pcre *, pcre_extra *, const char *, unsigned int, parse_func, void *, GQueue *);
INLINE void strmove(char **, char **);

Loading…
Cancel
Save