Skip to content

Commit

Permalink
dnssd: Fix off by one error when adding device names
Browse files Browse the repository at this point in the history
for some reason, there was an off by one error, which means we always
dropped the last device, and never saw it when we were looking at scan
contexts...

pi@raspberrypi:~/libiio/build $ iio_info -s
Available contexts:
        0: 169.254.231.18 (cpu_thermal) [ip:raspberrypi.local]

should have been (and is after the fix):

pi@raspberrypi:~/libiio/build $ ./tests/iio_info -s
Available contexts:
        0: 169.254.231.18 (cpu_thermal,rpi_volt) [ip:raspberrypi.local]

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz authored and pcercuei committed Jul 17, 2023
1 parent f5ded6a commit f6a452b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static int dnssd_fill_context_info(struct iio_context_info *info,
} else {
iio_snprintf(description, sizeof(description), "%s (", addr_str);
p = description + strlen(description);
for (i = 0; i < iio_context_get_devices_count(ctx) - 1; i++) {
for (i = 0; i < iio_context_get_devices_count(ctx); i++) {
const struct iio_device *dev = iio_context_get_device(ctx, i);
const char *name = iio_device_get_name(dev);
if (name) {
Expand Down

0 comments on commit f6a452b

Please sign in to comment.