From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] /vm/hugepage/thp/thp05: cleanup should not use safe macros
Date: Wed, 26 Nov 2014 15:50:04 +0100 [thread overview]
Message-ID: <20141126145004.GA3306@rei> (raw)
In-Reply-To: <857789373.5490769.1415284744752.JavaMail.zimbra@redhat.com>
Hi!
> > What should be done in this case is to create an equivalent to the
> > SAFE_FILE_PRINTF() function that is not calling the tst_brkm() and
>
>
> well, if create a new safe function/macro to replace use the SAFE_FILE_PRINTF
> but not calling tst_brkm(), that's will be break the safe rule.
> if create a unsafe function/macro, I dont know where is to place the
> new function and how to rename.
>
> Additional, i found so much testcases use safe macro in there cleanup(), that's
> really a hard work if maintain all.
The ideal solution would be to create a base functions file_scanf() and
file_printf() that would look like safe_file_scanf() and
safe_file_printf() but without the file, lineno and cleanup parameters.
These would return non-zero return value on failure and then we can base the
safe_file_scanf() on the top of these functions.
I.e. safe_file_scanf() would call file_scanf() and call tst_brkm() if
file_scanf() has reported a failure. Then we can use file_scanf() in test
cleanup. But as these functions use variable number of arguments this needs one
more indirection with functions that takes va_list.
int file_vscanf(const char *file, const char *fmt, va_list va)
{
// do here what safe_file_scanf() does but return with error
// instead of tst_brkm()
}
int file_scanf(const char *file, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
ret = file_vscanf(file, fmt, va);
va_end(va);
return ret;
}
void safe_file_scanf(const char *file, const int lineno,
void (*cleanup_fn) (void),
const char *path, const char *fmt, ...)
{
// call file_vscanf() here and switch on it's exit value
// i.e. one for failed to open file
// one for EOF
// one for unexpected number of conversion
// and exit cleanly on zero
}
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-11-26 14:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 3:31 [LTP] [PATCH] /vm/hugepage/thp/thp05: cleanup should not use safe macros Li Wang
2014-11-06 10:22 ` Cyril Hrubis
[not found] ` <857789373.5490769.1415284744752.JavaMail.zimbra@redhat.com>
2014-11-26 14:50 ` Cyril Hrubis [this message]
[not found] <1417512939-6435-1-git-send-email-liwang@redhat.com>
[not found] ` <2046852420.5414979.1417513768451.JavaMail.zimbra@redhat.com>
2014-12-02 12:00 ` Cyril Hrubis
[not found] <1417596291-8540-1-git-send-email-liwang@redhat.com>
[not found] ` <373996084.5962831.1417596425167.JavaMail.zimbra@redhat.com>
2014-12-03 10:50 ` Cyril Hrubis
[not found] <1417612136-10890-1-git-send-email-liwang@redhat.com>
[not found] ` <152932834.6076324.1417612296820.JavaMail.zimbra@redhat.com>
2014-12-16 14:47 ` Cyril Hrubis
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=20141126145004.GA3306@rei \
--to=chrubis@suse.cz \
--cc=liwang@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/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