Skip to content

Conversation

@Lestropie
Copy link
Member

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: sh2peaks was 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.

Copy link

@github-actions github-actions bot left a 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;
Copy link

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]

Suggested change
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));
Copy link

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));
Copy link

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));
Copy link

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));
Copy link

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];
Copy link

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];
Copy link

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;
Copy link

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));
Copy link

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));
Copy link

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));
                                           ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants