[LTP] [PATCH 1/3] API/cgroup: Add safe_cgroup_lines_scanf
Cyril Hrubis
chrubis@suse.cz
Mon Dec 20 16:08:48 CET 2021
Hi!
> +void safe_cgroup_lines_scanf(const char *const file, const int lineno,
> + const struct tst_cgroup_group *const cg,
> + const char *const file_name,
> + const char *const fmt, ...)
> +{
> + va_list va;
> + char buf[BUFSIZ];
> + ssize_t len = safe_cgroup_read(file, lineno,
> + cg, file_name, buf, sizeof(buf));
> + const int conv_cnt = tst_count_scanf_conversions(fmt);
> + int ret = 0;
> + char *line;
> +
> + if (len < 1)
> + return;
> +
> + line = strtok(buf, "\n");
It may be safer to use strtok_r() other than that:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list