diff options
author | Leo C | 2018-07-27 08:43:02 +0200 |
---|---|---|
committer | Leo C | 2018-07-27 08:43:02 +0200 |
commit | b0a9d14ceee5b6d4e6e27bb6982497c70cd12aeb (patch) | |
tree | ae586c561169cdbb8286435c687736ec04b23ee2 /avr | |
parent | 8b2c7c224f3ff45c5404501034bdc2e01612eef0 (diff) | |
download | z180-stamp-b0a9d14ceee5b6d4e6e27bb6982497c70cd12aeb.zip |
ENV_SIZE
Diffstat (limited to 'avr')
-rw-r--r-- | avr/env.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -18,13 +18,6 @@ debug_cond(DEBUG_ENV, fmt, ##args) -#define ENV_SIZE (CONFIG_ENV_SIZE - sizeof(uint16_t) -1) -#define ACTIVE_FLAG 1 -#define OBSOLETE_FLAG 0 - -#define ENVLIST_DELETE (1<<0) - - /* * Default Environment */ @@ -44,10 +37,17 @@ const FLASH char default_env[] = { }; +#define ENV_SIZE (CONFIG_ENV_SIZE - sizeof(uint16_t) - sizeof(uint8_t)) + +#define ENVLIST_DELETE (1<<0) + + /* EEPROM storage */ typedef struct environment_s { uint16_t crc; /* CRC16 over data bytes */ uint8_t flags; /* active/obsolete flags */ +#define ACTIVE_FLAG 1 +#define OBSOLETE_FLAG 0 char data[ENV_SIZE]; /* Environment data */ } env_t; @@ -139,7 +139,7 @@ static char *env_item_insert_name(char *pos, const char *name, int len) while (*end++ != 0) while (*end++ != 0); - if (end > env_list + ENV_SIZE) + if (end + len >= env_list + ENV_SIZE) return NULL; memmove(dstp, pos, end - pos); @@ -714,7 +714,7 @@ command_ret_t do_env_print(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, return CMD_RET_FAILURE; if (mode == 0) printf_P(PSTR("\nEnvironment size: %d/%d bytes\n"), - size, ENV_SIZE); + size, ENV_SIZE - 1); return CMD_RET_SUCCESS; } |