未验证 提交 9f39a6bd 编写于 作者: O openharmony_ci 提交者: Gitee

!1180 【OpenHarmony开源贡献者计划2022】判断sprintf_s函数的返回值

Merge pull request !1180 from zhaoweiying/master
......@@ -182,7 +182,10 @@ static int DoResizeF2fs(const char* device, const unsigned long long size)
unsigned long long realSize = size *
((unsigned long long)RESIZE_BUFFER_SIZE * RESIZE_BUFFER_SIZE / FS_MANAGER_BUFFER_SIZE);
char sizeStr[RESIZE_BUFFER_SIZE] = {0};
sprintf_s(sizeStr, RESIZE_BUFFER_SIZE, "%llu", realSize);
int len = sprintf_s(sizeStr, RESIZE_BUFFER_SIZE, "%llu", realSize);
if (len <= 0) {
BEGET_LOGE("Write buffer size failed.");
}
char *cmd[] = {
file, "-t", sizeStr, (char *)device, NULL
};
......@@ -229,7 +232,10 @@ static int DoResizeExt(const char* device, const unsigned long long size)
ret = ExecCommand(argc, argv);
} else {
char sizeStr[RESIZE_BUFFER_SIZE] = {0};
sprintf_s(sizeStr, RESIZE_BUFFER_SIZE, "%lluM", size);
int len = sprintf_s(sizeStr, RESIZE_BUFFER_SIZE, "%lluM", size);
if (len <= 0) {
BEGET_LOGE("Write buffer size failed.");
}
char *cmd[] = {
file, "-f", (char *)device, sizeStr, NULL
};
......
......@@ -38,7 +38,10 @@ char *BShellEnvErrString(BShellHandle handle, int32_t err)
}
BSH_CHECK(handle != NULL, return "System unknow err", "Invalid shell env");
BShellEnv *shell = (BShellEnv *)handle;
sprintf_s(shell->data, sizeof(shell->data) - 1, "System unknow err 0x%08x", err);
int len = sprintf_s(shell->data, sizeof(shell->data) - 1, "System unknow err 0x%08x", err);
if (len <= 0) {
BSH_LOGE("Write shell data size failed.");
}
return shell->data;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册