[LTP] [PATCH] lib: fix MemAvailable parsing

Richard Palethorpe rpalethorpe@suse.de
Wed Sep 29 10:14:56 CEST 2021


Hello Ralph,

Ralph Siemsen <ralph.siemsen@linaro.org> writes:

> The amount of available memory was not being returned correctly, which
> resulted in tests being executed when they should have been skipped.
>
> Fixes: 8759f4 ("lib: adjust the tmpfs size according to .dev_min_size and MemAvailable")
> Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
> ---
>  lib/tst_memutils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
> index 69077861f..90911da56 100644
> --- a/lib/tst_memutils.c
> +++ b/lib/tst_memutils.c
> @@ -65,9 +65,9 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
>  
>  long long tst_available_mem(void)
>  {
> -	long long mem_available;
> +	long long mem_available = 0;
>  
> -	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
> +	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %lld",
>  		&mem_available)) {
>  		mem_available = SAFE_READ_MEMINFO("MemFree:")
>  			+ SAFE_READ_MEMINFO("Cached:");
> -- 
> 2.25.1

Just curious, did you find this on 32-bit ARM?

Anyway looks correct.

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

-- 
Thank you,
Richard.


More information about the ltp mailing list