Skip to content

Commit

Permalink
dns-sd: Fix error handling in dnssd_add_scan_result()
Browse files Browse the repository at this point in the history
iio_context_create() never returns NULL on error, but a pointer-encoded
error code instead.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei authored and mhennerich committed Feb 20, 2024
1 parent 7ba23c8 commit 14aff9d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static int dnssd_add_scan_result(const struct iio_context_params *params,
const char *hw_model = NULL, *serial = NULL;
const struct iio_attr *attr;
unsigned int i;
int err;

if (port == IIOD_PORT) {
iio_snprintf(uri, sizeof(uri), "ip:%s", hostname);
Expand All @@ -107,9 +108,10 @@ static int dnssd_add_scan_result(const struct iio_context_params *params,
}

ctx = iio_create_context(params, uri);
if (!ctx) {
prm_err(params, "No context at %s\n", addr_str);
return -ENOMEM;
err = iio_err(ctx);
if (err) {
prm_perror(params, err, "No context at %s\n", addr_str);
return err;
}

attr = iio_context_find_attr(ctx, "hw_model");
Expand Down

0 comments on commit 14aff9d

Please sign in to comment.