On Thu, Mar 17, 2016 at 05:32:12PM +0800, Fei Jie wrote:
> --- /dev/null
> +++ b/tests/syslog.c
> @@ -0,0 +1,40 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_syslog
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +# define SYSLOG_ACTION_READ 2
> +
> +static char buf[1024];

This creates an illusion that sizeof(buf) matters, which is not the case.
The only thing you need in this test is a pointer, so ...

> +int
> +main(void)
> +{
> +     int rc = syscall(__NR_syslog, SYSLOG_ACTION_READ, buf, -1);
> +     const char *errno_text;

... just use a pointer.  Any pointer.  For example,

        const char *errno_text;
        const void *bufp = &errno_text;
        int rc = syscall(__NR_syslog, SYSLOG_ACTION_READ, bufp, -1);
        ...
        printf("syslog(SYSLOG_ACTION_READ, %p, -1) = %d %s (%m)\n",
               bufp, rc, errno_text);
        

-- 
ldv

Attachment: pgpHdcJJqwRBb.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

Reply via email to