diff --git a/dns_sd.c b/dns_sd.c index 8afe92124..0fb81d884 100644 --- a/dns_sd.c +++ b/dns_sd.c @@ -286,13 +286,14 @@ int dnssd_discover_host(char *addr_str, size_t addr_len, uint16_t *port) ret = dnssd_find_hosts(&ddata); if (ret < 0) - return ret; + goto host_fail; if (ddata) { *port = ddata->port; strncpy(addr_str, ddata->addr_str, addr_len); } +host_fail: dnssd_free_all_discovery_data(ddata); /* negative error codes, 0 for no data */ diff --git a/iiod/iiod.c b/iiod/iiod.c index 5b4309cda..aad84e7aa 100644 --- a/iiod/iiod.c +++ b/iiod/iiod.c @@ -407,9 +407,24 @@ static int main_interactive(struct iio_context *ctx, bool verbose, bool use_aio) if (!use_aio) { flags = fcntl(STDIN_FILENO, F_GETFL); - fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); + if (flags >= 0) + flags = fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); + if (flags < 0) { + char err_str[1024]; + iio_strerror(errno, err_str, sizeof(err_str)); + IIO_ERROR("Could not get/set O_NONBLOCK on STDIN_FILENO" + " %s (%d)\n", err_str, -errno); + } + flags = fcntl(STDOUT_FILENO, F_GETFL); - fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK); + if (flags >= 0) + flags = fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK); + if (flags < 0) { + char err_str[1024]; + iio_strerror(errno, err_str, sizeof(err_str)); + IIO_ERROR("Could not get/set O_NONBLOCK on STDOUT_FILENO" + " %s (%d)\n", err_str, -errno); + } } interpreter(ctx, STDIN_FILENO, STDOUT_FILENO, verbose, diff --git a/tests/iio_stresstest.c b/tests/iio_stresstest.c index 12dc5a345..0c074db68 100644 --- a/tests/iio_stresstest.c +++ b/tests/iio_stresstest.c @@ -385,15 +385,18 @@ int main(int argc, char **argv) break; case 'b': info.arg_index += 2; - info.buffer_size = atoi(info.argv[info.arg_index]); + info.buffer_size = strtol(info.argv[info.arg_index], NULL, 10); + /* Max 4M */ + if (info.buffer_size > (1024 * 1024 * 4)) + info.buffer_size = 1024 * 1024 * 4; break; case 't': info.arg_index +=2; - info.timeout = 1000 * atoi(info.argv[info.arg_index]); + info.timeout = 1000 * strtol(info.argv[info.arg_index], NULL, 10); break; case 'T': info.arg_index +=2; - info.num_threads = atoi(info.argv[info.arg_index]); + info.num_threads = strtol(info.argv[info.arg_index], NULL, 10); break; case 'v': if (!info.verbose)