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

[native] Change C-style casts to C++-style #24237

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

jkhaliqi
Copy link
Contributor

@jkhaliqi jkhaliqi commented Dec 10, 2024

Description

As per the security guideline in
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast

Covers the findings in the list from this issue and
closes #2493

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== NO RELEASE NOTE ==

@jkhaliqi jkhaliqi requested a review from a team as a code owner December 10, 2024 21:32
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Dec 10, 2024
@prestodb-ci prestodb-ci requested review from a team, infvg and wanglinsong and removed request for a team December 10, 2024 21:32
@jkhaliqi jkhaliqi force-pushed the jk_cve branch 2 times, most recently from a3998f5 to 2507ca2 Compare December 10, 2024 22:07
@jkhaliqi jkhaliqi changed the title refactor: Change C-style casts to C++-style [native] Change C-style casts to C++-style Dec 10, 2024
@jkhaliqi jkhaliqi force-pushed the jk_cve branch 4 times, most recently from b902b86 to fd5d1eb Compare December 11, 2024 00:52
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @jkhaliqi. Had one comment about this change.

@@ -65,10 +65,10 @@ void toThrift(const std::vector<P>& p, std::vector<T>& t) {
}

void toThrift(const protocol::TaskState& proto, thrift::TaskState& thrift) {
thrift = (thrift::TaskState)((int)proto);
thrift = (thrift::TaskState)(static_cast<int>(proto));
Copy link
Contributor

@aditi-pandit aditi-pandit Dec 11, 2024

Choose a reason for hiding this comment

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

Should there be a static_cast from int -> thrift::TaskState enum as well ?

Same comment for the line below also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @aditi-pandit good catch, updated with the change, thank you!

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @jkhaliqi

mohsaka
mohsaka previously approved these changes Dec 13, 2024
Copy link
Contributor

@mohsaka mohsaka left a comment

Choose a reason for hiding this comment

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

LGTM

@prestodb-ci
Copy link

@ethanyzhang imported this issue into IBM GitHub Enterprise

@jkhaliqi jkhaliqi force-pushed the jk_cve branch 2 times, most recently from 67a80e5 to 9bb06f3 Compare January 14, 2025 19:08
@jkhaliqi jkhaliqi force-pushed the jk_cve branch 2 times, most recently from 158b1f8 to 2313697 Compare January 15, 2025 21:31
Copy link
Contributor

@aditi-pandit aditi-pandit Jan 16, 2025

Choose a reason for hiding this comment

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

This is a code generated file. We will have to change the code generation logic instead.

Please remove this file from the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, Added change to mustache file ProtocolToThrift-cpp.mustache thank you!

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @jkhaliqi

@aditi-pandit
Copy link
Contributor

@jkhaliqi : Lets wait until the builds pass to submit this code.

@aditi-pandit aditi-pandit merged commit 84c6730 into prestodb:master Jan 22, 2025
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:IBM PR from IBM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants