From 9580a42bffde32d234b71ce4f7275db635c7cc4f Mon Sep 17 00:00:00 2001 From: ryne3366 Date: Mon, 4 Aug 2025 11:58:49 +0800 Subject: [PATCH] Fix coding check issue Signed-off-by: ryne3366 --- BUILD.gn | 8 +++---- include/sqlite3sym.h | 24 +++++++++---------- patch/0001-History-features-on-OH.patch | 16 ++++++------- patch/0002-Enable-and-optimize-ICU.patch | 4 ++-- patch/0003-Busy-debug-and-log-dump.patch | 14 +++++------ patch/0004-Support-meta-recovery.patch | 2 +- ...ity-report-corruption-and-check-page.patch | 6 ++--- patch/0006-Support-Binlog.patch | 8 +++---- ...Allow-enable-checksum-through-PRAGMA.patch | 4 ++-- patch/0011-Support-compress-db.patch | 8 +++---- patch/0012-Bugfix-on-current-version.patch | 2 +- unittest/common.cpp | 4 ++-- unittest/common.h | 4 ++-- unittest/sqlite_cksum_test.cpp | 2 +- unittest/sqlite_compress_test.cpp | 2 +- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 0ba59f3..c3afd56 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -45,7 +45,7 @@ ohos_shared_library("sqliteicu") { "NDEBUG=1", "SQLITE_EXPORT_SYMBOLS", "SQLITE_ENABLE_FTS3", - "HARMONY_OS", + "OS_FEATURE", "SQLITE_ENABLE_ICU", ] cflags_c = [ @@ -90,7 +90,7 @@ ohos_shared_library("sqlitecompressvfs") { "NDEBUG=1", "SQLITE_EXPORT_SYMBOLS", "SQLITE_ENABLE_PAGE_COMPRESS", - "HARMONY_OS", + "OS_FEATURE", ] cflags_c = [ "-fvisibility=hidden", @@ -162,7 +162,7 @@ ohos_shared_library("sqlite") { "OPENSSL_SUPPRESS_DEPRECATED", "LOG_DUMP", "FDSAN_ENABLE", - "HARMONY_OS", + "OS_FEATURE", "SQLITE_HDR_CHECK", "SQLITE_ENABLE_ICU", "SQLITE_META_DWR", @@ -247,7 +247,7 @@ ohos_executable("sqlite3") { "OPENSSL_SUPPRESS_DEPRECATED", "LOG_DUMP", "FDSAN_ENABLE", - "HARMONY_OS", + "OS_FEATURE", ] cflags = [ diff --git a/include/sqlite3sym.h b/include/sqlite3sym.h index b425756..0080aa1 100644 --- a/include/sqlite3sym.h +++ b/include/sqlite3sym.h @@ -49,7 +49,7 @@ typedef struct Sqlite3BinlogConfig { ** END OF BINLOG CONFIG *************************************************************************/ -struct sqlite3_api_routines_hw { +struct sqlite3_api_routines_extra { int (*initialize)(); int (*config)(int,...); int (*key)(sqlite3*,const void*,int); @@ -62,17 +62,17 @@ struct sqlite3_api_routines_hw { int (*compressdb_backup)(sqlite3*, const char*); }; -extern const struct sqlite3_api_routines_hw *sqlite3_export_hw_symbols; -#define sqlite3_initialize sqlite3_export_hw_symbols->initialize -#define sqlite3_config sqlite3_export_hw_symbols->config -#define sqlite3_key sqlite3_export_hw_symbols->key -#define sqlite3_key_v2 sqlite3_export_hw_symbols->key_v2 -#define sqlite3_rekey sqlite3_export_hw_symbols->rekey -#define sqlite3_rekey_v2 sqlite3_export_hw_symbols->rekey_v2 -#define sqlite3_is_support_binlog sqlite3_export_hw_symbols->is_support_binlog -#define sqlite3_replay_binlog sqlite3_export_hw_symbols->replay_binlog -#define sqlite3_clean_binlog sqlite3_export_hw_symbols->clean_binlog -#define sqlite3_compressdb_backup sqlite3_export_hw_symbols->compressdb_backup +extern const struct sqlite3_api_routines_extra *sqlite3_export_extra_symbols; +#define sqlite3_initialize sqlite3_export_extra_symbols->initialize +#define sqlite3_config sqlite3_export_extra_symbols->config +#define sqlite3_key sqlite3_export_extra_symbols->key +#define sqlite3_key_v2 sqlite3_export_extra_symbols->key_v2 +#define sqlite3_rekey sqlite3_export_extra_symbols->rekey +#define sqlite3_rekey_v2 sqlite3_export_extra_symbols->rekey_v2 +#define sqlite3_is_support_binlog sqlite3_export_extra_symbols->is_support_binlog +#define sqlite3_replay_binlog sqlite3_export_extra_symbols->replay_binlog +#define sqlite3_clean_binlog sqlite3_export_extra_symbols->clean_binlog +#define sqlite3_compressdb_backup sqlite3_export_extra_symbols->compressdb_backup struct sqlite3_api_routines_cksumvfs { int (*register_cksumvfs)(const char *); diff --git a/patch/0001-History-features-on-OH.patch b/patch/0001-History-features-on-OH.patch index 7e7236c..9b09c15 100644 --- a/patch/0001-History-features-on-OH.patch +++ b/patch/0001-History-features-on-OH.patch @@ -1,7 +1,7 @@ From 243b21cbaa3d360fbdfb91ea3e18398125129167 Mon Sep 17 00:00:00 2001 From: MartinChoo <214582617@qq.com> Date: Wed, 23 Jul 2025 17:38:02 +0800 -Subject: [PATCH 01/12] History features on OH +Subject: [PATCH 01/12] History features of sqlite --- src/sqlite3.c | 2451 ++++++++++++++++++++++++++++++++++++++++++++++++- @@ -27,7 +27,7 @@ index 730b247..b132937 100644 ); SQLITE_API void sqlite3_free_table(char **result); -+// hw export the symbols ++// export the symbols +#ifdef SQLITE_EXPORT_SYMBOLS +#if defined(__GNUC__) +# define EXPORT_SYMBOLS __attribute__ ((visibility ("default"))) @@ -2999,9 +2999,9 @@ index 730b247..b132937 100644 +/************** End file hw_codec.c *****************************************/ +#endif + -+// hw export the symbols ++// export the symbols +#ifdef SQLITE_EXPORT_SYMBOLS -+struct sqlite3_api_routines_hw { ++struct sqlite3_api_routines_extra { + int (*initialize)(); + int (*config)(int,...); + int (*key)(sqlite3*,const void*,int); @@ -3010,8 +3010,8 @@ index 730b247..b132937 100644 + int (*rekey_v2)(sqlite3*,const char*,const void*,int); +}; + -+typedef struct sqlite3_api_routines_hw sqlite3_api_routines_hw; -+static const sqlite3_api_routines_hw sqlite3HwApis = { ++typedef struct sqlite3_api_routines_extra sqlite3_api_routines_extra; ++static const sqlite3_api_routines_extra sqlite3HwApis = { + sqlite3_initialize, + sqlite3_config, +#ifdef SQLITE_HAS_CODEC @@ -3028,8 +3028,8 @@ index 730b247..b132937 100644 +}; + +EXPORT_SYMBOLS const sqlite3_api_routines *sqlite3_export_symbols = &sqlite3Apis; -+EXPORT_SYMBOLS const sqlite3_api_routines_hw *sqlite3_export_hw_symbols = &sqlite3HwApis; -+/************** End hw export the symbols *****************************************/ ++EXPORT_SYMBOLS const sqlite3_api_routines_extra *sqlite3_export_extra_symbols = &sqlite3HwApis; ++/************** End export the symbols *****************************************/ +#endif /* SQLITE_EXPORT_SYMBOLS */ -- 2.47.0.windows.2 diff --git a/patch/0002-Enable-and-optimize-ICU.patch b/patch/0002-Enable-and-optimize-ICU.patch index ecc3699..f20dd46 100644 --- a/patch/0002-Enable-and-optimize-ICU.patch +++ b/patch/0002-Enable-and-optimize-ICU.patch @@ -1225,7 +1225,7 @@ index 0000000..b5944d5 +/* #include "sqlite3.h" */ +#endif + -+// hw export the symbols ++// export the symbols +#ifdef SQLITE_EXPORT_SYMBOLS +#if defined(__GNUC__) +# define EXPORT_SYMBOLS __attribute__ ((visibility ("default"))) @@ -1716,7 +1716,7 @@ index 0000000..b5944d5 + {"like", 3, SQLITE_UTF8|SQLITEICU_EXTRAFLAGS, 0, icuLikeFunc}, +#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */ + }; -+#ifdef HARMONY_OS ++#ifdef OS_FEATURE + extern void SetOhosIcuDirectory(); + SetOhosIcuDirectory(); +#endif diff --git a/patch/0003-Busy-debug-and-log-dump.patch b/patch/0003-Busy-debug-and-log-dump.patch index d918ed8..4d2d521 100644 --- a/patch/0003-Busy-debug-and-log-dump.patch +++ b/patch/0003-Busy-debug-and-log-dump.patch @@ -92,7 +92,7 @@ index efc4cd4..6f423a9 100644 #define F2FS_FEATURE_ATOMIC_WRITE 0x0004 #endif /* __linux__ */ -+#ifdef HARMONY_OS ++#ifdef OS_FEATURE +#define HMFS_MONITOR_FL 0x00000002 +#define HMFS_IOCTL_HW_GET_FLAGS _IOR(0xf5, 70, unsigned int) +#define HMFS_IOCTL_HW_SET_FLAGS _IOR(0xf5, 71, unsigned int) @@ -114,7 +114,7 @@ index efc4cd4..6f423a9 100644 + } +} + -+#endif /* HARMONY_OS */ ++#endif /* OS_FEATURE */ /* ** Different Unix systems declare open() in different ways. Same use @@ -129,11 +129,11 @@ index efc4cd4..6f423a9 100644 + fdsan_exchange_owner_tag(fd, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, SQLITE_FDSAN_TAG)); + } +#endif /* FDSAN_ENABLE */ -+#ifdef HARMONY_OS ++#ifdef OS_FEATURE + if( fd >= 0 ){ + enableDbFileDelMonitor(fd); + } -+#endif /* HARMONY_OS */ ++#endif /* OS_FEATURE */ + return fd; +} + @@ -506,7 +506,7 @@ index efc4cd4..6f423a9 100644 return SQLITE_OK; } -+#ifdef HARMONY_OS ++#ifdef OS_FEATURE +/* +** If the last component of the pathname in z[0]..z[j-1] is something +** other than ".." then back it out and return true. If the last @@ -1409,9 +1409,9 @@ index efc4cd4..6f423a9 100644 +} +#endif + - // hw export the symbols + // export the symbols #ifdef SQLITE_EXPORT_SYMBOLS - struct sqlite3_api_routines_hw { + struct sqlite3_api_routines_extra { -- 2.47.0.windows.2 diff --git a/patch/0004-Support-meta-recovery.patch b/patch/0004-Support-meta-recovery.patch index ab027f8..ffcc266 100644 --- a/patch/0004-Support-meta-recovery.patch +++ b/patch/0004-Support-meta-recovery.patch @@ -775,7 +775,7 @@ index 6f423a9..dc09c3c 100644 + if (!exists && !openCreate) { + return SQLITE_PERM; + } -+#ifdef HARMONY_OS ++#ifdef OS_FEATURE + // check if the path have enough permission + rc = osAccess(metaPath, W_OK|R_OK); + if (rc == 0 || errno == ENOENT) { diff --git a/patch/0005-Enhance-dfx-ability-report-corruption-and-check-page.patch b/patch/0005-Enhance-dfx-ability-report-corruption-and-check-page.patch index 6fd4d35..cdc79d1 100644 --- a/patch/0005-Enhance-dfx-ability-report-corruption-and-check-page.patch +++ b/patch/0005-Enhance-dfx-ability-report-corruption-and-check-page.patch @@ -186,7 +186,7 @@ index 0000000..6f4c55c +#include +#include + -+// hw export the symbols ++// export the symbols +#ifdef SQLITE_EXPORT_SYMBOLS +#if defined(__GNUC__) +# define EXPORT_SYMBOLS __attribute__ ((visibility ("default"))) @@ -2383,7 +2383,7 @@ index dc09c3c..e7e8b3c 100644 @@ -256317,6 +256915,26 @@ static void walLogCheckpointInfo(Wal *pWal, sqlite3 *db, sqlite3_int64 startTime - // hw export the symbols + // export the symbols #ifdef SQLITE_EXPORT_SYMBOLS +#ifndef SQLITE_CKSUMVFS_STATIC +int sqlite3_register_cksumvfs(const char *NotUsed){ @@ -2405,7 +2405,7 @@ index dc09c3c..e7e8b3c 100644 + +EXPORT_SYMBOLS const sqlite3_api_routines_cksumvfs *sqlite3_export_cksumvfs_symbols = &sqlite3CksumvfsApis; +#endif - struct sqlite3_api_routines_hw { + struct sqlite3_api_routines_extra { int (*initialize)(); int (*config)(int,...); -- diff --git a/patch/0006-Support-Binlog.patch b/patch/0006-Support-Binlog.patch index 9bf8b39..e7ffebe 100644 --- a/patch/0006-Support-Binlog.patch +++ b/patch/0006-Support-Binlog.patch @@ -1752,10 +1752,10 @@ index e7e8b3c..3f1195a 100644 +/************** End of binlog implement ************************************/ +#endif /* SQLITE_ENABLE_BINLOG */ + - // hw export the symbols + // export the symbols #ifdef SQLITE_EXPORT_SYMBOLS #ifndef SQLITE_CKSUMVFS_STATIC -@@ -256942,6 +258420,9 @@ struct sqlite3_api_routines_hw { +@@ -256942,6 +258420,9 @@ struct sqlite3_api_routines_extra { int (*key_v2)(sqlite3*,const char*,const void*,int); int (*rekey)(sqlite3*,const void*,int); int (*rekey_v2)(sqlite3*,const char*,const void*,int); @@ -1764,8 +1764,8 @@ index e7e8b3c..3f1195a 100644 + int (*clean_binlog)(sqlite3*, BinlogFileCleanModeE); }; - typedef struct sqlite3_api_routines_hw sqlite3_api_routines_hw; -@@ -256952,13 +258433,22 @@ static const sqlite3_api_routines_hw sqlite3HwApis = { + typedef struct sqlite3_api_routines_extra sqlite3_api_routines_extra; +@@ -256952,13 +258433,22 @@ static const sqlite3_api_routines_extra sqlite3HwApis = { sqlite3_key, sqlite3_key_v2, sqlite3_rekey, diff --git a/patch/0009-Allow-enable-checksum-through-PRAGMA.patch b/patch/0009-Allow-enable-checksum-through-PRAGMA.patch index 332346a..3076fb3 100644 --- a/patch/0009-Allow-enable-checksum-through-PRAGMA.patch +++ b/patch/0009-Allow-enable-checksum-through-PRAGMA.patch @@ -597,7 +597,7 @@ index 4c538a1..c84348b 100644 sqlite3_log(SQLITE_WARNING_DUMP, "Meta double write disabled, sysno %d", errno); } -#endif -+#endif /* HARMONY_OS */ ++#endif /* OS_FEATURE */ return rc; } @@ -731,7 +731,7 @@ index 4c538a1..c84348b 100644 -#endif +#endif /* SQLITE_CKSUMVFS_STATIC */ + - struct sqlite3_api_routines_hw { + struct sqlite3_api_routines_extra { int (*initialize)(); int (*config)(int,...); -- diff --git a/patch/0011-Support-compress-db.patch b/patch/0011-Support-compress-db.patch index 1301746..c16336e 100644 --- a/patch/0011-Support-compress-db.patch +++ b/patch/0011-Support-compress-db.patch @@ -112,7 +112,7 @@ index 0000000..90a3f44 +#include +#endif + -+// hw export the symbols ++// export the symbols +#ifdef SQLITE_EXPORT_SYMBOLS +#if defined(__GNUC__) +# define EXPORT_SYMBOLS __attribute__ ((visibility ("default"))) @@ -2071,7 +2071,7 @@ index c84348b..1abddb3 100644 return; } #ifndef SQLITE_OMIT_WAL -@@ -258615,6 +259042,11 @@ struct sqlite3_api_routines_hw { +@@ -258615,6 +259042,11 @@ struct sqlite3_api_routines_extra { int (*is_support_binlog)(void); int (*replay_binlog)(sqlite3*, sqlite3*); int (*clean_binlog)(sqlite3*, BinlogFileCleanModeE); @@ -2082,8 +2082,8 @@ index c84348b..1abddb3 100644 +#endif /* SQLITE_ENABLE_PAGE_COMPRESS */ }; - typedef struct sqlite3_api_routines_hw sqlite3_api_routines_hw; -@@ -258641,6 +259073,11 @@ static const sqlite3_api_routines_hw sqlite3HwApis = { + typedef struct sqlite3_api_routines_extra sqlite3_api_routines_extra; +@@ -258641,6 +259073,11 @@ static const sqlite3_api_routines_extra sqlite3HwApis = { 0, 0, #endif/* SQLITE_ENABLE_BINLOG */ diff --git a/patch/0012-Bugfix-on-current-version.patch b/patch/0012-Bugfix-on-current-version.patch index 228a01e..c722412 100644 --- a/patch/0012-Bugfix-on-current-version.patch +++ b/patch/0012-Bugfix-on-current-version.patch @@ -598,7 +598,7 @@ index 2953517..1e8fc0f 100644 sqlite3_log(SQLITE_ERROR, "[SQLite]Get wal file lock ofs %u failed, errno: %d", lock->l_start, errno); return 0; } -@@ -259039,9 +259220,13 @@ struct sqlite3_api_routines_hw { +@@ -259039,9 +259220,13 @@ struct sqlite3_api_routines_extra { int (*key_v2)(sqlite3*,const char*,const void*,int); int (*rekey)(sqlite3*,const void*,int); int (*rekey_v2)(sqlite3*,const char*,const void*,int); diff --git a/unittest/common.cpp b/unittest/common.cpp index c8ac153..1810db4 100644 --- a/unittest/common.cpp +++ b/unittest/common.cpp @@ -26,7 +26,7 @@ using namespace std; -namespace OHOS { +namespace UnitTest { namespace SQLiteTest { int Common::RemoveDir(const char *dir) { @@ -98,4 +98,4 @@ bool Common::IsFileExist(const char *fullPath) } } // namespace SQLiteTest -} // namespace OHOS \ No newline at end of file +} // namespace UnitTest \ No newline at end of file diff --git a/unittest/common.h b/unittest/common.h index 3468644..5eb0ff8 100644 --- a/unittest/common.h +++ b/unittest/common.h @@ -15,7 +15,7 @@ #ifndef COMMON_H #define COMMON_H -namespace OHOS { +namespace UnitTest { namespace SQLiteTest { #define TEST_STATUS_OK 0 @@ -28,6 +28,6 @@ public: static bool IsFileExist(const char *fullPath); }; } // namespace SQLiteTest -} // namespace OHOS +} // namespace UnitTest #endif /* COMMON_H */ diff --git a/unittest/sqlite_cksum_test.cpp b/unittest/sqlite_cksum_test.cpp index 4012dcf..fe066e4 100644 --- a/unittest/sqlite_cksum_test.cpp +++ b/unittest/sqlite_cksum_test.cpp @@ -29,7 +29,7 @@ #include "sqlite3sym.h" using namespace testing::ext; -using namespace OHOS::SQLiteTest; +using namespace UnitTest::SQLiteTest; #define TEST_DIR "./sqlitecksumtest" #define TEST_DB (TEST_DIR "/test.db") diff --git a/unittest/sqlite_compress_test.cpp b/unittest/sqlite_compress_test.cpp index 338a684..5d715bc 100644 --- a/unittest/sqlite_compress_test.cpp +++ b/unittest/sqlite_compress_test.cpp @@ -29,7 +29,7 @@ #include "sqlite3sym.h" using namespace testing::ext; -using namespace OHOS::SQLiteTest; +using namespace UnitTest::SQLiteTest; #define TEST_DIR "./sqlitecompresstest" #define TEST_DB (TEST_DIR "/test.db") -- Gitee