From: Rafał Miłecki Date: Thu, 9 Mar 2017 21:17:32 +0000 (+0100) Subject: Drop unneeded code to simplify getting hosts over ubus X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=46b87811664756aacaf6ef945b9d247790de49df;p=project%2Fmdnsd.git Drop unneeded code to simplify getting hosts over ubus This code in umdns_hosts was there since ever but it seems like an unneeded copy & paste part of umdns_browse. In this function we iterate over *host* entries of cached services list. It means the entry field conains values like "example.local". In such case looking for "._" is pointless and appending ".local" results in looking for entries like "example.local.local". This code make sense for browsing *services* only where for entries like "ex._ssh._tcp.local" we try dumping "ex.local" & "ex._ssh._tcp.local". Signed-off-by: Rafał Miłecki --- diff --git a/ubus.c b/ubus.c index 9ceeab1..4120fd5 100644 --- a/ubus.c +++ b/ubus.c @@ -97,21 +97,13 @@ umdns_hosts(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *msg) { struct cache_service *s; - char *buffer = (char *) mdns_buf; void *c; blob_buf_init(&b, 0); avl_for_each_element(&services, s, avl) { - char *local; if (!cache_service_is_host(s)) continue; - snprintf(buffer, MAX_NAME_LEN, "%s", s->entry); - local = strstr(buffer, "._"); - if (local) - *local = '\0'; - c = blobmsg_open_table(&b, buffer); - strncat(buffer, ".local", MAX_NAME_LEN); - cache_dump_records(&b, buffer); + c = blobmsg_open_table(&b, s->entry); cache_dump_records(&b, s->entry); blobmsg_close_table(&b, c); }