From 3c6f47a7dbadcd6c4cedef405970d877014736e1 Mon Sep 17 00:00:00 2001 From: Dimas Abreu Archanjo Dutra Date: Mon, 19 Aug 2019 19:15:06 -0300 Subject: [PATCH] Making printf types in examples/dummy-iiostream.c platform independent. --- examples/dummy-iiostream.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/dummy-iiostream.c b/examples/dummy-iiostream.c index 7f1905508..09f1cfe0c 100644 --- a/examples/dummy-iiostream.c +++ b/examples/dummy-iiostream.c @@ -142,9 +142,9 @@ static ssize_t sample_cb(const struct iio_channel *chn, void *src, size_t bytes, printf("%s ", iio_channel_get_id(chn)); for (int j = 0; j < repeat; ++j) { if (bytes == sizeof(int16_t)) - printf("%i ", ((int16_t *)src)[j]); + printf("%i ", (int)((int16_t *)src)[j]); else if (bytes == sizeof(int64_t)) - printf("%ld ", ((int64_t *)src)[j]); + printf("%lld ", (long long)((int64_t *)src)[j]); } return bytes * repeat; @@ -301,7 +301,7 @@ int main (int argc, char **argv) if (has_ts) for (p_dat = iio_buffer_first(rxbuf, channels[channel_count-1]); p_dat < p_end; p_dat += p_inc) { now_ts = (((int64_t *)p_dat)[0]); - printf("[%04ld] ", last_ts > 0 ? (now_ts - last_ts)/1000/1000 : 0); + printf("[%04ld] ", (long)(last_ts > 0 ? (now_ts - last_ts)/1000/1000 : 0)); last_ts = now_ts; } @@ -317,9 +317,9 @@ int main (int argc, char **argv) for (p_dat = iio_buffer_first(rxbuf, channels[i]); p_dat < p_end; p_dat += p_inc) { for (int j = 0; j < repeat; ++j) { if (fmt->length/8 == sizeof(int16_t)) - printf("%i ", ((int16_t *)p_dat)[j]); + printf("%i ", (int)((int16_t *)p_dat)[j]); else if (fmt->length/8 == sizeof(int64_t)) - printf("%ld ", ((int64_t *)p_dat)[j]); + printf("%lld ", (long long)((int64_t *)p_dat)[j]); } } } @@ -351,9 +351,9 @@ int main (int argc, char **argv) for (int sample = 0; sample < bytes / sample_size; ++sample) { for (int j = 0; j < repeat; ++j) { if (fmt->length / 8 == sizeof(int16_t)) - printf("%i ", ((int16_t *)buf)[sample+j]); + printf("%i ", (int)((int16_t *)buf)[sample+j]); else if (fmt->length / 8 == sizeof(int64_t)) - printf("%li ", ((int64_t *)buf)[sample+j]); + printf("%lli ", (long long)((int64_t *)buf)[sample+j]); } }