<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 29, 2018 at 5:22 PM, Zhibin Li <span dir="ltr"><<a href="mailto:08826794brmt@gmail.com" target="_blank">08826794brmt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
 tests/fcntl.c | 41 ++++++++++++++++++++++++++++++<wbr>+++++++++++<br>
 1 file changed, 41 insertions(+)<br>
<br>
diff --git a/tests/fcntl.c b/tests/fcntl.c<br>
index 4f62ca2a..606f63bd 100644<br>
--- a/tests/fcntl.c<br>
+++ b/tests/fcntl.c<br>
@@ -69,12 +69,53 @@ test_flock64(void)<br>
 #endif<br>
 }<br>
<br>
+static long<br>
+test_f_owner_ex_type_pid(cons<wbr>t int cmd, const char *const cmd_name,<br>
+                        const int type, const char *const type_name,<br>
+                        const pid_t pid)<br>
+{<br>
+       struct f_owner_ex fo = { .type = type, .pid = pid };<br>
+<br>
+       long rc = invoke_test_syscall(cmd, &fo);<br>
+       printf("%s(0, %s, {type=%s, pid=%d}) = %s\n",<br>
+              TEST_SYSCALL_STR, cmd_name, type_name, pid, sprintrc(rc));<br>
+       return rc;<br>
+}<br>
+<br>
+static void<br>
+is_esrch_test_f_owner_ex(cons<wbr>t int type, const char *const type_name,<br>
+                        pid_t pid, bool is_esrch)<br>
+{<br>
+       if (is_esrch) {<br>
+               test_f_owner_ex_type_pid(ARG_<wbr>STR(F_SETOWN_EX),<br>
+                                        type, type_name, pid);<br>
+       } else {<br>
+               if (test_f_owner_ex_type_pid(ARG_<wbr>STR(F_SETOWN_EX),<br>
+                                            type, type_name, pid))<br>
+                       return;<br>
+               test_f_owner_ex_type_pid(ARG_<wbr>STR(F_GETOWN_EX),<br>
+        </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">                                type, type_name, pid);<br>
+       }<br>
+}<br></blockquote><div>According to Dmitry's advice, I use this function instead of a piece of duplicate code.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+static void<br>
+test_f_owner_ex(void)<br>
+{<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_TID), 1234567890, true);<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_PID), 1298126790, true);<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_PGRP), 1294567890, true);<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_TID), 20, false);<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_PID), 30, false);<br>
+       is_esrch_test_f_owner_ex(ARG_<wbr>STR(F_OWNER_PGRP), 40, false);<br></blockquote><div>Since the function  <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">is_esrch_test_f_owner_ex is called many times(duplication?), I don't know whether</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">it would be better to user a macro now such as:</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><pre>define IS_ESRCH_TEST_F_OWNER_EX_ESRCH(cmd) is_esrch_test_f_owner_ex_esrch(cmd, #cmd)</pre>Beside, I want to to know how to locate indentation problems(or similar things) before I send patches?</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I did find something in README-hacking but when I use this:</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">git -c core.whitespace=space-before-tab,trailing-space diff-index \<br></span></div><div><span style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">--check 4b825dc642cb6eb9a060e54bf8d69288fbee4904<br></span></div><div><br></div><div>I didn't find the indentation problems in my former patch(v2) so I guess I'm getting into the wrong direction.</div><div>Anyone can help?</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+}<br>
+<br>
 int<br>
 main(void)<br>
 {<br>
        create_sample();<br>
        test_flock();<br>
        test_flock64();<br>
+       test_f_owner_ex();<br>
<br>
        puts("+++ exited with 0 +++");<br>
        return 0;<br>
<span class="gmail-m_4701106695908525776HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>