Skip to content

Commit

Permalink
Merge pull request #426 from analogdevicesinc/rgetz-coverity-fixes2
Browse files Browse the repository at this point in the history
coverity fixes2
  • Loading branch information
rgetz authored Apr 8, 2020
2 parents 135c189 + 7d39af6 commit 45ee694
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
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);
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;
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

0 comments on commit 45ee694

Please sign in to comment.