Skip to content

Commit 96f0a62

Browse files
committed
Unify code in runguard output_cgroup_stats_v{1,2} functions
1 parent 3c1303a commit 96f0a62

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

judge/runguard.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,8 @@ void output_cgroup_stats_v1(double *cputime)
494494
int ret;
495495
if ((ret = cgroup_get_cgroup(cg)) != 0) error(ret,"get cgroup information");
496496

497-
int64_t max_usage;
498-
struct cgroup_controller *cg_controller;
499-
cg_controller = cgroup_get_controller(cg, "memory");
497+
int64_t max_usage = 0;
498+
struct cgroup_controller *cg_controller = cgroup_get_controller(cg, "memory");
500499
ret = cgroup_get_value_int64(cg_controller, "memory.memsw.max_usage_in_bytes", &max_usage);
501500
if ( ret!=0 ) error(ret,"get cgroup value memory.memsw.max_usage_in_bytes");
502501

@@ -516,7 +515,7 @@ void output_cgroup_stats_v1(double *cputime)
516515
void output_cgroup_stats_v2(double *cputime)
517516
{
518517
struct cgroup *cg;
519-
if ( (cg = cgroup_new_cgroup(cgroupname))==NULL ) error(0,"cgroup_new_cgroup");
518+
if ( (cg = cgroup_new_cgroup(cgroupname))==nullptr ) error(0,"cgroup_new_cgroup");
520519

521520
int ret;
522521
if ((ret = cgroup_get_cgroup(cg)) != 0) error(ret,"get cgroup information");
@@ -549,7 +548,6 @@ void output_cgroup_stats_v2(double *cputime)
549548
cgroup_read_stats_end(&handle);
550549

551550
cgroup_free(&cg);
552-
553551
}
554552

555553
/* Temporary shorthand define for error handling. */

0 commit comments

Comments
 (0)