[LTP] [RFC PATCH 01/13] mem/lib: convert to new API
Cyril Hrubis
chrubis@suse.cz
Fri Mar 31 08:46:46 CEST 2017
Hi!
> I saw this MACRO, but it doesn't work with too much pointers which
> transfered by multi level function.
>
> This test program is not work:
> =======================
>
> #include <stdio.h>
> #include "tst_test.h"
>
> long read_meminfo(char *item)
> {
> long val;
>
> SAFE_FILE_LINES_SCANF("/proc/meminfo", "%s %ld", item, &val);
This is because the item has to be part of the matching string and not a
item to be matched the "%s %ld" string would match first line in the
/proc/meminfo. The easiest solution would be turning this into a macro:
#define SAFE_READ_MEMINFO(item) \
({long tst_rval; \
SAFE_FILE_LINES_SCANF("/proc/meminfo", item " %ld",
&tst_rval); \
This of course works only when item is compile time string constant, but
I doubt that we use it with anything else.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list