On Thu, Mar 31, 2016 at 04:06:49PM +0800, Fei Jie wrote:
> * tests/sethostname.c: New file.
> * tests/sethostname.test: New test.
> * tests/.gitignore: Add sethostname.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add sethostname.test.
> ---
>  tests/.gitignore       |  1 +
>  tests/Makefile.am      |  2 ++
>  tests/sethostname.c    | 38 ++++++++++++++++++++++++++++++++++++++
>  tests/sethostname.test |  6 ++++++
>  4 files changed, 47 insertions(+)
>  create mode 100644 tests/sethostname.c
>  create mode 100755 tests/sethostname.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 92ab696..b709f49 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -118,6 +118,7 @@ select
>  sendfile
>  sendfile64
>  set_ptracer_any
> +sethostname
>  sigaction
>  sigaltstack
>  signalfd
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 29d7873..98be3a4 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -167,6 +167,7 @@ check_PROGRAMS = \
>       sendfile \
>       sendfile64 \
>       set_ptracer_any \
> +     sethostname \
>       sigaction \
>       sigaltstack \
>       signalfd \
> @@ -343,6 +344,7 @@ DECODER_TESTS = \
>       select.test \
>       sendfile.test \
>       sendfile64.test \
> +     sethostname.test \
>       sigaction.test \
>       sigaltstack.test \
>       signalfd.test \
> diff --git a/tests/sethostname.c b/tests/sethostname.c
> new file mode 100644
> index 0000000..8b4eca2
> --- /dev/null
> +++ b/tests/sethostname.c
> @@ -0,0 +1,38 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_sethostname
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <sys/utsname.h>

There is no need to include <sys/utsname.h> because...

> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +     static const char *hostname = NULL;
> +     int rc = syscall(__NR_sethostname, hostname, _UTSNAME_LENGTH - 1);

... _UTSNAME_LENGTH cannot be used anyway: it's a constant internal to glibc.

also, there is no need to declare hostname pointer static.

Otherwise OK, applied with these corrections.


-- 
ldv

Attachment: pgpw8hB5_ONiV.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=278785471&iu=/4140
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to