On Mon, Mar 07, 2016 at 11:32:03AM +0800, Fei Jie wrote:
> --- /dev/null
> +++ b/tests/acct.c
> @@ -0,0 +1,37 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_acct
> +
> +# define TMP_FILE "acct_tmpfile"
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +int
> +main(void)

Please move definition of a local macro after inclusion of system headers.
Please add an empty line after headers and before the function.

> +{
> +     int rc = syscall(__NR_acct, TMP_FILE);
> +     const char *errno_text;
> +     switch(errno) {
> +             case EPERM:
> +                     errno_text = "EPERM";
> +                     break;
> +             case ENOSYS:
> +                     errno_text = "ENOSYS";
> +                     break;
> +             default:
> +                     errno_text = "ENOENT";
> +     }
> +     printf("acct(\"%s\") = %d %s (%m)\n",
> +            TMP_FILE, rc, errno_text);

errno has a meaning here only if the syscall has failed.
You rightfully assume that acct will fail, i.e. rc == -1,
otherwise the test is not going to produce correct results.

I think some kind of check for syscall return code should be added here
for consistency, e.g.
        assert(syscall(__NR_acct, TMP_FILE) == -1);


-- 
ldv

Attachment: pgprHfz154AQS.pgp
Description: PGP signature

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://makebettercode.com/inteldaal-eval
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to