1、【优化】ENV 大小获取函数,增加容错处理。

Signed-off-by: armink <armink.ztl@gmail.com>
pull/15/head
armink 8 years ago
parent 9dfc19cf3c
commit df7fecded4

@ -1,6 +1,6 @@
The MIT License (MIT) 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 Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyFlash Library. * This file is part of the EasyFlash Library.
* *
* 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 * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -67,7 +67,7 @@ if (!(EXPR)) \
while (1); \ while (1); \
} }
/* EasyFlash software version number */ /* EasyFlash software version number */
#define EF_SW_VERSION "3.0.3" #define EF_SW_VERSION "3.0.4"
typedef struct _ef_env{ typedef struct _ef_env{
char *key; char *key;

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyFlash Library. * This file is part of the EasyFlash Library.
* *
* Copyright (c) 2014-2016, 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 * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * 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 * @return size
*/ */
static size_t get_env_data_size(void) { static size_t get_env_data_size(void) {
if (get_env_end_addr() > get_env_data_addr()) {
return 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 * @return bytes
*/ */
static size_t get_env_user_used_size(void) { static size_t get_env_user_used_size(void) {
if (get_env_end_addr() > get_env_system_addr()) {
return get_env_end_addr() - get_env_system_addr(); return get_env_end_addr() - get_env_system_addr();
} else {
return 0;
}
} }
/** /**

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyFlash Library. * This file is part of the EasyFlash Library.
* *
* Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2018, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * 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 * @return size
*/ */
static size_t get_env_detail_size(void) { static size_t get_env_detail_size(void) {
if (get_env_detail_end_addr() > get_env_detail_addr()) {
return 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 */ /* must be initialized */
static size_t get_env_user_used_size(void) { static size_t get_env_user_used_size(void) {
if (get_env_detail_end_addr() > get_cur_using_data_addr()) {
return get_env_detail_end_addr() - get_cur_using_data_addr(); return get_env_detail_end_addr() - get_cur_using_data_addr();
} else {
return 0;
}
} }
/** /**

Loading…
Cancel
Save