logger:Use inttypes

This commit is contained in:
David Sidrane
2021-04-22 06:27:07 -07:00
committed by Julian Oes
parent 3b725e5525
commit 5faa116681
2 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* *
* Copyright (c) 2019 PX4 Development Team. All rights reserved. * Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -310,7 +310,7 @@ int LoggedTopics::add_topics_from_file(const char *fname)
char topic_name[80]; char topic_name[80];
uint32_t interval_ms = 0; uint32_t interval_ms = 0;
uint32_t instance = 0; uint32_t instance = 0;
int nfields = sscanf(line, "%s %u %u", topic_name, &interval_ms, &instance); int nfields = sscanf(line, "%s %" PRIu32 " %" PRIu32, topic_name, &interval_ms, &instance);
if (nfields > 0) { if (nfields > 0) {
int name_len = strlen(topic_name); int name_len = strlen(topic_name);
@@ -366,7 +366,7 @@ bool LoggedTopics::add_topic(const orb_metadata *topic, uint16_t interval_ms, ui
} }
if (_subscriptions.count >= MAX_TOPICS_NUM) { if (_subscriptions.count >= MAX_TOPICS_NUM) {
PX4_WARN("Too many subscriptions, failed to add: %s %d", topic->o_name, instance); PX4_WARN("Too many subscriptions, failed to add: %s %" PRIu8, topic->o_name, instance);
return false; return false;
} }
@@ -391,7 +391,7 @@ bool LoggedTopics::add_topic(const char *name, uint16_t interval_ms, uint8_t ins
if (_subscriptions.sub[j].id == static_cast<ORB_ID>(topics[i]->o_id) && if (_subscriptions.sub[j].id == static_cast<ORB_ID>(topics[i]->o_id) &&
_subscriptions.sub[j].instance == instance) { _subscriptions.sub[j].instance == instance) {
PX4_DEBUG("logging topic %s(%d), interval: %i, already added, only setting interval", PX4_DEBUG("logging topic %s(%" PRUu8 "), interval: %" PRUu16 ", already added, only setting interval",
topics[i]->o_name, instance, interval_ms); topics[i]->o_name, instance, interval_ms);
_subscriptions.sub[j].interval_ms = interval_ms; _subscriptions.sub[j].interval_ms = interval_ms;
@@ -403,7 +403,7 @@ bool LoggedTopics::add_topic(const char *name, uint16_t interval_ms, uint8_t ins
if (!already_added) { if (!already_added) {
success = add_topic(topics[i], interval_ms, instance); success = add_topic(topics[i], interval_ms, instance);
PX4_DEBUG("logging topic: %s(%d), interval: %i", topics[i]->o_name, instance, interval_ms); PX4_DEBUG("logging topic: %s(%" PRUu8 "), interval: %" PRUu16, topics[i]->o_name, instance, interval_ms);
break; break;
} }
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* *
* Copyright (c) 2016 PX4 Development Team. All rights reserved. * Copyright (c) 2016, 2021 PX4 Development Team. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -1121,7 +1121,7 @@ int Logger::create_log_dir(LogType type, tm *tt, char *log_dir, int log_dir_len)
/* look for the next dir that does not exist */ /* look for the next dir that does not exist */
while (!file_name.has_log_dir) { while (!file_name.has_log_dir) {
/* format log dir: e.g. /fs/microsd/log/sess001 */ /* format log dir: e.g. /fs/microsd/log/sess001 */
int n2 = snprintf(file_name.log_dir, sizeof(LogFileName::log_dir), "sess%03u", dir_number); int n2 = snprintf(file_name.log_dir, sizeof(LogFileName::log_dir), "sess%03" PRIu16, dir_number);
if (n2 >= (int)sizeof(LogFileName::log_dir)) { if (n2 >= (int)sizeof(LogFileName::log_dir)) {
PX4_ERR("log path too long (%i)", n); PX4_ERR("log path too long (%i)", n);
@@ -1192,7 +1192,7 @@ int Logger::get_log_file_name(LogType type, char *file_name, size_t file_name_si
/* look for the next file that does not exist */ /* look for the next file that does not exist */
while (file_number <= MAX_NO_LOGFILE) { while (file_number <= MAX_NO_LOGFILE) {
/* format log file path: e.g. /fs/microsd/log/sess001/log001.ulg */ /* format log file path: e.g. /fs/microsd/log/sess001/log001.ulg */
snprintf(log_file_name, sizeof(LogFileName::log_file_name), "log%03u%s.ulg", file_number, replay_suffix); snprintf(log_file_name, sizeof(LogFileName::log_file_name), "log%03" PRIu16 "%s.ulg", file_number, replay_suffix);
snprintf(file_name + n, file_name_size - n, "/%s", log_file_name); snprintf(file_name + n, file_name_size - n, "/%s", log_file_name);
if (!util::file_exist(file_name)) { if (!util::file_exist(file_name)) {
@@ -1682,7 +1682,7 @@ void Logger::write_info_multiple(LogType type, const char *name, const char *val
write_message(type, buffer, msg_size); write_message(type, buffer, msg_size);
} else { } else {
PX4_ERR("info_multiple str too long (%i), key=%s", msg.key_len, msg.key); PX4_ERR("info_multiple str too long (%" PRIu8 "), key=%s", msg.key_len, msg.key);
} }
_writer.unlock(); _writer.unlock();
@@ -1809,7 +1809,7 @@ void Logger::write_version(LogType type)
// data versioning: increase this on every larger data change (format/semantic) // data versioning: increase this on every larger data change (format/semantic)
// 1: switch to FIFO drivers (disabled on-chip DLPF) // 1: switch to FIFO drivers (disabled on-chip DLPF)
write_info(type, "ver_data_format", 1); write_info(type, "ver_data_format", static_cast<uint32_t>(1));
#ifndef BOARD_HAS_NO_UUID #ifndef BOARD_HAS_NO_UUID