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

refactor: Change C style casts to C++ style (Part 4) #11687

Closed
wants to merge 1 commit into from
Closed

Conversation

aditi-pandit
Copy link
Collaborator

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 velox/functions

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 28, 2024
Copy link

netlify bot commented Nov 28, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit cf2510e
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6758070cf975d7000853ec06

@aditi-pandit aditi-pandit changed the title refactor : Change C-style casts to C++-style (Part 4) refactor: Change C style casts to C++ style (Part 4) Nov 28, 2024
@aditi-pandit aditi-pandit marked this pull request as ready for review December 2, 2024 18:20
@aditi-pandit
Copy link
Collaborator Author

Test failures related to #11721 mostly. Will rebase after that PR is submit.

@aditi-pandit aditi-pandit force-pushed the cve4 branch 2 times, most recently from ed180ee to 01e404f Compare December 5, 2024 15:43
sumC_ += (double)count;
sumCLogC_ += (double)count * std::log(count);
sumC_ += static_cast<double>(count);
sumCLogC_ += static_cast<double>(count * std::log(count));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be: static_cast<double>(count) * std::log(count);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch. Updated.

@@ -154,7 +154,7 @@ class ArrayWriterBenchmark : public functions::test::FunctionBenchmarkBase {
}

vector_size_t size = 1'000;
size_t totalItemsCount = (size) * (size + 1) / 2;
size_t totalItemsCount = static_cast<size_t>((size) * (size + 1) / 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess I have some questions around vector_size_t being int32_t. A vector access via [] operator or at would use a size_type parameter which is an unsigned integral type.
And the Velox vectors should work similar to std::vector in terms of access.

If it was unsigned then we could use implicit type conversion which still would work here I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not 100% sure but I generally thought it was that way to keep the sizes of vectors bounded in Velox. But yes, being consistent with std::vector access is a good idea.

Maybe open a discussion in Velox about it ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created #11816

Copy link
Collaborator

@majetideepak majetideepak left a comment

Choose a reason for hiding this comment

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

Thanks, @aditi-pandit

@majetideepak majetideepak added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Dec 10, 2024
@facebook-github-bot
Copy link
Contributor

@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Collaborator

@czentgr czentgr left a comment

Choose a reason for hiding this comment

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

Thanks!

@facebook-github-bot
Copy link
Contributor

@bikramSingh91 merged this pull request in 109ef3b.

@aditi-pandit aditi-pandit deleted the cve4 branch December 12, 2024 04:41
athmaja-n pushed a commit to athmaja-n/velox that referenced this pull request Jan 10, 2025
…or#11687)

Summary:
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 velox/functions

Pull Request resolved: facebookincubator#11687

Reviewed By: Yuhta

Differential Revision: D67060300

Pulled By: bikramSingh91

fbshipit-source-id: e127c7d36c3ef9248d2eb8fe0ae85d8f065871e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants