Message ID | 1521184376-3649-1-git-send-email-huangjh.jy@cn.fujitsu.com |
---|---|
State | Changes Requested |
Delegated to: | Petr Vorel |
Headers | show |
Series | [1/2] SAFE_MACROS: Add SAFE_GETGRNAM() | expand |
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
Hi! > > +#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 ? We are not supposed to add anything into oldlib safe macros, the old library is in a maintenance mode, only bugfixes should go there, no new functionality.
To Petr I will write V2 as you suggested, I am sorry to reply so late. Kind Regards, Jinhui On 2018/03/26 21:22, Petr Vorel Wrote: > 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 > > > . >
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)) + #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); + 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)) + #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)) - #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) +{ + 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)
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(-)