mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix FDB_config and fwrite size check
This commit is contained in:
parent
be098b033c
commit
a6f9a6c893
@ -9,9 +9,12 @@
|
|||||||
* @brief configuration file
|
* @brief configuration file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _FDB_CFG_H_
|
#ifndef _FDB_CFG_H_
|
||||||
#define _FDB_CFG_H_
|
#define _FDB_CFG_H_
|
||||||
|
|
||||||
|
#include "PikaObj.h"
|
||||||
|
|
||||||
/* using KVDB feature */
|
/* using KVDB feature */
|
||||||
#define FDB_USING_KVDB
|
#define FDB_USING_KVDB
|
||||||
|
|
||||||
@ -33,8 +36,12 @@
|
|||||||
/* #define FDB_PRINT(...) my_printf(__VA_ARGS__) */
|
/* #define FDB_PRINT(...) my_printf(__VA_ARGS__) */
|
||||||
|
|
||||||
/* print debug information */
|
/* print debug information */
|
||||||
|
#ifndef PIKA_FDB_DEBUG_ENABLE
|
||||||
|
#define PIKA_FDB_DEBUG_ENABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PIKA_FDB_DEBUG_ENABLE
|
||||||
#define FDB_DEBUG_ENABLE
|
#define FDB_DEBUG_ENABLE
|
||||||
#define FDB_KV_CACHE_TABLE_SIZE 0
|
#endif
|
||||||
#define FDB_SECTOR_CACHE_TABLE_SIZE 0
|
|
||||||
|
|
||||||
#endif /* _FDB_CFG_H_ */
|
#endif /* _FDB_CFG_H_ */
|
||||||
|
@ -226,15 +226,15 @@ fdb_err_t _fdb_file_erase(fdb_db_t db, uint32_t addr, size_t size) {
|
|||||||
pika_platform_fseek(fp, 0, SEEK_SET);
|
pika_platform_fseek(fp, 0, SEEK_SET);
|
||||||
for (i = 0; i * BUF_SIZE < size; i++) {
|
for (i = 0; i * BUF_SIZE < size; i++) {
|
||||||
memset(buf, 0xFF, BUF_SIZE);
|
memset(buf, 0xFF, BUF_SIZE);
|
||||||
size_t sizew = pika_platform_fwrite(buf, BUF_SIZE, 1, fp);
|
size_t sizew = pika_platform_fwrite(buf, 1, BUF_SIZE, fp);
|
||||||
if (sizew != 1) {
|
if (sizew != BUF_SIZE) {
|
||||||
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
||||||
result = FDB_WRITE_ERR;
|
result = FDB_WRITE_ERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(buf, 0xFF, BUF_SIZE);
|
memset(buf, 0xFF, BUF_SIZE);
|
||||||
size_t sizew = pika_platform_fwrite(buf, size - i * BUF_SIZE, 1, fp);
|
size_t sizew = pika_platform_fwrite(buf, 1, size - i * BUF_SIZE, fp);
|
||||||
if (sizew != size - i * BUF_SIZE) {
|
if (sizew != size - i * BUF_SIZE) {
|
||||||
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
||||||
result = FDB_WRITE_ERR;
|
result = FDB_WRITE_ERR;
|
||||||
|
@ -9,9 +9,12 @@
|
|||||||
* @brief configuration file
|
* @brief configuration file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _FDB_CFG_H_
|
#ifndef _FDB_CFG_H_
|
||||||
#define _FDB_CFG_H_
|
#define _FDB_CFG_H_
|
||||||
|
|
||||||
|
#include "PikaObj.h"
|
||||||
|
|
||||||
/* using KVDB feature */
|
/* using KVDB feature */
|
||||||
#define FDB_USING_KVDB
|
#define FDB_USING_KVDB
|
||||||
|
|
||||||
@ -33,8 +36,12 @@
|
|||||||
/* #define FDB_PRINT(...) my_printf(__VA_ARGS__) */
|
/* #define FDB_PRINT(...) my_printf(__VA_ARGS__) */
|
||||||
|
|
||||||
/* print debug information */
|
/* print debug information */
|
||||||
|
#ifndef PIKA_FDB_DEBUG_ENABLE
|
||||||
|
#define PIKA_FDB_DEBUG_ENABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PIKA_FDB_DEBUG_ENABLE
|
||||||
#define FDB_DEBUG_ENABLE
|
#define FDB_DEBUG_ENABLE
|
||||||
#define FDB_KV_CACHE_TABLE_SIZE 0
|
#endif
|
||||||
#define FDB_SECTOR_CACHE_TABLE_SIZE 0
|
|
||||||
|
|
||||||
#endif /* _FDB_CFG_H_ */
|
#endif /* _FDB_CFG_H_ */
|
||||||
|
@ -226,15 +226,15 @@ fdb_err_t _fdb_file_erase(fdb_db_t db, uint32_t addr, size_t size) {
|
|||||||
pika_platform_fseek(fp, 0, SEEK_SET);
|
pika_platform_fseek(fp, 0, SEEK_SET);
|
||||||
for (i = 0; i * BUF_SIZE < size; i++) {
|
for (i = 0; i * BUF_SIZE < size; i++) {
|
||||||
memset(buf, 0xFF, BUF_SIZE);
|
memset(buf, 0xFF, BUF_SIZE);
|
||||||
size_t sizew = pika_platform_fwrite(buf, BUF_SIZE, 1, fp);
|
size_t sizew = pika_platform_fwrite(buf, 1, BUF_SIZE, fp);
|
||||||
if (sizew != 1) {
|
if (sizew != BUF_SIZE) {
|
||||||
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
||||||
result = FDB_WRITE_ERR;
|
result = FDB_WRITE_ERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(buf, 0xFF, BUF_SIZE);
|
memset(buf, 0xFF, BUF_SIZE);
|
||||||
size_t sizew = pika_platform_fwrite(buf, size - i * BUF_SIZE, 1, fp);
|
size_t sizew = pika_platform_fwrite(buf, 1, size - i * BUF_SIZE, fp);
|
||||||
if (sizew != size - i * BUF_SIZE) {
|
if (sizew != size - i * BUF_SIZE) {
|
||||||
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
FDB_PRINT("Error: write (%s) file failed.\n", db->name);
|
||||||
result = FDB_WRITE_ERR;
|
result = FDB_WRITE_ERR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user