summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2018-07-27 08:43:02 +0200
committerLeo C2018-07-27 08:43:02 +0200
commitb0a9d14ceee5b6d4e6e27bb6982497c70cd12aeb (patch)
treeae586c561169cdbb8286435c687736ec04b23ee2
parent8b2c7c224f3ff45c5404501034bdc2e01612eef0 (diff)
downloadz180-stamp-b0a9d14ceee5b6d4e6e27bb6982497c70cd12aeb.zip
ENV_SIZE
-rw-r--r--avr/env.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/avr/env.c b/avr/env.c
index 6bbd99c..44c5742 100644
--- a/avr/env.c
+++ b/avr/env.c
@@ -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;
}