<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - static analyzer false positive: errno will always be nonzero after read(2) returns an error"
href="http://llvm.org/bugs/show_bug.cgi?id=18701">18701</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>static analyzer false positive: errno will always be nonzero after read(2) returns an error
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>kremenek@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nelhage@nelhage.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=11993" name="attach_11993" title="reproducer with false positive">attachment 11993</a> <a href="attachment.cgi?id=11993&action=edit" title="reproducer with false positive">[details]</a></span>
reproducer with false positive
the static analyzer doesn't understand that after read(2) returns an error,
errno will be set to a non-zero value.
In the attached test case, a helper function checks the return value of read(),
and returns 'errno' if read returns < 0. The static analyzer flags an error
that will happen if read() returns < 0, but errno == 0, which should never
happen in a conforming libc.
(c.f. SUSv3, which says of (pread,read):
"Upon successful completion, these functions shall return a non-negative
integer indicating the number of bytes actually read. Otherwise, the functions
shall return -1 and set errno to indicate the error."
and of (errno):
"No function in this volume of POSIX.1-2008 shall set errno to 0.")</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>