-
Notifications
You must be signed in to change notification settings - Fork 191
Preclude C-style arrays #3251
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
base: dev
Are you sure you want to change the base?
Preclude C-style arrays #3251
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 106. Check the log or trigger a new build to see more.
| } | ||
| } else { | ||
| float p[3]; | ||
| std::array<float, 3> p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: uninitialized record type: 'p' [cppcoreguidelines-pro-type-member-init]
| std::array<float, 3> p; | |
| std::array<float, 3> p{}; |
| Raw::store_BE(pos[i], p, i); | ||
| VTKout.write((char *)p, 3 * sizeof(float)); | ||
| Raw::store_BE(pos[i], p.data(), i); | ||
| VTKout.write(reinterpret_cast<char *>(p.data()), sizeof(p)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
VTKout.write(reinterpret_cast<char *>(p.data()), sizeof(p));
^| int32_t buffer; | ||
| buffer = ByteOrder::BE<int32_t>(track.second - track.first); | ||
| VTKout.write((char *)&buffer, 1 * sizeof(int32_t)); | ||
| VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t));
^|
|
||
| buffer = ByteOrder::BE<int32_t>(track.first); | ||
| VTKout.write((char *)&buffer, 1 * sizeof(int32_t)); | ||
| VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t));
^| for (size_t i = track.first + 1; i < track.second; ++i) { | ||
| buffer = ByteOrder::BE<int32_t>(i); | ||
| VTKout.write((char *)&buffer, 1 * sizeof(int32_t)); | ||
| VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
VTKout.write(reinterpret_cast<char *>(&buffer), sizeof(int32_t));
^| extremum_values[axis][1] = vertices[i].dir[axis]; | ||
| extremum_indices[axis][1] = i; | ||
| if (vertices[i].dir[axis] > extremum_values(axis, 1)) { | ||
| extremum_values(axis, 1) = vertices[i].dir[axis]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
extremum_values(axis, 1) = vertices[i].dir[axis];
^| extremum_values[axis][1] = vertices[i].dir[axis]; | ||
| extremum_indices[axis][1] = i; | ||
| if (vertices[i].dir[axis] > extremum_values(axis, 1)) { | ||
| extremum_values(axis, 1) = vertices[i].dir[axis]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
extremum_values(axis, 1) = vertices[i].dir[axis];
^| extremum_indices[axis][1] = i; | ||
| if (vertices[i].dir[axis] > extremum_values(axis, 1)) { | ||
| extremum_values(axis, 1) = vertices[i].dir[axis]; | ||
| extremum_indices(axis, 1) = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
extremum_indices(axis, 1) = i;
^| for (size_t axis = 0; axis != 3; ++axis) { | ||
| all_extrema.push_back(extremum_indices[axis][0]); | ||
| all_extrema.push_back(extremum_indices[axis][1]); | ||
| all_extrema.push_back(extremum_indices(axis, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
all_extrema.push_back(extremum_indices(axis, 0));
^| all_extrema.push_back(extremum_indices[axis][0]); | ||
| all_extrema.push_back(extremum_indices[axis][1]); | ||
| all_extrema.push_back(extremum_indices(axis, 0)); | ||
| all_extrema.push_back(extremum_indices(axis, 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
all_extrema.push_back(extremum_indices(axis, 1));
^
Further extension of #3212.
Closes #3240.
There was a comment in #2665 that it would be preferable to avoid the use of C-style arrays, and it immediately occurred to me that we should be able to enforce this; as noted in #3243 this may not be an optimal solution, but it's possible, and I was having fun with regexes.
Note that there's a somewhat unrelated change hidden in here:
sh2peakswas using its own direction set, and in trying to refactor for this change it was vastly easier to instead make use of the internally-defined set. But this does mean that there's scope for the outcomes of that command to change; and also it may not be terribly discoverable being part of this PR. So it might be safer for me to create that in a standalone PR.