<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 020/11/8 0:55, Petr Vorel wrote:
<blockquote cite="mid:20201107165518.GB10159@pevik" type="cite">
<pre wrap="">Hi,
</pre>
<blockquote type="cite">
<pre wrap="">On 11/7/20 12:47 AM, Cyril Hrubis wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi!
</pre>
<blockquote type="cite">
<pre wrap="">I have a doubt after reading Xu's patch[1] and Martin's patch[2]:
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">1) Xu removed sync01 because sync() always return 0.
</pre>
</blockquote>
<pre wrap="">Actually sync() is defined as void function, so the tests were bogusly
checking the TST_RET value which haven't been set at all.
</pre>
</blockquote>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Hi Cyril,
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Oops, I gave a wrong example. :-(
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">On error, I just wonder if we need to check all return value(i.e. negative
value except -1).
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">IOW, Is it possible for syscall to get a error value which is not -1?
</pre>
</blockquote>
<pre wrap="">There are probably other examples, but I've found only these:
man malloc_get_state(3)
If the implementation detects that state does not point to a correctly
formed data structure, malloc_set_state() returns -1.
If the implementation detects that the version of the data structure
referred to by state is a more recent version than this implementation knows
about, malloc_set_state() returns -2.
man mmap(2)
On error, the value MAP_FAILED (that is, (void *) -1) is returned.
</pre>
</blockquote>
Hi,<br>
<br>
Sorry, I didn't describe the doubt clearly.<br>
For example:<br>
1) open(2) will return -1 if an error occur.<br>
Is it necessary to check invalid return value(except -1) if an
error occur?<br>
2) mmap(2) will return MAP_FAILED if an error occurs.<br>
Is it necessary to check invalid value(except MAP_FAILED) if an
error occur?<br>
Martin's patches have added a check for invalid return value in many
safe macros but a lot of syscall tests(e.g. after doingTEST()) don't
add the check for now.<br>
I am not sure if we need to add the check for all syscall tests. <span
class="moz-smiley-s1"><span> :-) </span></span><br>
BTW: In my opinion, <span style="display: inline ! important;
float: none; background-color: rgb(255, 255, 255); color: rgb(51,
51, 51); font: 13px/21px Arial,sans-serif; letter-spacing: normal;
orphans: 2; text-align: left; text-decoration: none; text-indent:
0px; text-transform: none; white-space: normal; word-spacing:
0px;"></span>it is hardly to get invalid return value so the check
seems unnecessary and redundance.<br>
<br>
Best Regards,<br>
Xiao Yang<br>
<blockquote cite="mid:20201107165518.GB10159@pevik" type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Best Regards,
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Xiao Yang
</pre>
</blockquote>
<pre wrap="">
Kind regards,
Petr
</pre>
</blockquote>
<br>
</body>
</html>