缩小变量作用域:消除18处variableScope,声明移入实际使用块
This commit is contained in:
@@ -585,13 +585,13 @@ int gd5f2gq5ue_read_id(uint8_t *p_mid, uint8_t *p_did) {
|
||||
* 函数说明:自动处理跨页读取;offset+size 越界返回错误
|
||||
*/
|
||||
int gd5f2gq5ue_read(long offset, uint8_t *p_buf, size_t size) {
|
||||
int ret;
|
||||
|
||||
if (offset < 0 || (uint32_t)offset + (uint32_t)size > GD5F_TOTAL_SIZE) {
|
||||
return GD5F_ERROR;
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
int ret;
|
||||
uint32_t page_addr = offset / GD5F_PAGE_SIZE;
|
||||
uint16_t column = offset % GD5F_PAGE_SIZE;
|
||||
size_t bytes = GD5F_PAGE_SIZE - column;
|
||||
@@ -628,13 +628,13 @@ int gd5f2gq5ue_read(long offset, uint8_t *p_buf, size_t size) {
|
||||
* 函数说明:自动处理跨页写入;offset+size 越界返回错误
|
||||
*/
|
||||
int gd5f2gq5ue_write(long offset, const uint8_t *p_buf, size_t size) {
|
||||
int ret;
|
||||
|
||||
if (offset < 0 || (uint32_t)offset + (uint32_t)size > GD5F_TOTAL_SIZE) {
|
||||
return GD5F_ERROR;
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
int ret;
|
||||
uint32_t page_addr = offset / GD5F_PAGE_SIZE;
|
||||
uint16_t column = offset % GD5F_PAGE_SIZE;
|
||||
size_t bytes = GD5F_PAGE_SIZE - column;
|
||||
@@ -665,7 +665,6 @@ int gd5f2gq5ue_write(long offset, const uint8_t *p_buf, size_t size) {
|
||||
* 函数说明:循环擦除 [offset, offset+size) 覆盖的每个块,偏移/长度不对齐返回错误
|
||||
*/
|
||||
int gd5f2gq5ue_erase(long offset, size_t size) {
|
||||
int ret;
|
||||
|
||||
if (offset % GD5F_BLOCK_SIZE != 0) {
|
||||
return GD5F_ERROR;
|
||||
@@ -675,6 +674,7 @@ int gd5f2gq5ue_erase(long offset, size_t size) {
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
int ret;
|
||||
uint32_t block_addr = offset / GD5F_BLOCK_SIZE;
|
||||
|
||||
ret = gd5f_block_erase(block_addr);
|
||||
|
||||
Reference in New Issue
Block a user