public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH 01/13] mem/lib: convert to new API
Date: Fri, 31 Mar 2017 08:46:46 +0200	[thread overview]
Message-ID: <20170331064645.GA7552@rei.lan> (raw)
In-Reply-To: <CAEemH2cE4ceo0++ayfzgaXS0LOPd17nfibrGWdo1GfTRnJUXmQ@mail.gmail.com>

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

  reply	other threads:[~2017-03-31  6:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28  3:22 [LTP] [RFC PATCH 00/13] Convert LTP kernel/mem/testcase to New API Li Wang
2017-03-28  3:22 ` [LTP] [RFC PATCH 01/13] mem/lib: convert to new API Li Wang
2017-03-28  3:22   ` [LTP] [RFC PATCH 02/13] mem/oom: " Li Wang
2017-03-28  3:22     ` [LTP] [RFC PATCH 03/13] mem/ksm: " Li Wang
2017-03-28  3:22       ` [LTP] [RFC PATCH 04/13] mem/thp: " Li Wang
2017-03-28  3:22         ` [LTP] [RFC PATCH 05/13] mem/hugetlb: " Li Wang
2017-03-28  3:22           ` [LTP] [RFC PATCH 06/13] mem/hugemmap: " Li Wang
2017-03-28  3:22             ` [LTP] [RFC PATCH 07/13] mem/hugeshmat: " Li Wang
2017-03-28  3:22               ` [LTP] [RFC PATCH 08/13] mem/hugeshmctl: " Li Wang
2017-03-28  3:22                 ` [LTP] [RFC PATCH 09/13] mm/hugeshmdt: " Li Wang
2017-03-28  3:22                   ` [LTP] [RFC PATCH 10/13] mem/hugeshmget: " Li Wang
2017-03-28  3:22                     ` [LTP] [RFC PATCH 11/13] mem/cpuset: " Li Wang
2017-03-28  3:22                       ` [LTP] [RFC PATCH 12/13] mem/swapping: " Li Wang
2017-03-28  3:22                         ` [LTP] [RFC PATCH 13/13] mem/tunable: " Li Wang
2017-03-30 15:55   ` [LTP] [RFC PATCH 01/13] mem/lib: " Cyril Hrubis
2017-03-31  6:36     ` Li Wang
2017-03-31  6:46       ` Cyril Hrubis [this message]
2017-03-30 15:43 ` [LTP] [RFC PATCH 00/13] Convert LTP kernel/mem/testcase to New API Cyril Hrubis
2017-03-31  6:01   ` Li Wang
2017-03-31  7:09   ` Jan Stancek
2017-03-31  7:34     ` Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170331064645.GA7552@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox