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

Fix coverity scan logically dead code #6451

Conversation

@fabriziomello fabriziomello added continuous_aggregate tech-debt Needs refactoring and improvement tasks related to the source code and its architecture. labels Dec 20, 2023
@fabriziomello fabriziomello self-assigned this Dec 20, 2023
Copy link

@erimatnor, @mkindahl: please review this pull request.

Powered by pull-review

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8ecce0d) 87.33% compared to head (a189989) 87.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6451      +/-   ##
==========================================
- Coverage   87.33%   87.33%   -0.01%     
==========================================
  Files         187      187              
  Lines       41846    41793      -53     
  Branches     9314     9292      -22     
==========================================
- Hits        36545    36498      -47     
+ Misses       3626     3620       -6     
  Partials     1675     1675              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jnidzwetzki jnidzwetzki left a comment

Choose a reason for hiding this comment

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

Added a comment that should be checked before merging. The rest looks good to me.

@@ -146,9 +139,6 @@ cagg_rebuild_view_definition(ContinuousAgg *agg, Hypertable *mat_ht, bool force_
&mataddress,
NameStr(mat_ht->fd.table_name));
}
else
view_query =
finalizequery_get_select_query(&fqi, mattblinfo.matcollist, &mataddress, relname);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering what happens in this case: Since we now remove the else statement, view_query could be uninitialized in line 149. If !agg->data.materialized_only in line 153 is also false, the variable stays uninitialized and we will access the NULL pointer in line 181.

Even if the condition is true, passing the uninitialized view_query to build_union_query looks suspicious. However, our test cases do not fail and these branches are marked as dead code. But could you double-check that this is not a problem before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will not happen because in the current logic the only way to this happen is if the finalized=false and in that case we are exiting earlier of the function emitting a warning message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway removed the branch because it become useless at this point.

@fabriziomello fabriziomello force-pushed the fix_coverityscan_logically_dead_code branch from b2d5f2c to a189989 Compare December 21, 2023 17:43
@fabriziomello fabriziomello merged commit 5e318c4 into timescale:main Dec 22, 2023
42 checks passed
@timescale-automation
Copy link

Automated backport to 2.13.x not done: cherry-pick failed.

Git status

HEAD detached at origin/2.13.x
You are currently cherry-picking commit 5e318c480.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tsl/src/continuous_aggs/repair.c

no changes added to commit (use "git add" and/or "git commit -a")

Job log

@timescale-automation timescale-automation added the auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) label Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) bug continuous_aggregate tech-debt Needs refactoring and improvement tasks related to the source code and its architecture.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants