From 46b87811664756aacaf6ef945b9d247790de49df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 9 Mar 2017 22:17:32 +0100 Subject: [PATCH] Drop unneeded code to simplify getting hosts over ubus MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- ubus.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) 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); } -- 2.11.0