logger coverity fix 143427

This commit is contained in:
Daniel Agar
2017-04-27 20:54:38 -04:00
committed by Nuno Marques
parent 91cda08081
commit 086ddf5078
2 changed files with 35 additions and 35 deletions
+12 -12
View File
@@ -1191,7 +1191,7 @@ bool Logger::file_exist(const char *filename)
int Logger::get_log_file_name(char *file_name, size_t file_name_size)
{
tm tt;
tm tt = {};
bool time_ok = false;
if (_log_name_timestamp) {
@@ -1280,7 +1280,7 @@ bool Logger::get_log_time(struct tm *tt, bool boot_time)
if (use_clock_time) {
/* take clock time if there's no fix (yet) */
struct timespec ts;
struct timespec ts = {};
px4_clock_gettime(CLOCK_REALTIME, &ts);
utc_time_sec = ts.tv_sec + (ts.tv_nsec / 1e9);
@@ -1417,7 +1417,7 @@ void Logger::perf_iterate_callback(perf_counter_t handle, void *user)
void Logger::write_perf_data(bool preflight)
{
perf_callback_data_t callback_data;
perf_callback_data_t callback_data = {};
callback_data.logger = this;
callback_data.counter = 0;
callback_data.preflight = preflight;
@@ -1463,7 +1463,7 @@ void Logger::initialize_load_output()
void Logger::write_load_output(bool preflight)
{
perf_callback_data_t callback_data;
perf_callback_data_t callback_data = {};
char buffer[140];
callback_data.logger = this;
callback_data.counter = 0;
@@ -1480,7 +1480,7 @@ void Logger::write_load_output(bool preflight)
void Logger::write_formats()
{
_writer.lock();
ulog_message_format_s msg;
ulog_message_format_s msg = {};
const orb_metadata **topics = orb_get_topics();
//write all known formats
@@ -1538,7 +1538,7 @@ void Logger::write_add_logged_msg(LoggerSubscription &subscription, int instance
void Logger::write_info(const char *name, const char *value)
{
_writer.lock();
ulog_message_info_header_s msg;
ulog_message_info_header_s msg = {};
uint8_t *buffer = reinterpret_cast<uint8_t *>(&msg);
msg.msg_type = static_cast<uint8_t>(ULogMessageType::INFO);
@@ -1601,7 +1601,7 @@ template<typename T>
void Logger::write_info_template(const char *name, T value, const char *type_str)
{
_writer.lock();
ulog_message_info_header_s msg;
ulog_message_info_header_s msg = {};
uint8_t *buffer = reinterpret_cast<uint8_t *>(&msg);
msg.msg_type = static_cast<uint8_t>(ULogMessageType::INFO);
@@ -1622,7 +1622,7 @@ void Logger::write_info_template(const char *name, T value, const char *type_str
void Logger::write_header()
{
ulog_file_header_s header;
ulog_file_header_s header = {};
header.magic[0] = 'U';
header.magic[1] = 'L';
header.magic[2] = 'o';
@@ -1711,7 +1711,7 @@ void Logger::write_version()
void Logger::write_parameters()
{
_writer.lock();
ulog_message_parameter_header_s msg;
ulog_message_parameter_header_s msg = {};
uint8_t *buffer = reinterpret_cast<uint8_t *>(&msg);
msg.msg_type = static_cast<uint8_t>(ULogMessageType::PARAMETER);
@@ -1768,7 +1768,7 @@ void Logger::write_parameters()
void Logger::write_changed_parameters()
{
_writer.lock();
ulog_message_parameter_header_s msg;
ulog_message_parameter_header_s msg = {};
uint8_t *buffer = reinterpret_cast<uint8_t *>(&msg);
msg.msg_type = static_cast<uint8_t>(ULogMessageType::PARAMETER);
@@ -2028,5 +2028,5 @@ void Logger::ack_vehicle_command(orb_advert_t &vehicle_command_ack_pub, vehicle_
}
}
}
} // namespace logger
} // namespace px4
+23 -23
View File
@@ -292,42 +292,42 @@ private:
static constexpr const char *LOG_ROOT = PX4_ROOTFSDIR"/fs/microsd/log";
#endif
uint8_t *_msg_buffer = nullptr;
int _msg_buffer_len = 0;
char _log_dir[LOG_DIR_LEN];
int _sess_dir_index = 1; ///< search starting index for 'sess<i>' directory name
uint8_t *_msg_buffer{nullptr};
int _msg_buffer_len{0};
char _log_dir[LOG_DIR_LEN] {};
int _sess_dir_index{1}; ///< search starting index for 'sess<i>' directory name
char _log_file_name[32];
bool _has_log_dir = false;
bool _was_armed = false;
bool _arm_override;
bool _has_log_dir{false};
bool _was_armed{false};
bool _arm_override{false};
// statistics
hrt_abstime _start_time_file; ///< Time when logging started, file backend (not the logger thread)
hrt_abstime _dropout_start = 0; ///< start of current dropout (0 = no dropout)
float _max_dropout_duration = 0.f; ///< max duration of dropout [s]
size_t _write_dropouts = 0; ///< failed buffer writes due to buffer overflow
size_t _high_water = 0; ///< maximum used write buffer
hrt_abstime _start_time_file{0}; ///< Time when logging started, file backend (not the logger thread)
hrt_abstime _dropout_start{0}; ///< start of current dropout (0 = no dropout)
float _max_dropout_duration{0.0f}; ///< max duration of dropout [s]
size_t _write_dropouts{0}; ///< failed buffer writes due to buffer overflow
size_t _high_water{0}; ///< maximum used write buffer
const bool _log_on_start;
const bool _log_until_shutdown;
const bool _log_name_timestamp;
Array<LoggerSubscription, MAX_TOPICS_NUM> _subscriptions;
LogWriter _writer;
uint32_t _log_interval;
const orb_metadata *_polling_topic_meta = nullptr; ///< if non-null, poll on this topic instead of sleeping
param_t _log_utc_offset;
param_t _log_dirs_max;
orb_advert_t _mavlink_log_pub = nullptr;
uint16_t _next_topic_id = 0; ///< id of next subscribed ulog topic
char *_replay_file_name = nullptr;
bool _should_stop_file_log = false; /**< if true _next_load_print is set and file logging
uint32_t _log_interval{0};
const orb_metadata *_polling_topic_meta{nullptr}; ///< if non-null, poll on this topic instead of sleeping
orb_advert_t _mavlink_log_pub{nullptr};
uint16_t _next_topic_id{0}; ///< id of next subscribed ulog topic
char *_replay_file_name{nullptr};
bool _should_stop_file_log{false}; /**< if true _next_load_print is set and file logging
will be stopped after load printing */
print_load_s _load; ///< process load data
hrt_abstime _next_load_print = 0; ///< timestamp when to print the process load
print_load_s _load{}; ///< process load data
hrt_abstime _next_load_print{0}; ///< timestamp when to print the process load
// control
param_t _sdlog_profile_handle;
param_t _sdlog_profile_handle{PARAM_INVALID};
param_t _log_utc_offset{PARAM_INVALID};
param_t _log_dirs_max{PARAM_INVALID};
};
} //namespace logger