意见修改

Signed-off-by: songdawei <songdawei1@huawei.com>
This commit is contained in:
songdawei 2022-03-28 07:13:18 +00:00
parent 80a0cac402
commit 5b001ca08d
3 changed files with 8 additions and 16 deletions

View File

@ -90,7 +90,10 @@ int waitDataWithCode(char* code, char* data)
while (i < timeout) {
if (readDataFromShm(str) == 0) {
if (strncmp(code, str, CODE_HEAD) == 0) {
if (strncpy_s(data, 2, str + STR_KEY, 1) != EOK) {
errno_t ret = 1;
ret = strncpy_s(data, strlen(data), str + STR_KEY, 1);
if (ret != EOK)
{
return -1;
}
return 0;
@ -165,8 +168,7 @@ char* Int2String(int num, char* str) // 10进制
return nullptr;
}
int i = 0; // 指示填充str
if (num < 0) // 如果num为负数将num变正
{
if (num < 0){
num = -num;
str[i++] = '-';
}
@ -180,8 +182,7 @@ char* Int2String(int num, char* str) // 10进制
// 确定开始调整的位置
int j = 0;
if (str[0] == '-') // 如果有负号,负号不用调整
{
if (str[0] == '-') {
j = 1; // 从第二位开始调整
++i; // 由于有负号,所以交换的对称轴也要后移一位
}

View File

@ -2336,12 +2336,9 @@ HWTEST_F(DistributedKvDataManagerTest, SubscribeWithQuery_0700, TestSize.Level1)
ASSERT_NE(nullptr, DisKvTest::KvStorePtr) << "KvStorePtr is nullptr";
// 1.本端创建Lv
// 2.远端创建kv
// 3. 远端put int
std::string stringKey = "math_score_vector";
Key keyInt = stringKey;
std::vector<uint8_t> vect2 = { 9, 9, 8, 8, 7, 7, 6, 6 };
std::string strvc;
strvc.assign(vect2.begin(), vect2.end());
@ -2350,11 +2347,6 @@ HWTEST_F(DistributedKvDataManagerTest, SubscribeWithQuery_0700, TestSize.Level1)
strcpy_s(strKV, strlen(stringKey.c_str()) + 1, stringKey.c_str());
strcat(strKV, ":");
strcat(strKV, strvc.c_str());
std::cout << "strvc = " << strvc << std::endl;
std::cout << "strvc.c_str() = " << strvc.c_str() << std::endl;
std::cout << "strKV = " << strKV << std::endl;
writeCodeDataToShm(CTRL_CODE_DATAMGR_PUT_DATA, strKV);
char str[MAX_DATA_LENGTH] = { 0 };
@ -2366,7 +2358,6 @@ HWTEST_F(DistributedKvDataManagerTest, SubscribeWithQuery_0700, TestSize.Level1)
strcpy_s(code, strlen(str) + 1, str); // 9999
memset_s(str, MAX_DATA_LENGTH, 0, MAX_DATA_LENGTH);
waitDataWithCode(code, str);
std::cout << "yput-vector<uint8_t> get result=" << str << std::endl;
// 检查远端是否返回成功
int ret = strcmp(str, "0");
EXPECT_EQ(ret, 0);

View File

@ -23,8 +23,8 @@
#include "cstring"
#include "distributed_kv_data_manager.h"
#include "process_msg.h"
#include "types.h"
#include "process_msg.h"
using namespace OHOS::DistributedKv;
using namespace std;
@ -304,7 +304,7 @@ int processGetData(char* putData)
cout << "LOGdisDataTest--ss = " << ss << endl;
cout << "LOGdisDataTest--ss2 = " << ss2 << endl;
LOG("LOGdisDataTest--ss2.c_str() = %s", ss2.c_str());
LOG("LOGdisDataTest--ret.c_str() = %s", ret.c_str()); //数据库
LOG("LOGdisDataTest--ret.c_str() = %s", ret.c_str());
if (strcmp(ss2.c_str(), ret.c_str()) == 0) {
return RESULT_OK;
}