* [LTP] [PATCH] syscalls/chown01: Fix test file creation @ 2013-06-08 2:54 Jungsoo Son 2013-06-10 14:07 ` Jan Stancek 0 siblings, 1 reply; 4+ messages in thread From: Jungsoo Son @ 2013-06-08 2:54 UTC (permalink / raw) To: ltp-list There is a bug in the code to create the file and the code is very intricate. So replace it with SAFE_FILE_PRINTF(). Signed-off-by: jungsoo.son <jungsoo.son@lge.com> --- testcases/kernel/syscalls/chown/chown01.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/syscalls/chown/chown01.c b/testcases/kernel/syscalls/chown/chown01.c index 50b9ea5..14b699b 100644 --- a/testcases/kernel/syscalls/chown/chown01.c +++ b/testcases/kernel/syscalls/chown/chown01.c @@ -116,9 +116,7 @@ #include <signal.h> #include "test.h" #include "usctest.h" - -void setup(); -void cleanup(); +#include "safe_macros.h" char *TCID = "chown01"; int TST_TOTAL = 1; @@ -126,8 +124,10 @@ int TST_TOTAL = 1; int exp_enos[] = { 0, 0 }; char fname[255]; -int fd, uid, gid; -char *buf = "davef"; +int uid, gid; + +static void setup(); +static void cleanup(); int main(int ac, char **av) { @@ -163,7 +163,7 @@ int main(int ac, char **av) } -void setup() +static void setup() { tst_sig(NOFORK, DEF_HANDLER, cleanup); @@ -176,17 +176,11 @@ void setup() gid = getegid(); sprintf(fname, "t_%d", getpid()); - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) - tst_brkm(TBROK | TERRNO, cleanup, - "open(%s, O_RDWR|O_CREAT,0700) failed", fname); - else if (write(fd, &buf, strlen(buf)) == -1) - tst_brkm(TBROK | TERRNO, cleanup, - "write(%s, &buf, strlen(buf)) failed", fname); - else if (close(fd) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", fname); + + SAFE_FILE_PRINTF(cleanup, fname, "davef"); } -void cleanup() +static void cleanup() { TEST_CLEANUP; -- 1.7.9.5 ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] syscalls/chown01: Fix test file creation 2013-06-08 2:54 [LTP] [PATCH] syscalls/chown01: Fix test file creation Jungsoo Son @ 2013-06-10 14:07 ` Jan Stancek 2013-06-10 23:36 ` Jungsoo Son 0 siblings, 1 reply; 4+ messages in thread From: Jan Stancek @ 2013-06-10 14:07 UTC (permalink / raw) To: Jungsoo Son; +Cc: ltp-list ----- Original Message ----- > From: "Jungsoo Son" <jungsoo.son@lge.com> > To: ltp-list@lists.sourceforge.net > Sent: Saturday, 8 June, 2013 4:54:26 AM > Subject: [LTP] [PATCH] syscalls/chown01: Fix test file creation > > There is a bug in the code to create the file and the code is > very intricate. So replace it with SAFE_FILE_PRINTF(). > > Signed-off-by: jungsoo.son <jungsoo.son@lge.com> Please add void to setup()/cleanup(). The rest looks OK. Regards, Jan > --- > testcases/kernel/syscalls/chown/chown01.c | 24 +++++++++--------------- > 1 file changed, 9 insertions(+), 15 deletions(-) > > diff --git a/testcases/kernel/syscalls/chown/chown01.c > b/testcases/kernel/syscalls/chown/chown01.c > index 50b9ea5..14b699b 100644 > --- a/testcases/kernel/syscalls/chown/chown01.c > +++ b/testcases/kernel/syscalls/chown/chown01.c > @@ -116,9 +116,7 @@ > #include <signal.h> > #include "test.h" > #include "usctest.h" > - > -void setup(); > -void cleanup(); > +#include "safe_macros.h" > > char *TCID = "chown01"; > int TST_TOTAL = 1; > @@ -126,8 +124,10 @@ int TST_TOTAL = 1; > int exp_enos[] = { 0, 0 }; > > char fname[255]; > -int fd, uid, gid; > -char *buf = "davef"; > +int uid, gid; > + > +static void setup(); > +static void cleanup(); in these two above ^^ > > int main(int ac, char **av) > { > @@ -163,7 +163,7 @@ int main(int ac, char **av) > > } > > -void setup() > +static void setup() here > { > > tst_sig(NOFORK, DEF_HANDLER, cleanup); > @@ -176,17 +176,11 @@ void setup() > gid = getegid(); > > sprintf(fname, "t_%d", getpid()); > - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) > - tst_brkm(TBROK | TERRNO, cleanup, > - "open(%s, O_RDWR|O_CREAT,0700) failed", fname); > - else if (write(fd, &buf, strlen(buf)) == -1) > - tst_brkm(TBROK | TERRNO, cleanup, > - "write(%s, &buf, strlen(buf)) failed", fname); > - else if (close(fd) == -1) > - tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", > fname); > + > + SAFE_FILE_PRINTF(cleanup, fname, "davef"); > } > > -void cleanup() > +static void cleanup() and here. > { > TEST_CLEANUP; > > -- > 1.7.9.5 > > > ------------------------------------------------------------------------------ > How ServiceNow helps IT people transform IT departments: > 1. A cloud service to automate IT design, transition and operations > 2. Dashboards that offer high-level views of enterprise services > 3. A single system of record for all IT processes > http://p.sf.net/sfu/servicenow-d2d-j > _______________________________________________ > Ltp-list mailing list > Ltp-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ltp-list > ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] syscalls/chown01: Fix test file creation 2013-06-10 14:07 ` Jan Stancek @ 2013-06-10 23:36 ` Jungsoo Son 2013-06-11 0:07 ` Wanlong Gao 0 siblings, 1 reply; 4+ messages in thread From: Jungsoo Son @ 2013-06-10 23:36 UTC (permalink / raw) To: 'Jan Stancek'; +Cc: ltp-list I added 'void' to setup() and cleanup() as your mention. There is a bug in the code to create the file and the code is very intricate. So replace it with SAFE_FILE_PRINTF(). Signed-off-by: jungsoo.son <jungsoo.son@lge.com> --- testcases/kernel/syscalls/chown/chown01.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/syscalls/chown/chown01.c b/testcases/kernel/syscalls/chown/chown01.c index 50b9ea5..d95564e 100644 --- a/testcases/kernel/syscalls/chown/chown01.c +++ b/testcases/kernel/syscalls/chown/chown01.c @@ -116,9 +116,7 @@ #include <signal.h> #include "test.h" #include "usctest.h" - -void setup(); -void cleanup(); +#include "safe_macros.h" char *TCID = "chown01"; int TST_TOTAL = 1; @@ -126,8 +124,10 @@ int TST_TOTAL = 1; int exp_enos[] = { 0, 0 }; char fname[255]; -int fd, uid, gid; -char *buf = "davef"; +int uid, gid; + +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { @@ -163,7 +163,7 @@ int main(int ac, char **av) } -void setup() +static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); @@ -176,17 +176,11 @@ void setup() gid = getegid(); sprintf(fname, "t_%d", getpid()); - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) - tst_brkm(TBROK | TERRNO, cleanup, - "open(%s, O_RDWR|O_CREAT,0700) failed", fname); - else if (write(fd, &buf, strlen(buf)) == -1) - tst_brkm(TBROK | TERRNO, cleanup, - "write(%s, &buf, strlen(buf)) failed", fname); - else if (close(fd) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", fname); + + SAFE_FILE_PRINTF(cleanup, fname, "davef"); } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; -- 1.7.9.5 > -----Original Message----- > From: Jan Stancek [mailto:jstancek@redhat.com] > Sent: Monday, June 10, 2013 11:08 PM > To: Jungsoo Son > Cc: ltp-list@lists.sourceforge.net > Subject: Re: [LTP] [PATCH] syscalls/chown01: Fix test file creation > > > ----- Original Message ----- > > From: "Jungsoo Son" <jungsoo.son@lge.com> > > To: ltp-list@lists.sourceforge.net > > Sent: Saturday, 8 June, 2013 4:54:26 AM > > Subject: [LTP] [PATCH] syscalls/chown01: Fix test file creation > > > > There is a bug in the code to create the file and the code is very > > intricate. So replace it with SAFE_FILE_PRINTF(). > > > > Signed-off-by: jungsoo.son <jungsoo.son@lge.com> > > Please add void to setup()/cleanup(). The rest looks OK. > > Regards, > Jan > > > --- > > testcases/kernel/syscalls/chown/chown01.c | 24 +++++++++-------------- > - > > 1 file changed, 9 insertions(+), 15 deletions(-) > > > > diff --git a/testcases/kernel/syscalls/chown/chown01.c > > b/testcases/kernel/syscalls/chown/chown01.c > > index 50b9ea5..14b699b 100644 > > --- a/testcases/kernel/syscalls/chown/chown01.c > > +++ b/testcases/kernel/syscalls/chown/chown01.c > > @@ -116,9 +116,7 @@ > > #include <signal.h> > > #include "test.h" > > #include "usctest.h" > > - > > -void setup(); > > -void cleanup(); > > +#include "safe_macros.h" > > > > char *TCID = "chown01"; > > int TST_TOTAL = 1; > > @@ -126,8 +124,10 @@ int TST_TOTAL = 1; int exp_enos[] = { 0, 0 }; > > > > char fname[255]; > > -int fd, uid, gid; > > -char *buf = "davef"; > > +int uid, gid; > > + > > +static void setup(); > > +static void cleanup(); > > in these two above ^^ > > > > > int main(int ac, char **av) > > { > > @@ -163,7 +163,7 @@ int main(int ac, char **av) > > > > } > > > > -void setup() > > +static void setup() > > here > > > { > > > > tst_sig(NOFORK, DEF_HANDLER, cleanup); @@ -176,17 +176,11 @@ void > > setup() > > gid = getegid(); > > > > sprintf(fname, "t_%d", getpid()); > > - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) > > - tst_brkm(TBROK | TERRNO, cleanup, > > - "open(%s, O_RDWR|O_CREAT,0700) failed", fname); > > - else if (write(fd, &buf, strlen(buf)) == -1) > > - tst_brkm(TBROK | TERRNO, cleanup, > > - "write(%s, &buf, strlen(buf)) failed", fname); > > - else if (close(fd) == -1) > > - tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", > > fname); > > + > > + SAFE_FILE_PRINTF(cleanup, fname, "davef"); > > } > > > > -void cleanup() > > +static void cleanup() > > and here. > > > { > > TEST_CLEANUP; > > > > -- > > 1.7.9.5 > > > > > > ---------------------------------------------------------------------- > > -------- How ServiceNow helps IT people transform IT departments: > > 1. A cloud service to automate IT design, transition and operations 2. > > Dashboards that offer high-level views of enterprise services 3. A > > single system of record for all IT processes > > http://p.sf.net/sfu/servicenow-d2d-j > > _______________________________________________ > > Ltp-list mailing list > > Ltp-list@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/ltp-list > > ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] syscalls/chown01: Fix test file creation 2013-06-10 23:36 ` Jungsoo Son @ 2013-06-11 0:07 ` Wanlong Gao 0 siblings, 0 replies; 4+ messages in thread From: Wanlong Gao @ 2013-06-11 0:07 UTC (permalink / raw) To: Jungsoo Son; +Cc: ltp-list On 06/11/2013 07:36 AM, Jungsoo Son wrote: > I added 'void' to setup() and cleanup() as your mention. > > > There is a bug in the code to create the file and the code is > very intricate. So replace it with SAFE_FILE_PRINTF(). > > Signed-off-by: jungsoo.son <jungsoo.son@lge.com> Applied, thank you. Wanlong Gao ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-11 0:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-06-08 2:54 [LTP] [PATCH] syscalls/chown01: Fix test file creation Jungsoo Son 2013-06-10 14:07 ` Jan Stancek 2013-06-10 23:36 ` Jungsoo Son 2013-06-11 0:07 ` Wanlong Gao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox