Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do_from_chars(): initialize variable to fix Coverity Scan warning #353

Merged
merged 1 commit into from
May 5, 2024

Conversation

rouault
Copy link
Contributor

@rouault rouault commented May 5, 2024

The argparse.hpp copy inside GDAL has caused Coverity Scan to emit a (false-positive) warning about x not being initialized.

________________________________________________________________________________________________________
*** CID 1544814:  Uninitialized variables  (UNINIT)
/gdal/apps/argparse/argparse.hpp: 257 in gdal_argparse::details::do_from_chars<unsigned char, (int)10>(std::basic_string_view<char, std::char_traits<char>>)()
251       if (ec == std::errc::invalid_argument) {
252         throw std::invalid_argument{"pattern '" + std::string(s) + "' not found"};
253       }
254       if (ec == std::errc::result_out_of_range) {
255         throw std::range_error{"'" + std::string(s) + "' not representable"};
256       }
>>>     CID 1544814:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "x".

Let's initialize it to 0 to make the analyzer happy

The argparse.hpp copy inside GDAL has caused Coverity Scan to emit a
(false-positive) warning about x not being initialized.

```
________________________________________________________________________________________________________
*** CID 1544814:  Uninitialized variables  (UNINIT)
/gdal/apps/argparse/argparse.hpp: 257 in gdal_argparse::details::do_from_chars<unsigned char, (int)10>(std::basic_string_view<char, std::char_traits<char>>)()
251       if (ec == std::errc::invalid_argument) {
252         throw std::invalid_argument{"pattern '" + std::string(s) + "' not found"};
253       }
254       if (ec == std::errc::result_out_of_range) {
255         throw std::range_error{"'" + std::string(s) + "' not representable"};
256       }
>>>     CID 1544814:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "x".
```

Let's initialize it to 0 to make the analyzer happy
@p-ranav p-ranav merged commit eba16b3 into p-ranav:master May 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants