From: Jaroslav Kysela Date: Wed, 14 Oct 2015 13:37:17 +0000 (+0200) Subject: url: small cleanup - add urlinit() fcn X-Git-Tag: v4.2.1~1914 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85bfb78dd0160bc094c09372f666865d7389a829;p=thirdparty%2Ftvheadend.git url: small cleanup - add urlinit() fcn --- diff --git a/src/config.c b/src/config.c index ffdd9a799..5b7f558da 100644 --- a/src/config.c +++ b/src/config.c @@ -1715,7 +1715,7 @@ config_class_cors_origin_set ( void *o, const void *v ) prop_sbuf[0] = '*'; prop_sbuf[1] = '\0'; } else { - memset(&u, 0, sizeof(u)); + urlinit(&u); urlparse(s, &u); if (u.scheme && (!strcmp(u.scheme, "http") || !strcmp(u.scheme, "https")) && u.host) { if (u.port) diff --git a/src/httpc.c b/src/httpc.c index ad4bead4d..d92971aaf 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -1199,7 +1199,7 @@ http_client_redirected ( http_client_t *hc ) hc->hc_scheme, hc->hc_host, hc->hc_port, location); } - memset(&u, 0, sizeof(u)); + urlinit(&u); if (urlparse(location2 ? location2 : location, &u)) { tvherror("httpc", "%04X: redirection - cannot parse url '%s'", shortid(hc), location2 ? location2 : location); @@ -1740,8 +1740,8 @@ http_client_testsuite_run( void ) tvhlog(LOG_NOTICE, "httpc", "Test: unable to open '%s': %s", path, strerror(errno)); return; } - memset(&u1, 0, sizeof(u1)); - memset(&u2, 0, sizeof(u2)); + urlinit(&u1); + urlinit(&u2); http_arg_init(&args); efd = tvhpoll_create(1); while (fgets(line, sizeof(line), fp) != NULL && tvheadend_running) { diff --git a/src/imagecache.c b/src/imagecache.c index 3bb4e43e4..c46e7d50c 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -248,7 +248,7 @@ imagecache_image_fetch ( imagecache_image_t *img ) if (img->url == NULL || img->url[0] == '\0') return res; - memset(&url, 0, sizeof(url)); + urlinit(&url); /* Open file */ if (hts_settings_buildpath(path, sizeof(path), "imagecache/data/%d", diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index d152c8f17..0c17ce8cf 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -266,7 +266,7 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) /* Parse URL */ mpegts_mux_nice_name((mpegts_mux_t*)im, buf, sizeof(buf)); - memset(&url, 0, sizeof(url)); + urlinit(&url); if (raw && !strncmp(raw, "pipe://", 7)) { diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index 825de463e..dcf573544 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -85,7 +85,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, chnum += (int64_t)*total * CHANNEL_SPLIT; } - memset(&u, 0, sizeof(u)); + urlinit(&u); if (urlparse(url, &u)) return; if (u.host == NULL || u.host[0] == '\0') @@ -373,7 +373,7 @@ iptv_auto_network_fetch_complete(http_client_t *hc) return 0; } - memset(&u, 0, sizeof(u)); + urlinit(&u); if (!urlparse(in->in_url, &u)) { last_url = strrchr(u.path, '/'); if (last_url) @@ -411,7 +411,7 @@ iptv_auto_network_fetch(void *aux) http_client_t *hc; url_t u; - memset(&u, 0, sizeof(u)); + urlinit(&u); if (in->in_url == NULL) goto done; diff --git a/src/input/mpegts/iptv/iptv_http.c b/src/input/mpegts/iptv/iptv_http.c index db228ee34..2e9ef308b 100644 --- a/src/input/mpegts/iptv/iptv_http.c +++ b/src/input/mpegts/iptv/iptv_http.c @@ -139,7 +139,7 @@ iptv_http_complete tvherror("iptv", "m3u contents parsing failed"); return 0; } - memset(&u, 0, sizeof(u)); + urlinit(&u); if (!urlparse(url, &u)) { hc->hc_keepalive = 0; r = http_client_simple_reconnect(hc, &u); diff --git a/src/input/mpegts/iptv/iptv_mux.c b/src/input/mpegts/iptv/iptv_mux.c index 691b251e2..0004e22ef 100644 --- a/src/input/mpegts/iptv/iptv_mux.c +++ b/src/input/mpegts/iptv/iptv_mux.c @@ -64,7 +64,7 @@ iptv_url_set ( char **url, char **sane_url, const char *str, int allow_file, int iptv_url_set0(url, sane_url, str, str); return 1; } - memset(&u, 0, sizeof(u)); + urlinit(&u); if (!urlparse(str, &u)) { len = (u.scheme ? strlen(u.scheme) + 3 : 0) + (u.host ? strlen(u.host) + 1 : 0) + diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index 9bd32f431..3eb63d369 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -1119,6 +1119,7 @@ satip_discovery_static(const char *descurl) if (satip_device_find_by_descurl(descurl)) return; d = calloc(1, sizeof(satip_discovery_t)); + urlinit(&d->url); if (urlparse(descurl, &d->url)) { satip_discovery_destroy(d, 0); return; diff --git a/src/url.h b/src/url.h index 5c9b632a2..d0b7d8044 100644 --- a/src/url.h +++ b/src/url.h @@ -21,6 +21,7 @@ #define __TVH_URL_H__ #include +#include /* URL structure */ typedef struct url @@ -36,6 +37,7 @@ typedef struct url char *raw; } url_t; +static inline void urlinit ( url_t *url ) { memset(url, 0, sizeof(*url)); } void urlreset ( url_t *url ); int urlparse ( const char *str, url_t *url ); void urlparse_done ( void );