diff --git a/libraries/AP_Logger/AP_Logger_File.cpp b/libraries/AP_Logger/AP_Logger_File.cpp index c379e5e6ad..e38ed3b304 100644 --- a/libraries/AP_Logger/AP_Logger_File.cpp +++ b/libraries/AP_Logger/AP_Logger_File.cpp @@ -29,10 +29,6 @@ extern const AP_HAL::HAL& hal; #define LOGGER_PAGE_SIZE 1024UL -#ifndef HAL_LOGGER_WRITE_CHUNK_SIZE -#define HAL_LOGGER_WRITE_CHUNK_SIZE 4096 -#endif - #define MB_to_B 1000000 #define B_to_MB 0.000001 @@ -46,11 +42,7 @@ AP_Logger_File::AP_Logger_File(AP_Logger &front, LoggerMessageWriter_DFLogStart *writer, const char *log_directory) : AP_Logger_Backend(front, writer), - _write_fd(-1), - _read_fd(-1), - _log_directory(log_directory), - _writebuf(0), - _writebuf_chunk(HAL_LOGGER_WRITE_CHUNK_SIZE) + _log_directory(log_directory) { df_stats_clear(); } diff --git a/libraries/AP_Logger/AP_Logger_File.h b/libraries/AP_Logger/AP_Logger_File.h index a16cf77ede..7c0696b082 100644 --- a/libraries/AP_Logger/AP_Logger_File.h +++ b/libraries/AP_Logger/AP_Logger_File.h @@ -13,6 +13,10 @@ #include #include "AP_Logger_Backend.h" +#ifndef HAL_LOGGER_WRITE_CHUNK_SIZE +#define HAL_LOGGER_WRITE_CHUNK_SIZE 4096 +#endif + class AP_Logger_File : public AP_Logger_Backend { public: @@ -59,14 +63,14 @@ protected: bool StartNewLogOK() const override; private: - int _write_fd; + int _write_fd = -1; char *_write_filename; uint32_t _last_write_ms; #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS bool _need_rtc_update; #endif - int _read_fd; + int _read_fd = -1; uint16_t _read_fd_log_num; uint32_t _read_offset; uint32_t _write_offset; @@ -92,8 +96,8 @@ private: bool log_exists(const uint16_t lognum) const; // write buffer - ByteBuffer _writebuf; - const uint16_t _writebuf_chunk; + ByteBuffer _writebuf{0}; + const uint16_t _writebuf_chunk = HAL_LOGGER_WRITE_CHUNK_SIZE; uint32_t _last_write_time; /* construct a file name given a log number. Caller must free. */