Skip to content

Commit

Permalink
dns_sd.c: Scanning doesn't require context
Browse files Browse the repository at this point in the history
Remove functions dnssd_context_scan_init() and
dnssd_context_scan_free(), as the context structure is actually never
used.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed May 24, 2021
1 parent 2988fe1 commit d93de75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
25 changes: 1 addition & 24 deletions dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ static void dnssd_remove_node(struct dns_sd_discovery_data **ddata, int n)
* DNS Service Discovery is turned on
*/

struct iio_scan_backend_context {
struct addrinfo *res;
};

static int dnssd_fill_context_info(struct iio_context_info *info,
char *hostname, char *addr_str, int port)
{
Expand Down Expand Up @@ -144,24 +140,6 @@ static int dnssd_fill_context_info(struct iio_context_info *info,
return 0;
}

struct iio_scan_backend_context * dnssd_context_scan_init(void)
{
struct iio_scan_backend_context *ctx;

ctx = malloc(sizeof(*ctx));
if (!ctx) {
errno = ENOMEM;
return NULL;
}

return ctx;
}

void dnssd_context_scan_free(struct iio_scan_backend_context *ctx)
{
free(ctx);
}

/*
* remove the ones in the list that you can't connect to
* This is sort of silly, but we have seen non-iio devices advertised
Expand Down Expand Up @@ -255,8 +233,7 @@ void remove_dup_discovery_data(struct dns_sd_discovery_data **ddata)
*ddata = d;
}

int dnssd_context_scan(struct iio_scan_backend_context *ctx,
struct iio_scan_result *scan_result)
int dnssd_context_scan(struct iio_scan_result *scan_result)
{
struct iio_context_info **info;
struct dns_sd_discovery_data *ddata, *ndata;
Expand Down
6 changes: 1 addition & 5 deletions iio-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,7 @@ void usb_context_scan_free(struct iio_scan_backend_context *ctx);
int usb_context_scan(struct iio_scan_backend_context *ctx,
struct iio_scan_result *scan_result);

struct iio_scan_backend_context * dnssd_context_scan_init(void);
void dnssd_context_scan_free(struct iio_scan_backend_context *ctx);

int dnssd_context_scan(struct iio_scan_backend_context *ctx,
struct iio_scan_result *scan_result);
int dnssd_context_scan(struct iio_scan_result *scan_result);

ssize_t iio_device_get_sample_size_mask(const struct iio_device *dev,
const uint32_t *mask, size_t words);
Expand Down
12 changes: 5 additions & 7 deletions scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

struct iio_scan_context {
struct iio_scan_backend_context *usb_ctx;
struct iio_scan_backend_context *dnssd_ctx;
bool scan_network;
bool scan_local;
};

Expand Down Expand Up @@ -54,8 +54,8 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx,
}
}

if (HAVE_DNS_SD && ctx->dnssd_ctx) {
int ret = dnssd_context_scan(ctx->dnssd_ctx, &scan_result);
if (HAVE_DNS_SD && ctx->scan_network) {
int ret = dnssd_context_scan(&scan_result);
if (ret < 0) {
if (scan_result.info)
iio_context_info_list_free(scan_result.info);
Expand Down Expand Up @@ -138,8 +138,8 @@ struct iio_scan_context * iio_create_scan_context(
if (WITH_USB_BACKEND && (!backend || strstr(backend, "usb")))
ctx->usb_ctx = usb_context_scan_init();

if (HAVE_DNS_SD && (!backend || strstr(backend, "ip")))
ctx->dnssd_ctx = dnssd_context_scan_init();
if (!backend || strstr(backend, "ip"))
ctx->scan_network = true;

return ctx;
}
Expand All @@ -148,8 +148,6 @@ void iio_scan_context_destroy(struct iio_scan_context *ctx)
{
if (WITH_USB_BACKEND && ctx->usb_ctx)
usb_context_scan_free(ctx->usb_ctx);
if (HAVE_DNS_SD && ctx->dnssd_ctx)
dnssd_context_scan_free(ctx->dnssd_ctx);
free(ctx);
}

Expand Down

0 comments on commit d93de75

Please sign in to comment.