From df7fecded4922075ac5408f3d6c11cd43d937ccc Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 1 Mar 2018 09:01:04 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91E?= =?UTF-8?q?NV=20=E5=A4=A7=E5=B0=8F=E8=8E=B7=E5=8F=96=E5=87=BD=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AE=B9=E9=94=99=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- LICENSE | 2 +- easyflash/inc/easyflash.h | 4 ++-- easyflash/src/ef_env.c | 14 +++++++++++--- easyflash/src/ef_env_wl.c | 14 +++++++++++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 9feba16..9b802d2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2017 Armink (armink.ztl@gmail.com) +Copyright (c) 2014-2018 Armink (armink.ztl@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/easyflash/inc/easyflash.h b/easyflash/inc/easyflash.h index 9848ff2..5a80585 100644 --- a/easyflash/inc/easyflash.h +++ b/easyflash/inc/easyflash.h @@ -1,7 +1,7 @@ /* * This file is part of the EasyFlash Library. * - * Copyright (c) 2014-2017, Armink, + * Copyright (c) 2014-2018, Armink, * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -67,7 +67,7 @@ if (!(EXPR)) \ while (1); \ } /* EasyFlash software version number */ -#define EF_SW_VERSION "3.0.3" +#define EF_SW_VERSION "3.0.4" typedef struct _ef_env{ char *key; diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index 1383471..7407dc9 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -1,7 +1,7 @@ /* * This file is part of the EasyFlash Library. * - * Copyright (c) 2014-2016, Armink, + * Copyright (c) 2014-2018, Armink, * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -246,7 +246,11 @@ static void set_env_end_addr(uint32_t end_addr) { * @return size */ static size_t get_env_data_size(void) { - return get_env_end_addr() - get_env_data_addr(); + if (get_env_end_addr() > get_env_data_addr()) { + return get_env_end_addr() - get_env_data_addr(); + } else { + return 0; + } } /** @@ -255,7 +259,11 @@ static size_t get_env_data_size(void) { * @return bytes */ static size_t get_env_user_used_size(void) { - return get_env_end_addr() - get_env_system_addr(); + if (get_env_end_addr() > get_env_system_addr()) { + return get_env_end_addr() - get_env_system_addr(); + } else { + return 0; + } } /** diff --git a/easyflash/src/ef_env_wl.c b/easyflash/src/ef_env_wl.c index 7e1e01e..219e1be 100644 --- a/easyflash/src/ef_env_wl.c +++ b/easyflash/src/ef_env_wl.c @@ -1,7 +1,7 @@ /* * This file is part of the EasyFlash Library. * - * Copyright (c) 2015-2017, Armink, + * Copyright (c) 2015-2018, Armink, * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -262,7 +262,11 @@ static void set_env_detail_end_addr(uint32_t end_addr) { * @return size */ static size_t get_env_detail_size(void) { - return get_env_detail_end_addr() - get_env_detail_addr(); + if (get_env_detail_end_addr() > get_env_detail_addr()) { + return get_env_detail_end_addr() - get_env_detail_addr(); + } else { + return 0; + } } /** @@ -274,7 +278,11 @@ static size_t get_env_detail_size(void) { */ /* must be initialized */ static size_t get_env_user_used_size(void) { - return get_env_detail_end_addr() - get_cur_using_data_addr(); + if (get_env_detail_end_addr() > get_cur_using_data_addr()) { + return get_env_detail_end_addr() - get_cur_using_data_addr(); + } else { + return 0; + } } /**