Skip to content

Commit

Permalink
flash vars - validate size in simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Feb 25, 2023
1 parent e2251b0 commit dbdd209
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hal/hal_flashVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct flash_vars_structure
// size 64
} FLASH_VARS_STRUCTURE;

#define MAGIC_FLASHVARS_SIZE 64

// call at startup
void HAL_FlashVars_IncreaseBootCount();
Expand Down
7 changes: 6 additions & 1 deletion src/win_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "driver\drv_public.h"
#include "cmnds\cmd_public.h"
#include "httpserver\new_http.h"
#include "hal\hal_flashVars.h"
#include "new_pins.h"
#include <timeapi.h>

Expand Down Expand Up @@ -193,7 +194,7 @@ int g_bDoingUnitTestsNow = 0;
#include "sim/sim_public.h"
int __cdecl main(int argc, char **argv)
{
bool bWantsUnitTests = 1;
bool bWantsUnitTests = 0;

if (argc > 1) {
int value;
Expand Down Expand Up @@ -244,6 +245,10 @@ int __cdecl main(int argc, char **argv)
printf("sizeof(long double) = %d\n", (int)sizeof(long double));
printf("sizeof(led_corr_t) = %d\n", (int)sizeof(led_corr_t));

if (sizeof(FLASH_VARS_STRUCTURE) != MAGIC_FLASHVARS_SIZE) {
printf("sizeof(FLASH_VARS_STRUCTURE) != MAGIC_FLASHVARS_SIZE!: %i\n", sizeof(FLASH_VARS_STRUCTURE));
system("pause");
}
if (sizeof(ledRemap_t) != MAGIC_LED_REMAP_SIZE) {
printf("sizeof(ledRemap_t) != MAGIC_LED_REMAP_SIZE!: %i\n", sizeof(ledRemap_t));
system("pause");
Expand Down

0 comments on commit dbdd209

Please sign in to comment.