mirror of
https://gitee.com/openharmony/startup_init
synced 2025-02-20 04:03:54 +00:00
check of nullptr and return value of sprintf_s
Signed-off-by: surencong <surencong@huawei.com> Change-Id: I48acb0ef1d6204e9ae618b99df12cfd9b6a17394
This commit is contained in:
parent
311adae5c0
commit
e2a23a15e1
@ -40,10 +40,17 @@ static bool g_enableSandbox = false;
|
||||
|
||||
static void WriteOomScoreAdjToService(Service *service)
|
||||
{
|
||||
if (service == NULL) {
|
||||
return;
|
||||
}
|
||||
if (IsOnDemandService(service)) {
|
||||
char pidAdjPath[30];
|
||||
const char* content = "-900";
|
||||
sprintf_s(pidAdjPath, sizeof(pidAdjPath), "/proc/%d/oom_score_adj", service->pid);
|
||||
int len = sprintf_s(pidAdjPath, sizeof(pidAdjPath), "/proc/%d/oom_score_adj", service->pid);
|
||||
if (len <= 0) {
|
||||
INIT_LOGE("Service(%s): format pidAdjPath (pid:%d) failed.", service->name, service->pid);
|
||||
return;
|
||||
}
|
||||
int fd = open(pidAdjPath, O_RDWR);
|
||||
if (fd < 0) {
|
||||
INIT_LOGE("Service(%s): open path %s failed.", service->name, pidAdjPath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user