On Sun, Mar 20, 2016 at 01:19:16AM +0530, Jay Joshi wrote: > --- /dev/null > +++ b/tests/getcwd.c > @@ -0,0 +1,40 @@ > +#include "tests.h" > + > +#include <sys/syscall.h> > + > +#ifdef __NR_getcwd > + > +# include <stdio.h> > +# include <unistd.h> > +# include <errno.h>
<nitpick> You no longer need <errno.h>. </nitpick>
> +# include <sys/param.h>
> +
> +int
> +main(void)
> +{
> + long res;
> + char cur_dir[PATH_MAX + 1];
> +
> + res = syscall(__NR_getcwd, cur_dir, sizeof(cur_dir));
> +
> + if (res <= 0)
> + perror_msg_and_fail("getcwd");
> +
> + printf("getcwd(\"");
> + print_quoted_string(cur_dir);
> + printf("\", %zu) = %ld\n", sizeof(cur_dir), res);
> +
> + syscall(__NR_getcwd, cur_dir, 0);
> +
> + printf("getcwd(%p, 0) = -1 ERANGE (%m)\n", cur_dir);
> +
> + puts("+++ exited with 0 +++");
> +
> + return 0;
> +}
Please reindent with TABs.
> --- /dev/null
> +++ b/tests/getcwd.test
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# Check getcwd syscall decoding
This sentence should end with a period.
> +print_quoted_string(const char *str)
> +{
> + unsigned int i=0;
> + int c;
> +
> + while ((c = str[i++]) != '\0') {
Wouldn't it be better without an iterator? e.g.
while ((c = *(str++))) {
> + if (c >= ' ' && c <= 0x7e)
> + printf("%c",c);
Wouldn't putchar(c) in cases like this look simpler?
> + printf("\0");
What is this?
> --- a/tests/tests.h
> +++ b/tests/tests.h
> @@ -75,6 +75,9 @@ const char *hexquote_strndup(const char *, size_t);
> /* Return inode number of socket descriptor. */
> unsigned long inode_of_sockfd(int);
>
> +/* Print string in escaped format */
This sentence should end with a period.
--
ldv
pgpc0cCnsvVP1.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://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
