[PATCH v2 2/2] tests: add syslog.test
Dmitry V. Levin
ldv at altlinux.org
Fri Mar 18 22:54:51 UTC 2016
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160319/3f09f3c4/attachment.bin>
More information about the Strace-devel
mailing list