fix: check nThreads less than zero.

Signed-off-by: TaowerfulMAX <liurantao@huawei.com>
This commit is contained in:
TaowerfulMAX 2024-08-29 23:23:24 +08:00
parent 12e6afd992
commit ff185e183a
4 changed files with 9 additions and 12 deletions

View File

@ -104,18 +104,9 @@ bool ForkChildCheck(int argc, const char *argv[])
return true;
}
size_t CheckUvThreadConfig()
static size_t CheckUvThreadConfig()
{
string nThreadsString;
bool ret = SystemDepend::GetDevItem("persist.hdc.uv.threads", nThreadsString);
if (!ret) {
return SIZE_THREAD_POOL;
}
size_t nThreads = atoi(nThreadsString.c_str());
if (nThreads <= 0) {
nThreads = SIZE_THREAD_POOL;
}
return nThreads;
return SystemDepend::GetDevUint("persist.hdc.uv.threads", SIZE_THREAD_POOL);
}
int BackgroundRun()

View File

@ -69,6 +69,11 @@ namespace SystemDepend {
return ret;
}
uint32_t GetDevUint(const char *key, uint32_t defaultValue)
{
return GetUintParameter(key, defaultValue);
}
bool CallDoReboot(const char *reason)
{
string rebootCtrl = "ohos.startup.powerctrl";

View File

@ -31,6 +31,7 @@ namespace SystemDepend {
#else
bool GetDevItem(const char *key, string &out, const char *preDefine = nullptr);
bool SetDevItem(const char *key, const char *value);
uint32_t GetDevUint(const char *key, uint32_t defaultValue);
#endif
bool RebootDevice(const string &cmd);
} // namespace SystemDepend

View File

@ -299,7 +299,7 @@ group("hdc_unittest") {
config("hdc_test_config") {
cflags = code_check_flag
ldflags = []
defines = []
defines = [ "HARMONY_PROJECT" ]
if (hdc_test_coverage && is_ohos) {
defines += [ "TEST_COVERAGE" ]