Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverity fixes2 #426

Merged
merged 3 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
19 changes: 17 additions & 2 deletions iiod/iiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
commodo marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand Down
9 changes: 6 additions & 3 deletions tests/iio_stresstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
commodo marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down