Added some safeguards to avoid issues related to data struct sizes
This commit is contained in:
@@ -19,8 +19,9 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DATACONSTANTS_H_
|
#if defined(_DATACONSTANTS_H_)
|
||||||
#define _DATACONSTANTS_H_
|
#error "This file MUST NOT be included side-by-side with dataconstants.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <storage/yaml/yaml_defs.h>
|
#include <storage/yaml/yaml_defs.h>
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
@@ -1046,5 +1047,3 @@ enum CalibrationState {
|
|||||||
CALIB_STORE,
|
CALIB_STORE,
|
||||||
CALIB_FINISHED
|
CALIB_FINISHED
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _DATACONSTANTS_H_
|
|
||||||
|
|||||||
@@ -19,9 +19,6 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// No include guards here, this file may be included many times in different namespaces
|
|
||||||
// i.e. BACKUP RAM Backup/Restore functions
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|||||||
@@ -19,11 +19,10 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MYEEPROM_H_
|
#if defined(_MYEEPROM_H_)
|
||||||
#define _MYEEPROM_H_
|
#error "This file MUST NOT be included side-by-side with myeeprom.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// #include "datastructs.h"
|
|
||||||
// #include "libopenui/src/bitfield.h"
|
|
||||||
|
|
||||||
#if defined(SDCARD_YAML)
|
#if defined(SDCARD_YAML)
|
||||||
#define EEPROM_VER 221
|
#define EEPROM_VER 221
|
||||||
@@ -278,5 +277,3 @@ PACK(union u_int8int16_t {
|
|||||||
|
|
||||||
constexpr uint8_t EE_GENERAL = 0x01;
|
constexpr uint8_t EE_GENERAL = 0x01;
|
||||||
constexpr uint8_t EE_MODEL = 0x02;
|
constexpr uint8_t EE_MODEL = 0x02;
|
||||||
|
|
||||||
#endif // _MYEEPROM_H_
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include "yaml_tree_walker.h"
|
#include "yaml_tree_walker.h"
|
||||||
|
|
||||||
// Use definitions from v220 conversions as long as nothing changes
|
// Use definitions from v220 conversions as long as nothing changes
|
||||||
#include "../conversions/datastructs_220.h"
|
|
||||||
|
|
||||||
namespace yaml_conv_220 {
|
namespace yaml_conv_220 {
|
||||||
bool in_write_weight(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque);
|
bool in_write_weight(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque);
|
||||||
@@ -58,12 +57,28 @@ namespace yaml_conv_220 {
|
|||||||
yaml_writer_func wf, void* opaque);
|
yaml_writer_func wf, void* opaque);
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(CustomFunctionData) == sizeof(bin_storage_220::CustomFunctionData),"");
|
//
|
||||||
static_assert(sizeof(ModuleData) == sizeof(bin_storage_220::ModuleData),"");
|
// WARNING:
|
||||||
static_assert(sizeof(FlightModeData) == sizeof(bin_storage_220::FlightModeData),"");
|
// ========
|
||||||
|
//
|
||||||
#if !defined(COLORLCD)
|
// If any of these static_assert() fails, you need to check that
|
||||||
static_assert(sizeof(TelemetryScreenData) == sizeof(bin_storage_220::TelemetryScreenData),"");
|
// the functions bellow are still applicable.
|
||||||
|
//
|
||||||
|
// Please note that the sizes used here are those from the v220 format
|
||||||
|
// (see storage/conversions/yaml/datastructs_220.h)
|
||||||
|
//
|
||||||
|
static_assert(sizeof(ModuleData) == 29,"");
|
||||||
|
#if defined(PCBHORUS) || defined(PCBNV14)
|
||||||
|
static_assert(sizeof(FlightModeData) == 44, "");
|
||||||
|
static_assert(sizeof(CustomFunctionData) == 9,"");
|
||||||
|
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE)
|
||||||
|
static_assert(sizeof(FlightModeData) == 36, "");
|
||||||
|
static_assert(sizeof(CustomFunctionData) == 11,"");
|
||||||
|
static_assert(sizeof(TelemetryScreenData) == 24, "");
|
||||||
|
#else
|
||||||
|
static_assert(sizeof(FlightModeData) == 40, "");
|
||||||
|
static_assert(sizeof(CustomFunctionData) == 11,"");
|
||||||
|
static_assert(sizeof(TelemetryScreenData) == 24, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GVAR_SMALL 128
|
#define GVAR_SMALL 128
|
||||||
|
|||||||
Reference in New Issue
Block a user