diff --git a/source/tools/detect/irqoff/irqoff.c b/source/tools/detect/irqoff/irqoff.c index 5b331bde2a094b3b886b62dde06f9be2dc626525..da6db5fa0c3a16f9a713b2dcefa854df40c2d10d 100644 --- a/source/tools/detect/irqoff/irqoff.c +++ b/source/tools/detect/irqoff/irqoff.c @@ -125,15 +125,6 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) default: return ARGP_ERR_UNKNOWN; } - if (!filep) { - filep = fopen(defaultfile, "w+"); - if (!filep) { - ret = errno; - fprintf(stderr, "%s :fopen %s\n", - strerror(errno), defaultfile); - return ret; - } - } /* refer to watchdog.c:set_sample_period, sample_period set to thres*2/5. */ env.sample_period = env.threshold*2/5; @@ -467,6 +458,15 @@ int main(int argc, char **argv) fprintf(stderr, "argp_parse fail\n"); return err; } + if (!filep) { + filep = fopen(defaultfile, "w+"); + if (!filep) { + err = errno; + fprintf(stderr, "%s :fopen %s\n", + strerror(errno), defaultfile); + return err; + } + } libbpf_set_print(libbpf_print_fn); bump_memlock_rlimit(); diff --git a/source/tools/monitor/sched/runqslower/runqslower.c b/source/tools/monitor/sched/runqslower/runqslower.c index 124bc9a7f8ef08d187b4dc199171680ea776f8fc..01e54e42ff53247c7b01a5c7060afbbe7ca83f89 100644 --- a/source/tools/monitor/sched/runqslower/runqslower.c +++ b/source/tools/monitor/sched/runqslower/runqslower.c @@ -166,15 +166,6 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) default: return ARGP_ERR_UNKNOWN; } - if (!filep) { - filep = fopen(defaultfile, "w+"); - if (!filep) { - int ret = errno; - fprintf(stderr, "%s :fopen %s\n", - strerror(errno), defaultfile); - return ret; - } - } return 0; } @@ -366,6 +357,15 @@ int main(int argc, char **argv) err = argp_parse(&argp, argc, argv, 0, NULL, NULL); if (err) return err; + if (!filep) { + filep = fopen(defaultfile, "w+"); + if (!filep) { + err = errno; + fprintf(stderr, "%s :fopen %s\n", + strerror(errno), defaultfile); + return err; + } + } libbpf_set_print(libbpf_print_fn);