You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by li...@apache.org on 2021/11/18 16:15:05 UTC
[incubator-nuttx-apps] branch master updated: testing/sensortest: Fix printf format warning
This is an automated email from the ASF dual-hosted git repository.
liuhaitao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new fd2289a testing/sensortest: Fix printf format warning
fd2289a is described below
commit fd2289a8a293607025deda05424990357f687ad7
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Nov 18 22:40:17 2021 +0800
testing/sensortest: Fix printf format warning
sensortest.c: In function 'print_valu':
Error: sensortest.c:161:10: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
161 | printf("%s: timestamp:%" PRIu64 " value:%u\n",
| ^~~~~~~~~~~~~~~~~
162 | name, event->timestamp, event->ppg);
| ~~~~~~~~~~
| |
| uint32_t {aka long unsigned int}
sensortest.c:161:44: note: format string is defined here
161 | printf("%s: timestamp:%" PRIu64 " value:%u\n",
| ~^
| |
| unsigned int
| %lu
sensortest.c: In function 'print_gps':
Error: sensortest.c:169:10: error: format '%u' expects argument of type 'unsigned int', but argument 15 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
169 | printf("%s: timestamp:%" PRIu64 " time_utc: %" PRIu64 " latitude: %f "
| ^~~~~~~~~~~~~~~~~
......
175 | event->ground_speed, event->course, event->satellites_used);
| ~~~~~~~~~~~~~~~~~~~~~~
| |
| uint32_t {aka long unsigned int}
sensortest.c:172:13: note: format string is defined here
172 | " %u\n", name, event->timestamp, event->time_utc, event->latitude,
| ~^
| |
| unsigned int
| %lu
sensortest.c: In function 'print_gps_satellite':
Error: sensortest.c:183:10: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
183 | printf("%s: timestamp: %" PRIu64 " count: %u satellites: %u", name,
| ^~~~~~~~~~~~~~~~~~
184 | event->timestamp, event->count, event->satellites);
| ~~~~~~~~~~~~
| |
| uint32_t {aka long unsigned int}
sensortest.c:183:46: note: format string is defined here
183 | printf("%s: timestamp: %" PRIu64 " count: %u satellites: %u", name,
| ~^
| |
| unsigned int
| %lu
Error: sensortest.c:183:10: error: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
183 | printf("%s: timestamp: %" PRIu64 " count: %u satellites: %u", name,
| ^~~~~~~~~~~~~~~~~~
184 | event->timestamp, event->count, event->satellites);
| ~~~~~~~~~~~~~~~~~
| |
| uint32_t {aka long unsigned int}
sensortest.c:183:61: note: format string is defined here
183 | printf("%s: timestamp: %" PRIu64 " count: %u satellites: %u", name,
| ~^
| |
| unsigned int
| %lu
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
testing/sensortest/sensortest.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/testing/sensortest/sensortest.c b/testing/sensortest/sensortest.c
index 1264905..1ec59bf 100644
--- a/testing/sensortest/sensortest.c
+++ b/testing/sensortest/sensortest.c
@@ -158,7 +158,7 @@ static void print_valf3(const char *buffer, const char *name)
static void print_valu(const char *buffer, const char *name)
{
struct sensor_event_ppg *event = (struct sensor_event_ppg *)buffer;
- printf("%s: timestamp:%" PRIu64 " value:%u\n",
+ printf("%s: timestamp:%" PRIu64 " value:%" PRIu32 "\n",
name, event->timestamp, event->ppg);
}
@@ -168,8 +168,9 @@ static void print_gps(const char *buffer, const char *name)
printf("%s: timestamp:%" PRIu64 " time_utc: %" PRIu64 " latitude: %f "
"longitude: %f altitude: %f altitude_ellipsoid: %f eph: %f epv: %f "
- "hdop: %f vdop: %f ground_speed: %f course: %f satellites_used:"
- " %u\n", name, event->timestamp, event->time_utc, event->latitude,
+ "hdop: %f vdop: %f ground_speed: %f course: %f satellites_used: %"
+ PRIu32 "\n",
+ name, event->timestamp, event->time_utc, event->latitude,
event->longitude, event->altitude, event->altitude_ellipsoid,
event->eph, event->epv, event->hdop, event->vdop,
event->ground_speed, event->course, event->satellites_used);
@@ -180,8 +181,9 @@ static void print_gps_satellite(FAR const char *buffer, FAR const char *name)
FAR struct sensor_event_gps_satellite *event =
(struct sensor_event_gps_satellite *)buffer;
- printf("%s: timestamp: %" PRIu64 " count: %u satellites: %u", name,
- event->timestamp, event->count, event->satellites);
+ printf("%s: timestamp: %" PRIu64 " count: %" PRIu32
+ " satellites: %" PRIu32 "\n",
+ name, event->timestamp, event->count, event->satellites);
}
static void usage(void)