mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-30 20:48:33 -04:00
DataFlash: Change ::bufferspace_available return type
from 'uint16_t' to 'uint32_t' to avoid overflow (possible in at least two implementations: Block and File).
This commit is contained in:
parent
3f1896b9b7
commit
a91da2e803
@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
void set_mission(const AP_Mission *mission);
|
void set_mission(const AP_Mission *mission);
|
||||||
|
|
||||||
virtual uint16_t bufferspace_available() = 0;
|
virtual uint32_t bufferspace_available() = 0;
|
||||||
|
|
||||||
virtual uint16_t start_new_log(void) = 0;
|
virtual uint16_t start_new_log(void) = 0;
|
||||||
bool log_write_started;
|
bool log_write_started;
|
||||||
|
@ -12,7 +12,7 @@ extern AP_HAL::HAL& hal;
|
|||||||
// this if (and only if!) the low level format changes
|
// this if (and only if!) the low level format changes
|
||||||
#define DF_LOGGING_FORMAT 0x28122013
|
#define DF_LOGGING_FORMAT 0x28122013
|
||||||
|
|
||||||
uint16_t DataFlash_Block::bufferspace_available()
|
uint32_t DataFlash_Block::bufferspace_available()
|
||||||
{
|
{
|
||||||
// because DataFlash_Block devices are ring buffers, we *always*
|
// because DataFlash_Block devices are ring buffers, we *always*
|
||||||
// have room...
|
// have room...
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
void ShowDeviceInfo(AP_HAL::BetterStream *port);
|
void ShowDeviceInfo(AP_HAL::BetterStream *port);
|
||||||
void ListAvailableLogs(AP_HAL::BetterStream *port);
|
void ListAvailableLogs(AP_HAL::BetterStream *port);
|
||||||
|
|
||||||
uint16_t bufferspace_available();
|
uint32_t bufferspace_available();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PageHeader {
|
struct PageHeader {
|
||||||
|
@ -473,7 +473,7 @@ bool DataFlash_File::WritePrioritisedBlock(const void *pBuffer, uint16_t size, b
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t space = _writebuf.space();
|
uint32_t space = _writebuf.space();
|
||||||
|
|
||||||
if (_writing_startup_messages &&
|
if (_writing_startup_messages &&
|
||||||
_startup_messagewriter->fmt_done()) {
|
_startup_messagewriter->fmt_done()) {
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
/* Write a block of data at current offset */
|
/* Write a block of data at current offset */
|
||||||
bool WritePrioritisedBlock(const void *pBuffer, uint16_t size, bool is_critical);
|
bool WritePrioritisedBlock(const void *pBuffer, uint16_t size, bool is_critical);
|
||||||
uint16_t bufferspace_available();
|
uint32_t bufferspace_available();
|
||||||
|
|
||||||
// high level interface
|
// high level interface
|
||||||
uint16_t find_last_log() override;
|
uint16_t find_last_log() override;
|
||||||
@ -129,9 +129,9 @@ private:
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
uint16_t non_messagewriter_message_reserved_space() const {
|
uint32_t non_messagewriter_message_reserved_space() const {
|
||||||
// possibly make this a proportional to buffer size?
|
// possibly make this a proportional to buffer size?
|
||||||
uint16_t ret = 1024;
|
uint32_t ret = 1024;
|
||||||
if (ret >= _writebuf.get_size()) {
|
if (ret >= _writebuf.get_size()) {
|
||||||
// need to allow messages out from the messagewriters. In
|
// need to allow messages out from the messagewriters. In
|
||||||
// this case while you have a messagewriter you won't get
|
// this case while you have a messagewriter you won't get
|
||||||
|
@ -55,7 +55,7 @@ bool DataFlash_MAVLink::logging_failed() const
|
|||||||
return !_sending_to_client;
|
return !_sending_to_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t DataFlash_MAVLink::bufferspace_available() {
|
uint32_t DataFlash_MAVLink::bufferspace_available() {
|
||||||
return (_blockcount_free * 200 + remaining_space_in_current_block());
|
return (_blockcount_free * 200 + remaining_space_in_current_block());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ private:
|
|||||||
void Log_Write_DF_MAV(DataFlash_MAVLink &df);
|
void Log_Write_DF_MAV(DataFlash_MAVLink &df);
|
||||||
|
|
||||||
void internal_error();
|
void internal_error();
|
||||||
uint16_t bufferspace_available() override; // in bytes
|
uint32_t bufferspace_available() override; // in bytes
|
||||||
uint8_t remaining_space_in_current_block();
|
uint8_t remaining_space_in_current_block();
|
||||||
// write buffer
|
// write buffer
|
||||||
uint8_t _blockcount_free;
|
uint8_t _blockcount_free;
|
||||||
|
Loading…
Reference in New Issue
Block a user