Skip to content

Commit

Permalink
MSVC 2019: Fix some minor errors pointed out by MSVS 2019
Browse files Browse the repository at this point in the history
In usb.c, tests/iio_common.c, tests/iio_attr.c & tests/iio_readdev.c
we were defining some varaibles twice (so don't do that).

In xml.c, we were passing sizeof() (which is a size_t) to something that
expected an unsigned int, so cast things.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed May 31, 2020
1 parent fdbfe59 commit 8d8c76c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
7 changes: 1 addition & 6 deletions tests/iio_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ int main(int argc, char **argv)
for (j = 0; j < nb_channels; j++) {
struct iio_channel *ch;
const char *type_name;
unsigned int k, nb_attrs;
unsigned int k;

if (!search_channel || !device_index)
continue;
Expand Down Expand Up @@ -741,7 +741,6 @@ int main(int argc, char **argv)
}

if (search_device && device_index && nb_attrs) {
unsigned int j;
int ret;
for (j = 0; j < nb_attrs; j++) {
const char *attr = iio_device_get_attr(dev, j);
Expand Down Expand Up @@ -772,8 +771,6 @@ int main(int argc, char **argv)
}

if (search_buffer && device_index && nb_attrs) {
unsigned int j;

for (j = 0; j < nb_attrs; j++) {
int ret;
const char *attr = iio_device_get_buffer_attr(dev, j);
Expand All @@ -799,8 +796,6 @@ int main(int argc, char **argv)
printf("found %u debug attributes\n", nb_attrs);

if (search_debug && device_index && nb_attrs) {
unsigned int j;

for (j = 0; j < nb_attrs; j++) {
int ret;
const char *attr = iio_device_get_debug_attr(dev, j);
Expand Down
4 changes: 2 additions & 2 deletions tests/iio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ unsigned long int sanitize_clamp(const char *name, const char *argv,

char ** dup_argv(char * name, int argc, char * argv[])
{
int i = 1;
int i;
char** new_argv = xmalloc((argc + 1) * sizeof(char *), name);

for(int i = 0; i < argc; i++) {
for(i = 0; i < argc; i++) {
new_argv[i] = cmn_strndup(argv[i], NAME_MAX);
if (!new_argv[i])
goto err_dup;
Expand Down
2 changes: 1 addition & 1 deletion tests/iio_readdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int main(int argc, char **argv)
#endif

while (app_running) {
ssize_t ret = iio_buffer_refill(buffer);
ret = iio_buffer_refill(buffer);
if (ret < 0) {
if (app_running) {
char buf[256];
Expand Down
2 changes: 0 additions & 2 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ struct iio_context * usb_create_context(unsigned int bus,

ret = libusb_claim_interface(hdl, intrfc);
if (ret) {
char err_str[1024];
ret = -(int) libusb_to_errno(ret);
iio_strerror(-ret, err_str, sizeof(err_str));
IIO_ERROR("Unable to claim interface %u:%u:%u: %s (%i)\n",
Expand All @@ -932,7 +931,6 @@ struct iio_context * usb_create_context(unsigned int bus,

ret = libusb_get_active_config_descriptor(usb_dev, &conf_desc);
if (ret) {
char err_str[1024];
ret = -(int) libusb_to_errno(ret);
iio_strerror(-ret, err_str, sizeof(err_str));
IIO_ERROR("Unable to get config descriptor: %s (%i)\n",
Expand Down
6 changes: 4 additions & 2 deletions xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ static void setup_scan_element(struct iio_channel *chn, xmlNode *n)
if (strchr(content, 'X')) {
iio_sscanf(content, "%ce:%c%u/%uX%u>>%u",
#ifdef _MSC_BUILD
&e, sizeof(e), &s, sizeof(s),
&e, (unsigned int)sizeof(e),
&s, (unsigned int)sizeof(s),
#else
&e, &s,
#endif
Expand All @@ -164,7 +165,8 @@ static void setup_scan_element(struct iio_channel *chn, xmlNode *n)
chn->format.repeat = 1;
iio_sscanf(content, "%ce:%c%u/%u>>%u",
#ifdef _MSC_BUILD
&e, sizeof(e), &s, sizeof(s),
&e, (unsigned int)sizeof(e),
&s, (unsigned int)sizeof(s),
#else
&e, &s,
#endif
Expand Down

0 comments on commit 8d8c76c

Please sign in to comment.