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

lint: fix cppcheck lint errors #587

Merged
merged 9 commits into from
Jul 28, 2024

Conversation

benoit-pierre
Copy link
Contributor

@benoit-pierre benoit-pierre commented Jul 28, 2024

Most of them.


This change is Reviewable

Comment out unused & problematic code:
```
crengine/include/lvref.h:395:16: warning: Reference to temporary returned. [returnTempReference]
   return LVRef(NULL);
               ^
crengine/include/lvref.h:396:15: warning: Reference to temporary returned. [returnTempReference]
  return LVRef( new T( *_ptr ) );
```
```
warning: Rethrowing current exception with 'throw;', it seems there is no current
exception to rethrow. If there is no current exception this calls std::terminate().
```
NOTE: only when compiling without ZSTD support.
```
lvxml.cpp|6166 col 42| warning: Uninitialized variable: quote [uninitvar]
    int endpos = encname.pos(quote);

lvxml.cpp|6159 col 28| note: Assuming condition is false
    while (pos < end) {

lvxml.cpp|6166 col 42| note: Uninitialized variable: quote
    int endpos = encname.pos(quote);
```
Comment on lines -6165 to +6161
lString8 encname = s.substr(pos + 1, 20 );
int endpos = encname.pos(quote);
if ( endpos>0 ) {
encname.erase( endpos, encname.length() - endpos );
lString32 enc32(encname.c_str());
SetCharset(enc32.c_str());
endpos = s.pos(s[startpos], startpos + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is ok scanning up to m_buf_len instead of previously 20. We should find that quote soon, and if not the HTML is crap. This is called for each xhtml fragment.
And we already scan the full string for "encoding".

@poire-z poire-z merged commit 159aeef into koreader:master Jul 28, 2024
1 check failed
@benoit-pierre benoit-pierre deleted the pr/fix_cppcheck_lint_errors branch July 28, 2024 08:21
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