<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">CCing cfe-dev because somehow I forgot to the first time around.<div><br><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: [cfe-dev] Opinion on Analyzer false positive</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">October 24, 2012 at 13:55:53 PDT<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Erik Cederstrand <<a href="mailto:erik@cederstrand.dk">erik@cederstrand.dk</a>><br></span></div><br><div><br>On Oct 24, 2012, at 13:31 , Erik Cederstrand <<a href="mailto:erik@cederstrand.dk">erik@cederstrand.dk</a>> wrote:<br><br><blockquote type="cite">Hi guys,<br><br>The Static Analyzer spits out this report on some ZFS code <a href="http://scan.freebsd.your.org/freebsd-head/WORLD/2012-10-24-amd64/report-uH6BjZ.html#EndPath">http://scan.freebsd.your.org/freebsd-head/WORLD/2012-10-24-amd64/report-uH6BjZ.html#EndPath</a><br><br>The code is OK in my opinion because the default return value for getopt(3) is '?': <a href="http://www.unix.com/man-page/posix/3posix/getopt/">http://www.unix.com/man-page/posix/3posix/getopt/</a><br><br>I could change the '?' case to 'default:' but this is a pretty common pattern (plus, it's not our own code). Is it possible to create a special case for getopt() in the Analyzer? It would require splitting the input string to getopt() to restrict the possible return values of getopt().<br></blockquote><br>This is definitely theoretically possible - a postCall check on getopt to assert that certain return values are impossible, based on the input string. Patches welcome. ;-)<br><br>Meanwhile, you (or the author) can put assert(false) or __builtin_unreachable in a default case to satisfy the analyzer.<br><br>Jordan</div></blockquote></div><br></div></body></html>