Boost C++ Libraries: Ticket #4573: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows previous 'result', declared at line 278 https://svn.boost.org/trac10/ticket/4573 <p> As of <a class="changeset" href="https://svn.boost.org/trac10/changeset/64932" title="Worked around annoying &#34;deprecated&#34; warnings on MSVC.">r64932</a> file boost/asio/detail/impl/socket_ops.ipp at function close, there is a declaration of 'int result' on line 315 that shadows a previous declaration of 'int result' on line 278. This causes warning C6246 from the Microsoft code analysis tool PREfast, because shadowing can often cause bugs or reduce maintainability. From inspection of the code, this particular construct guarantees that boost::asio::detail::socket_ops::close always returns 0, since the result initialized with a real value goes out of scope and the return statement then reads the result that was default-initialized to 0. </p> <p> Some call sites test the value of close, but most do not. In reactive_socket_service_base.ipp:67, the return value of close is used to decide whether to reconstruct the impl. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4573 Trac 1.4.3 chris_kohlhoff Sat, 16 Oct 2010 09:47:21 GMT <link>https://svn.boost.org/trac10/ticket/4573#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4573#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66008" title="Ensure close()/closesocket() failures are correctly propagated. Refs ...">[66008]</a>) Ensure close()/closesocket() failures are correctly propagated. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4573" title="#4573: Bugs: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows ... (closed: fixed)">#4573</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sun, 17 Oct 2010 12:25:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4573#comment:2 https://svn.boost.org/trac10/ticket/4573#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66037" title="Merge from trunk. ........ r65998 | chris_kohlhoff | 2010-10-16 ...">[66037]</a>) Merge from trunk. </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/65998" title="Make unit tests build faster. ">r65998</a> | chris_kohlhoff | 2010-10-16 15:30:12 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Make unit tests build faster. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66002" title="Add a test case for bug where a deadline timer never fires if the ...">r66002</a> | chris_kohlhoff | 2010-10-16 16:13:46 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add a test case for bug where a deadline timer never fires if the io_service is run in a background thread. N.B. fails only on platforms that use kqueue. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4568" title="#4568: Bugs: deadline_timer stop at boost-1.4.4 (closed: fixed)">#4568</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66004" title="Fix the way the kqueue_reactor is interrupted when a new timer is ...">r66004</a> | chris_kohlhoff | 2010-10-16 16:43:03 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix the way the kqueue_reactor is interrupted when a new timer is scheduled. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4568" title="#4568: Bugs: deadline_timer stop at boost-1.4.4 (closed: fixed)">#4568</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66005" title="Fix a const-correctness issue that prevents valid uses of ...">r66005</a> | chris_kohlhoff | 2010-10-16 17:27:45 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix a const-correctness issue that prevents valid uses of has_service&lt;&gt; from compiling. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4638" title="#4638: Bugs: Compile error using boost::asio::has_service() (closed: fixed)">#4638</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66006" title="Use lower-case to keep MinGW cross-compilers happy. Refs #4491. ">r66006</a> | chris_kohlhoff | 2010-10-16 18:06:18 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Use lower-case to keep MinGW cross-compilers happy. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4491" title="#4491: Bugs: asio : WinError.h case incorrect ? (closed: fixed)">#4491</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66007" title="Don't use deprecated system functions. Refs #4672. ">r66007</a> | chris_kohlhoff | 2010-10-16 18:24:47 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Don't use deprecated system functions. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4672" title="#4672: Bugs: asio uses deprecated functions from Boost.System (closed: fixed)">#4672</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66008" title="Ensure close()/closesocket() failures are correctly propagated. Refs ...">r66008</a> | chris_kohlhoff | 2010-10-16 20:47:11 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Ensure close()/closesocket() failures are correctly propagated. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4573" title="#4573: Bugs: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows ... (closed: fixed)">#4573</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66009" title="Check return code of InitializeCriticalSectionAndSpinCount. Refs #4574. ">r66009</a> | chris_kohlhoff | 2010-10-16 21:01:14 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Check return code of <a class="missing wiki">InitializeCriticalSectionAndSpinCount</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4574" title="#4574: Bugs: boost/asio/detail/impl/win_mutex.ipp:57: return value of ... (closed: fixed)">#4574</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66010" title="Add support for hardware flow control on QNX. Refs #4625. ">r66010</a> | chris_kohlhoff | 2010-10-16 22:04:08 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add support for hardware flow control on QNX. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4625" title="#4625: Patches: Can't set or unset serial hardware flow control on QNX (closed: fixed)">#4625</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66014" title="Always use pselect() on HP-UX, if it is available. Refs #4578. ">r66014</a> | chris_kohlhoff | 2010-10-16 22:39:13 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Always use pselect() on HP-UX, if it is available. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4578" title="#4578: Patches: asio: always use pselect() on hpux11.31 over select() (closed: fixed)">#4578</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66017" title="Ensure handler arguments are passed as lvalues. Refs #4744. ">r66017</a> | chris_kohlhoff | 2010-10-16 23:23:56 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Ensure handler arguments are passed as lvalues. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4744" title="#4744: Bugs: Some handler arguments are not passed as lvalues (closed: fixed)">#4744</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66018" title="Fix Windows build when thread support is disabled. Refs #4680. ">r66018</a> | chris_kohlhoff | 2010-10-16 23:39:06 +1100 (Sat, 16 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix Windows build when thread support is disabled. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4680" title="#4680: Bugs: error asio compilation with BOOST_ASIO_DISABLE_THREADS (closed: fixed)">#4680</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66020" title="Timers with expiry times set more than 5 minutes in the future need ...">r66020</a> | chris_kohlhoff | 2010-10-16 23:59:29 +1100 (Sat, 16 Oct 2010) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Timers with expiry times set more than 5 minutes in the future need the waitable timer to be periodic. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4745" title="#4745: Bugs: On Windows, timers that expire more than 5 minutes in the future may ... (closed: fixed)">#4745</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66035" title="Version bump. ">r66035</a> | chris_kohlhoff | 2010-10-17 22:33:28 +1100 (Sun, 17 Oct 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Version bump. </p> </blockquote> <p> ........ </p> Ticket