mirror of
https://gitee.com/openharmony/distributeddatamgr_relational_store
synced 2024-11-27 01:01:02 +00:00
回退 'Pull Request !1666 : 9.2 fix warning'
This commit is contained in:
parent
f41f60126b
commit
7df2cabc93
67
OAT.xml
67
OAT.xml
@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||
basedir: Root dir, the basedir + project path is the real source file location.
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
tasklist(only for batch mode):
|
||||
1. task: Define oat check thread, each task will start a new thread.
|
||||
2. task name: Only an name, no practical effect.
|
||||
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
|
||||
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
|
||||
5. task project: Projects to be checked, the path field define the source root dir of the project.
|
||||
|
||||
|
||||
policyList:
|
||||
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
|
||||
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == >
|
||||
& == >
|
||||
' == >
|
||||
< == >
|
||||
> == >
|
||||
-->
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile>LICENSE</licensefile>
|
||||
<filefilterlist>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filepath" name="figures/en-us_How_RDB_works.png"
|
||||
desc="self developed image"/>
|
||||
<filteritem type="filepath" name="figures/zh-cn_关系型数据库运作机制.png"
|
||||
desc="self developed image"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
@ -222,7 +222,7 @@ namespace Relational {
|
||||
for (size_t i = 0; i < devices.size(); i++) {
|
||||
cArrStr.head[i] = MallocCString(devices[i]);
|
||||
}
|
||||
cArrStr.size = static_cast<int>(devices.size());
|
||||
cArrStr.size = devices.size();
|
||||
return cArrStr;
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ namespace Relational {
|
||||
ModifyTime MapToModifyTime(std::map<NativeRdb::RdbStore::PRIKey, NativeRdb::RdbStore::Date> &map, int32_t &errCode)
|
||||
{
|
||||
ModifyTime modifyTime{0};
|
||||
modifyTime.size = static_cast<int>(map.size());
|
||||
modifyTime.size = map.size();
|
||||
modifyTime.key = static_cast<RetPRIKeyType*>(malloc(sizeof(RetPRIKeyType) * modifyTime.size));
|
||||
modifyTime.value = static_cast<uint64_t*>(malloc(sizeof(uint64_t) * modifyTime.size));
|
||||
if (modifyTime.key == nullptr || modifyTime.value == nullptr) {
|
||||
@ -293,7 +293,7 @@ namespace Relational {
|
||||
int64_t index = 0;
|
||||
for (auto it = map.begin(); it != map.end(); ++it) {
|
||||
modifyTime.key[index] = VariantToRetPRIKeyType(it->first);
|
||||
modifyTime.value[index] = static_cast<uint32_t>((it->second).date);
|
||||
modifyTime.value[index] = (it->second).date;
|
||||
index++;
|
||||
}
|
||||
return modifyTime;
|
||||
@ -312,7 +312,7 @@ namespace Relational {
|
||||
for (size_t i = 0; i < arr.size(); i++) {
|
||||
types.head[i] = VariantToRetPRIKeyType(arr[i]);
|
||||
}
|
||||
types.size = static_cast<int>(arr.size());
|
||||
types.size = arr.size();
|
||||
return types;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ namespace Relational {
|
||||
infos.head[index] = ToRetChangeInfo(origin, it);
|
||||
index++;
|
||||
}
|
||||
infos.size = static_cast<int>(changeInfo.size());
|
||||
infos.size = changeInfo.size();
|
||||
return infos;
|
||||
}
|
||||
|
||||
|
@ -242,17 +242,19 @@ int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::string &ou
|
||||
if (buffSize >= JSUtils::MAX_VALUE_LENGTH - 1) {
|
||||
buffSize = JSUtils::MAX_VALUE_LENGTH - 1;
|
||||
}
|
||||
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(buffSize + 1);
|
||||
char *buffer = (char *)malloc((buffSize + 1) * sizeof(char));
|
||||
if (buffer == nullptr) {
|
||||
LOG_ERROR("buffer data is nullptr.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_value_string_utf8(env, jsValue, buffer.get(), buffSize + 1, &buffSize);
|
||||
status = napi_get_value_string_utf8(env, jsValue, buffer, buffSize + 1, &buffSize);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("napi_get_value_string_utf8 failed, status = %{public}d", status);
|
||||
free(buffer);
|
||||
return status;
|
||||
}
|
||||
output = std::string(buffer.get());
|
||||
output = std::string(buffer);
|
||||
free(buffer);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -180,9 +180,6 @@ std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::Ge
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return predicatesProxy->predicates_;
|
||||
}
|
||||
|
||||
|
@ -206,9 +206,6 @@ std::shared_ptr<NativeRdb::RdbPredicates> RdbPredicatesProxy::GetNativePredicate
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return predicatesProxy->predicates_;
|
||||
}
|
||||
|
||||
@ -220,9 +217,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldArrayByName(napi_env env, napi
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 1, std::make_shared<ParamNumError>("1"), version);
|
||||
|
||||
@ -247,9 +241,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldByName(
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 1, std::make_shared<ParamNumError>("1"), version);
|
||||
|
||||
@ -267,9 +258,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseInt32FieldByName(
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 1, std::make_shared<ParamNumError>("1"), version);
|
||||
|
||||
@ -287,9 +275,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldAndValueArray(napi_env env, na
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
// Ensure that argc contains 2 parameters
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 2, std::make_shared<ParamNumError>("2"), version);
|
||||
@ -314,9 +299,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldAndValue(napi_env env, napi_ca
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
// 2 represents the number of parameters
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 2, std::make_shared<ParamNumError>("2"), version);
|
||||
@ -342,9 +324,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldAndStringValue(napi_env env, n
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
// 2 represents the number of parameters
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 2, std::make_shared<ParamNumError>("2"), version);
|
||||
@ -366,9 +345,6 @@ RdbPredicatesProxy *RdbPredicatesProxy::ParseFieldLowAndHigh(
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
RdbPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
int version = predicatesProxy->apiversion;
|
||||
// 3 represents the number of parameters
|
||||
RDB_NAPI_ASSERT_FROMV9(env, argc == 3, std::make_shared<ParamNumError>("3"), version);
|
||||
|
@ -249,9 +249,6 @@ uint32_t *SharedBlock::AllocRowOffset()
|
||||
|
||||
uint32_t rowPos = mHeader->rowNums % ROW_NUM_IN_A_GROUP;
|
||||
RowGroupHeader *group = static_cast<RowGroupHeader *>(OffsetToPtr(mHeader->groupOffset[groupPos]));
|
||||
if (group == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
mHeader->rowNums += 1;
|
||||
return group->rowOffsets + rowPos;
|
||||
}
|
||||
@ -267,9 +264,6 @@ SharedBlock::CellUnit *SharedBlock::GetCellUnit(uint32_t row, uint32_t column)
|
||||
|
||||
uint32_t groupPos = row / ROW_NUM_IN_A_GROUP;
|
||||
uint32_t rowPos = row % ROW_NUM_IN_A_GROUP;
|
||||
if (groupPos > GROUP_NUM) {
|
||||
return nullptr;
|
||||
}
|
||||
RowGroupHeader *group = reinterpret_cast<RowGroupHeader *>(mData + mHeader->groupOffset[groupPos]);
|
||||
return reinterpret_cast<CellUnit *>(mData + group->rowOffsets[rowPos]) + column;
|
||||
}
|
||||
@ -314,9 +308,6 @@ int SharedBlock::PutBlobOrString(uint32_t row, uint32_t column, const void *valu
|
||||
}
|
||||
uint32_t groupPos = row / ROW_NUM_IN_A_GROUP;
|
||||
uint32_t rowPos = row % ROW_NUM_IN_A_GROUP;
|
||||
if (groupPos > GROUP_NUM) {
|
||||
return SHARED_BLOCK_NO_MEMORY;
|
||||
}
|
||||
RowGroupHeader *group = reinterpret_cast<RowGroupHeader *>(mData + mHeader->groupOffset[groupPos]);
|
||||
CellUnit *cellUnit = reinterpret_cast<CellUnit *>(mData + group->rowOffsets[rowPos]) + column;
|
||||
uint32_t offset = mHeader->unusedOffset;
|
||||
@ -350,9 +341,6 @@ int SharedBlock::PutLong(uint32_t row, uint32_t column, int64_t value)
|
||||
|
||||
uint32_t groupPos = row / ROW_NUM_IN_A_GROUP;
|
||||
uint32_t rowPos = row % ROW_NUM_IN_A_GROUP;
|
||||
if (groupPos > GROUP_NUM) {
|
||||
return SHARED_BLOCK_NO_MEMORY;
|
||||
}
|
||||
RowGroupHeader *group = reinterpret_cast<RowGroupHeader *>(mData + mHeader->groupOffset[groupPos]);
|
||||
CellUnit *cellUnit = reinterpret_cast<CellUnit *>(mData + group->rowOffsets[rowPos]) + column;
|
||||
cellUnit->type = CELL_UNIT_TYPE_INTEGER;
|
||||
@ -371,9 +359,6 @@ int SharedBlock::PutDouble(uint32_t row, uint32_t column, double value)
|
||||
|
||||
uint32_t groupPos = row / ROW_NUM_IN_A_GROUP;
|
||||
uint32_t rowPos = row % ROW_NUM_IN_A_GROUP;
|
||||
if (groupPos > GROUP_NUM) {
|
||||
return SHARED_BLOCK_NO_MEMORY;
|
||||
}
|
||||
RowGroupHeader *group = reinterpret_cast<RowGroupHeader *>(mData + mHeader->groupOffset[groupPos]);
|
||||
CellUnit *cellUnit = reinterpret_cast<CellUnit *>(mData + group->rowOffsets[rowPos]) + column;
|
||||
cellUnit->type = CELL_UNIT_TYPE_FLOAT;
|
||||
@ -392,9 +377,6 @@ int SharedBlock::PutNull(uint32_t row, uint32_t column)
|
||||
|
||||
uint32_t groupPos = row / ROW_NUM_IN_A_GROUP;
|
||||
uint32_t rowPos = row % ROW_NUM_IN_A_GROUP;
|
||||
if (groupPos > GROUP_NUM) {
|
||||
return SHARED_BLOCK_NO_MEMORY;
|
||||
}
|
||||
RowGroupHeader *group = reinterpret_cast<RowGroupHeader *>(mData + mHeader->groupOffset[groupPos]);
|
||||
CellUnit *cellUnit = reinterpret_cast<CellUnit *>(mData + group->rowOffsets[rowPos]) + column;
|
||||
|
||||
|
@ -60,7 +60,6 @@ public:
|
||||
static std::string GetSlavePath(const std::string& name);
|
||||
static bool TryAccessSlaveLock(const std::string &dbPath, bool isDelete, bool needCreate,
|
||||
bool isSlaveFailure = false);
|
||||
static std::string RealPath(const std::string &inOriPath);
|
||||
|
||||
private:
|
||||
struct SqlType {
|
||||
|
@ -193,12 +193,7 @@ bool SqliteUtils::IsSlaveDbName(const std::string &fileName)
|
||||
bool SqliteUtils::TryAccessSlaveLock(const std::string &dbPath, bool isDelete, bool needCreate,
|
||||
bool isSlaveFailure)
|
||||
{
|
||||
auto realPath = RealPath(dbPath);
|
||||
if (realPath.empty()) {
|
||||
LOG_ERROR("get real path file failed, len = %{public}zu.", realPath.size());
|
||||
return false;
|
||||
}
|
||||
std::string lockFile = isSlaveFailure ? realPath + "-slaveFailure" : realPath + "-syncInterrupt";
|
||||
std::string lockFile = isSlaveFailure ? dbPath + "-slaveFailure" : dbPath + "-syncInterrupt";
|
||||
if (isDelete) {
|
||||
if (std::remove(lockFile.c_str()) != 0) {
|
||||
LOG_WARN("remove slave lock failed errno %{public}d %{public}s", errno, Anonymous(lockFile).c_str());
|
||||
@ -236,20 +231,5 @@ std::string SqliteUtils::GetSlavePath(const std::string& name)
|
||||
}
|
||||
return name.substr(0, pos) + slaveSuffix;
|
||||
}
|
||||
|
||||
std::string SqliteUtils::RealPath(const std::string &inOriPath)
|
||||
{
|
||||
std::vector<char> realPath(PATH_MAX + 1, '\0');
|
||||
if (inOriPath.size() > PATH_MAX || realpath(inOriPath.c_str(), realPath.data()) == nullptr) {
|
||||
LOG_ERROR("get real path fail!");
|
||||
return "";
|
||||
}
|
||||
auto outOriPath = std::string(realPath.data());
|
||||
if (access(outOriPath.c_str(), F_OK) != 0) {
|
||||
LOG_ERROR("FileDeal : access errInfo=%{public}s", strerror(errno));
|
||||
return "";
|
||||
}
|
||||
return outOriPath;
|
||||
}
|
||||
} // namespace NativeRdb
|
||||
} // namespace OHOS
|
||||
|
@ -332,7 +332,6 @@ if (is_ohos && !build_ohos_sdk) {
|
||||
deps = base_deps
|
||||
|
||||
sources += [
|
||||
"${relational_store_mock_path}/frameworks/native/rdb/stdlib.cpp",
|
||||
"${relational_store_native_path}/rdb/mock/src/rdb_radar_reporter.cpp",
|
||||
"${relational_store_native_path}/rdb/mock/src/task_executor.cpp",
|
||||
]
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "stdlib.h"
|
||||
#define IOC(a, b, c, d) (((a) << 30) | ((b) << 8) | (c) | ((d) << 16))
|
||||
#define IOC_READ 2U
|
||||
#define IOR(a, b, c) IOC(IOC_READ, (a), (b), sizeof(c))
|
||||
namespace OHOS {
|
||||
namespace NativeRdb {
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
static char *realpath(const char *__restrict path, char *__restrict resolved_path)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace NativeRdb
|
||||
} // namespace OHOS
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_STDLIB_H
|
||||
#define MOCK_STDLIB_H
|
||||
namespace OHOS {
|
||||
namespace NativeRdb {
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
static char *realpath(const char *__restrict path, char *__restrict resolved_path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace NativeRdb
|
||||
} // namespace OHOS
|
||||
#endif //MOCK_STDLIB_H
|
Loading…
Reference in New Issue
Block a user