[LTP] [PATCH v2 2/2] syscalls/acct01: convert to new library

Sandeep Patil
2019-04-05T14:25:53Z

On Fri, Apr 05, 2019 at 03:01:19PM +0200, Cyril Hrubis wrote:
> Hi!
> Pushed with cosmetic changes, thanks.
>
> > -static void setup2(void)
> > +static void verify_acct(unsigned int nr)
> > {
> > - SAFE_SETEUID(cleanup, ltpuser->pw_uid);
> > -}
> > + struct test_case *tcase = &tcases[nr];
> >
> > -static void cleanup2(void)
> > -{
> > - SAFE_SETEUID(cleanup, 0);
> > -}
> > + if (tcase->setupfunc)
> > + tcase->setupfunc();
> >
> > -static void cleanup(void)
> > -{
> > - if (acct(NULL) == -1)
> > - tst_resm(TWARN | TERRNO, "acct(NULL) failed");
> > + TEST(acct(tcase->filename));
> >
> > - if (mount_flag && tst_umount("mntpoint") < 0) {
> > - tst_resm(TWARN | TERRNO,
> > - "umount device:%s failed", device);
> > - }
> > + if (tcase->cleanfunc)
> > + tcase->cleanfunc();
> >
> > - if (device)
> > - tst_release_device(device);
> > + if (TST_RET != -1)
> > + tst_res(TFAIL, "acct(%s) succeeded unexpectedly",
> > + tcase->filename);
>
> I've put this block inside curly braces and added return; after the
> tst_res() here so that the code flow is more clear.
>
> > - tst_rmdir();
> > + if (TST_ERR == tcase->exp_errno)
> > + tst_res(TPASS | TTERRNO, "acct() failed as expected");
> > + else
> > + tst_res(TFAIL | TTERRNO,
> > + "acct() failed, expected: %s",
> > + tst_strerrno(tcase->exp_errno));
>
> And also added curly braces around these blocks, since LKML prefers to
> have them when at least one block spans across multiple lines.

Thanks Cyril, I'll remember that next time around. checkpatch didn't yell
back at me so I figured it'll be fine.

- ssp