From c32f7d1ab0fba3c8554d50ba946daf1d25fb3b8d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 14 Jan 2018 16:18:36 +0100 Subject: [PATCH] htsmsg: field's hmf_name is char array now, fix clang warnings --- src/config.c | 2 +- src/htsmsg.c | 6 +++--- src/htsmsg_binary.c | 5 ++--- src/htsmsg_binary2.c | 4 ++-- src/htsmsg_json.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/config.c b/src/config.c index 2035da220..6609abd65 100644 --- a/src/config.c +++ b/src/config.c @@ -1334,7 +1334,7 @@ config_migrate_v21 ( void ) s64 = 0; htsmsg_field_get_s64(f, &s64); if ((s64 || !strcmp(str ?: "", f->hmf_name)) && - f->hmf_name && f->hmf_name[0]) { + f->hmf_name[0]) { a = htsmsg_create_map(); htsmsg_add_bool(a, "enabled", 1); htsmsg_add_msg(e, f->hmf_name, a); diff --git a/src/htsmsg.c b/src/htsmsg.c index 1dced9551..927057ff9 100644 --- a/src/htsmsg.c +++ b/src/htsmsg.c @@ -170,7 +170,7 @@ htsmsg_field_find(const htsmsg_t *msg, const char *name) if (msg == NULL || name == NULL) return NULL; TAILQ_FOREACH(f, &msg->hm_fields, hmf_link) { - if(f->hmf_name != NULL && !strcmp(f->hmf_name, name)) + if(!strcmp(f->hmf_name, name)) return f; } return NULL; @@ -1174,7 +1174,7 @@ htsmsg_print0(htsmsg_t *msg, int indent) for(i = 0; i < indent; i++) printf("\t"); - printf("%s (", f->hmf_name ?: ""); + printf("%s (", f->hmf_name); switch(f->hmf_type) { @@ -1324,7 +1324,7 @@ htsmsg_cmp(const htsmsg_t *m1, const htsmsg_t *m2) if (f1->hmf_type != f2->hmf_type) return 1; - if (strcmp(f1->hmf_name ?: "", f2->hmf_name ?: "")) + if (strcmp(f1->hmf_name, f2->hmf_name)) return 1; switch(f1->hmf_type) { diff --git a/src/htsmsg_binary.c b/src/htsmsg_binary.c index 91da0cdbd..d442c243e 100644 --- a/src/htsmsg_binary.c +++ b/src/htsmsg_binary.c @@ -220,8 +220,7 @@ htsmsg_binary_count(htsmsg_t *msg) TAILQ_FOREACH(f, &msg->hm_fields, hmf_link) { - len += 6; - len += f->hmf_name ? strlen(f->hmf_name) : 0; + len += 6 + strlen(f->hmf_name); switch(f->hmf_type) { case HMF_MAP: @@ -269,7 +268,7 @@ htsmsg_binary_write(htsmsg_t *msg, uint8_t *ptr) int l, i, namelen; TAILQ_FOREACH(f, &msg->hm_fields, hmf_link) { - namelen = f->hmf_name ? strlen(f->hmf_name) : 0; + namelen = strlen(f->hmf_name); *ptr++ = f->hmf_type; *ptr++ = namelen; diff --git a/src/htsmsg_binary2.c b/src/htsmsg_binary2.c index 282a580e8..5c5796642 100644 --- a/src/htsmsg_binary2.c +++ b/src/htsmsg_binary2.c @@ -327,7 +327,7 @@ htsmsg_binary2_count(htsmsg_t *msg) TAILQ_FOREACH(f, &msg->hm_fields, hmf_link) { l = htsmsg_binary2_field_length(f); len += 2 + htsmsg_binary2_length_count(l); - len += f->hmf_name ? strlen(f->hmf_name) : 0; + len += strlen(f->hmf_name); len += l; } return len; @@ -344,7 +344,7 @@ htsmsg_binary2_write(htsmsg_t *msg, uint8_t *ptr) int l, i, namelen; TAILQ_FOREACH(f, &msg->hm_fields, hmf_link) { - namelen = f->hmf_name ? strlen(f->hmf_name) : 0; + namelen = strlen(f->hmf_name); assert(namelen <= 0xff); *ptr++ = f->hmf_type; *ptr++ = namelen; diff --git a/src/htsmsg_json.c b/src/htsmsg_json.c index 95ab23571..f33950fb9 100644 --- a/src/htsmsg_json.c +++ b/src/htsmsg_json.c @@ -49,7 +49,7 @@ htsmsg_json_write(htsmsg_t *msg, htsbuf_queue_t *hq, int isarray, htsbuf_append(hq, indentor, indent < 16 ? indent : 16); if(!isarray) { - htsbuf_append_and_escape_jsonstr(hq, f->hmf_name ?: "noname"); + htsbuf_append_and_escape_jsonstr(hq, f->hmf_name); htsbuf_append(hq, ": ", pretty ? 2 : 1); } -- 2.47.3