Re: [LTP] [PATCH v7 2/4] Hugetlb: Migrating libhugetlbfs brk_near_huge

Cyril Hrubis
2022-11-04T12:06:56Z

Hi!
> +#ifdef __powerpc64__
> +static int arch_has_slice_support(void)
> +{
> + char mmu_type[16];
> + FILE *fp;
> + int ret;
> +
> + fp = SAFE_POPEN("cat /proc/cpuinfo | grep MMU | awk '{ print $3}'", "r");
> + ret = fscanf(fp, "%s", mmu_type);
> + pclose(fp);
> +
> + if (ret < 0)
> + tst_brk(TBROK, "Failed to determine MMU type");

We do have SAFE_FILE_LINES_SCANF() that simplifies all this to a single line;

SAFE_FILE_LINES_SCANF("/proc/cpuinfo", "MMU : %16s", mmu_type);

--
Cyril Hrubis
chrubis@suse.cz