From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] SAFE_MACROS: Add SAFE_GETGRNAM()
Date: Mon, 26 Mar 2018 15:22:42 +0200 [thread overview]
Message-ID: <20180326132242.GA20143@x230> (raw)
In-Reply-To: <1521184376-3649-1-git-send-email-huangjh.jy@cn.fujitsu.com>
Hi Jinhui,
> Signed-off-by: Jinhui Huang <huangjh.jy@cn.fujitsu.com>
> ---
> include/old/safe_macros.h | 3 +++
> include/safe_macros_fn.h | 3 +++
> include/tst_safe_macros.h | 9 +++------
> lib/safe_macros.c | 15 +++++++++++++++
> 4 files changed, 24 insertions(+), 6 deletions(-)
> diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
> index e778d30..0718060 100644
> --- a/include/old/safe_macros.h
> +++ b/include/old/safe_macros.h
> @@ -44,6 +44,9 @@
> #define SAFE_GETPWNAM(cleanup_fn, name) \
> safe_getpwnam(__FILE__, __LINE__, cleanup_fn, (name))
> +#define SAFE_GETGRNAM(cleanup_fn, name) \
> + safe_getgrnam(__FILE__, __LINE__, cleanup_fn, (name))
Can you please sort it alphabetically (i.e. put SAFE_GETGRNAM() before SAFE_GETPWNAM())?
@Cyril: Do we want to change also safe_macros.h ?
> +
> #define SAFE_GETRUSAGE(cleanup_fn, who, usage) \
> safe_getrusage(__FILE__, __LINE__, (cleanup_fn), (who), (usage))
> diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
> index 3df9528..2d3ddae 100644
> --- a/include/safe_macros_fn.h
> +++ b/include/safe_macros_fn.h
> @@ -45,6 +45,9 @@ char* safe_getcwd(const char *file, const int lineno,
> struct passwd* safe_getpwnam(const char *file, const int lineno,
> void (*cleanup_fn)(void), const char *name);
> +struct group *safe_getgrnam(const char *file, const int lineno,
> + void (*cleanup_fn)(void), const char *name);
Again, sort it alphabetically please.
> +
> int safe_getrusage(const char *file, const int lineno,
> void (*cleanup_fn)(void), int who, struct rusage *usage);
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index f115a7b..56ff4c3 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -72,6 +72,9 @@ static inline int safe_dup(const char *file, const int lineno,
> #define SAFE_GETPWNAM(name) \
> safe_getpwnam(__FILE__, __LINE__, NULL, (name))
> +#define SAFE_GETGRNAM(name) \
> + safe_getgrnam(__FILE__, __LINE__, NULL, (name))
And here.
> +
> #define SAFE_GETRUSAGE(who, usage) \
> safe_getrusage(__FILE__, __LINE__, NULL, (who), (usage))
> @@ -397,12 +400,6 @@ static inline sighandler_t safe_signal(const char *file, const int lineno,
> #define SAFE_SIGNAL(signum, handler) \
> safe_signal(__FILE__, __LINE__, (signum), (handler))
> -int safe_sigaction(const char *file, const int lineno,
> - int signum, const struct sigaction *act,
> - struct sigaction *oldact);
> -#define SAFE_SIGACTION(signum, act, oldact) \
> - safe_sigaction(__FILE__, __LINE__, (signum), (act), (oldact))
> -
Removing SAFE_SIGACTION() & safe_sigaction() breaks build. I guess you removed it by
accident.
> #define SAFE_EXECLP(file, arg, ...) do { \
> execlp((file), (arg), ##__VA_ARGS__); \
> tst_brk_(__FILE__, __LINE__, TBROK | TERRNO, \
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index abdeca0..061819e 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -15,6 +15,7 @@
> #include <stdlib.h>
> #include <unistd.h>
> #include <malloc.h>
> +#include <grp.h>
> #include "test.h"
> #include "safe_macros.h"
> @@ -126,6 +127,20 @@ struct passwd *safe_getpwnam(const char *file, const int lineno,
> return rval;
> }
> +struct group *safe_getgrnam(const char *file, const int lineno,
> + void (*cleanup_fn) (void), const char *name)
Again, sort it alphabetically please.
> +{
> + struct group *rval;
> +
> + rval = getgrnam(name);
> + if (rval == NULL) {
> + tst_brkm(TBROK | TERRNO, cleanup_fn,
> + "%s:%d: getgrnam(%s) failed", file, lineno, name);
> + }
> +
> + return rval;
> +}
> +
> int
> safe_getrusage(const char *file, const int lineno, void (*cleanup_fn) (void),
> int who, struct rusage *usage)
Kind regards,
Petr
next prev parent reply other threads:[~2018-03-26 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 7:12 [LTP] [PATCH 1/2] SAFE_MACROS: Add SAFE_GETGRNAM() Jinhui Huang
2018-03-16 7:12 ` [LTP] [PATCH 2/2] Make use of SAFE_GETGRNAM() Jinhui Huang
2018-06-15 14:47 ` Petr Vorel
2018-03-26 13:22 ` Petr Vorel [this message]
2018-03-26 13:39 ` [LTP] [PATCH 1/2] SAFE_MACROS: Add SAFE_GETGRNAM() Cyril Hrubis
2018-06-14 11:25 ` jinhui huang
2018-06-14 11:27 ` [LTP] [PATCH v2] " Jinhui huang
2018-06-15 14:44 ` Petr Vorel
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=20180326132242.GA20143@x230 \
--to=pvorel@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