<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95638>95638</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            libc/src/stdio/printf_core/float_dec_converter.h:505: Possible poor error checking ?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            code-quality,
            libc
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dcb314
      </td>
    </tr>
</table>

<pre>
    Static analyser cppcheck says:

libc/src/stdio/printf_core/float_dec_converter.h:505:23: style: Unsigned expression 'positive_blocks' can't be negative so it is unnecessary to test it. [unsignedPositive]

Source code is

  const size_t positive_blocks = float_converter.get_positive_blocks();

  if (positive_blocks >= 0) {

In a strict sense, the static analyser is correct and the test looks pointless and
so could be deleted.

A deeper analysis suggests that get_positive_blocks *might* return 0 on error
and so the if test is doing some poor error checking and so the it should be

  if (positive_block > 0) {

Someone with more knowledge of the code would be able to offer a better opinion.

git blame says Jonas Hahnfeld last changed the code in commit 99b5474310,
but git blame frequently lies with shallow copies ;-<

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVEFv6zYM_jXKhWjgSHbjHHxIXxdsOz2g2DmQJdrWKot-It0u-_WDnQxtXwvssItsmObH7_tI0TKHPiE2qnpQ1ePGzjJQbrxrza7ctOQvzZNYCQ5ssvHCmMFNkxvQPQPbCytzVMWjKm5nDK1T-sR5PcUHUvo05ZCkOzvKqPSpi2Tl7NGdHaUXzIJ5OyhzrIpKmaM2yhyB5RJxefkjrfQ84F9TRuZACZTeT8RBwgue20jumZXeg7NJ6b1Ai5Cwt0sUmCAIBIY5JXTIbPMFhECQBYJsQVUP863C9xukqh7fC3qiOTsERx4h8PsIgKPEAhz-xrPAT5RAmUe4Sn2T2aOcP1GvlT4o8_AROnSgdP0Z85cFtlD6AGr_IeW3BBZYcnACjIlR6W8gAwL_1L3A4ChndAI2-fWX1Y5I9MwwUUgSkXkJXpGZwNEc_eKsx4iCfvu-8hE84oT5ViIw8Nz3yMIggxX4QjQofRxDP4jSR8goc05QACXAnClfYRdyTCu_0N06xuAppB6YRoSJKF8TYB3HJfA-SYCHG-__9nax9ktfn2hESgivQQYYKSM8J3qN6HsE6tZK62y8_muRbSMuM0Zdt3gCLYpgBppCCpQ-ONcHgTbaEdebBL9Tsgy_2iF1GD1EywJusKlH_1YnJHA0jkHgcGircl-aXaH0tytgOwu8gXYZf8yYJF4gBuSrBB5sjPQKjqblmzIPd8rc0je-Mf5gDnaDzW6_q0tTVeVhMzSVqcrOVbaud-2uqvHgTFffV9o6v-tcqzeh0YUui_tdVex3WtdbW9atRt92pd7XrjOqLHC0IW5jfBm3lPtNYJ6xOVT3pt5E22LkdQVpvci8-zHbGOSitF7EaX3dK3rZULlZMO7auWdVFjGw8BuqBInY_O8tBN-JOSyd_GrKlDlt5hybQWRaF6A-KX3qgwxzu3U0Kn1aCN0ed1OmP9GJ0qdVMyt9usp-afQ_AQAA__85Gs6q">