<div dir="ltr">I almost forget it. Thanks for reminding.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 10, 2018 at 7:51 PM Dmitry V. Levin <<a href="mailto:ldv@altlinux.org">ldv@altlinux.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Jul 04, 2018 at 12:04:22AM +0300, Dmitry V. Levin wrote:<br>
> On Fri, Jun 15, 2018 at 05:00:05PM +0800, Zhibin Li wrote:<br>
> [...]<br>
> > --- a/tests/fcntl-common.c<br>
> > +++ b/tests/fcntl-common.c<br>
> > @@ -31,7 +31,9 @@<br>
> > #include <stdlib.h><br>
> > #include <string.h><br>
> > #include <unistd.h><br>
> > +#include <assert.h><br>
> > #include "flock.h"<br>
> > +#include "signal2name.c"<br>
> <br>
> No need to include "signal2name.c", it's available via libtests,<br>
> you can just use signal2name().<br>
> <br>
> > <br>
> > #define FILE_LEN 4096<br>
> > <br>
> > @@ -238,6 +240,135 @@ test_f_owner_ex(void)<br>
> > }<br>
> > #endif /* TEST_F_OWNER_EX */<br>
> > <br>
> > +struct fcntl_cmd_check {<br>
> > + int fd;<br>
> > + int cmd;<br>
> > + const char *cmd_str;<br>
> > + long arg;<br>
> > + const char *arg_str;<br>
> > + void (*print_flags)(long rc);<br>
> > +};<br>
> > +<br>
> > +static void<br>
> > +print_retval_flags(const struct fcntl_cmd_check *check, long rc)<br>
> > +{<br>
> > + if (check->print_flags) {<br>
> > + check->print_flags(rc);<br>
> > + } else {<br>
> > + printf("%s", errstr);<br>
> > + }<br>
> > + printf("\n");<br>
> > +}<br>
> > +<br>
> > +static void<br>
> > +test_other_set_cmd(const struct fcntl_cmd_check *check)<br>
> > +{<br>
> > + invoke_test_syscall(check->fd, check->cmd, (void *) check->arg);<br>
> <br>
> This explicit cast to (void *) is redundant.<br>
> <br>
> > + printf("%s(%d, %s, %s) = %s\n",<br>
> > + TEST_SYSCALL_STR, check->fd,<br>
> > + check->cmd_str, check->arg_str, errstr);<br>
> > +<br>
> > + /* bad file fd */<br>
> > + invoke_test_syscall(-1, check->cmd, (void *) check->arg);<br>
> <br>
> Likewise.<br>
> <br>
> > + printf("%s(-1, %s, %s) = %s\n",<br>
> > + TEST_SYSCALL_STR, check->cmd_str,<br>
> > + check->arg_str, errstr);<br>
> > +}<br>
> > +<br>
> > +static void<br>
> > +test_other_get_cmd(const struct fcntl_cmd_check *check)<br>
> > +{<br>
> > + long rc = invoke_test_syscall(check->fd, check->cmd, NULL);<br>
> > + printf("%s(%d, %s) = ",<br>
> > + TEST_SYSCALL_STR, check->fd, check->cmd_str);<br>
> > + print_retval_flags(check, rc);<br>
> > +<br>
> > + /* bad file fd */<br>
> > + invoke_test_syscall(-1, check->cmd, NULL);<br>
> > + printf("%s(-1, %s) = %s\n",<br>
> > + TEST_SYSCALL_STR, check->cmd_str, errstr);<br>
> > +}<br>
> > +<br>
> > +static void<br>
> > +print_flags_getfd(long rc)<br>
> > +{<br>
> > + assert(rc >= 0);<br>
> > + const char *text;<br>
> > + text = rc & 1 ? " (flags FD_CLOEXEC)" : "";<br>
> > + printf("%#lx%s", rc, text);<br>
> <br>
> This "text" variable looks redundant here.<br>
> <br>
> > +}<br>
> > +<br>
> > +static void<br>
> > +print_flags_getsig(long rc)<br>
> > +{<br>
> > + assert(rc >= 0);<br>
> > + const char *text;<br>
> > +<br>
> > + if (!rc) {<br>
> > + text = "";<br>
> <br>
> This assignment is redundant.<br>
> <br>
> > + printf("%ld", rc);<br>
> > + } else {<br>
> > + text = signal2name((int) rc);<br>
> > + printf("%ld (%s)", rc, text);<br>
> <br>
> This "text" variable looks redundant here.<br>
<br>
Is there any process with this?<br>
<br>
<br>
-- <br>
ldv<br>
</blockquote></div>