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

OESS-168: Remove clang warnings. #1129

Closed
wants to merge 1 commit into from

Conversation

hyoklee
Copy link
Member

@hyoklee hyoklee commented Oct 21, 2021

This will fix the following warning:

h5dumpgentest.c:10258:5: warning: cast from 'long double **' to 'long double *' increases required alignment from 8 to 16 [-Wcast-align]

@@ -210,7 +210,7 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
\
ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \
\
ARR[0] = (TYPE *)(ARR + (DIMS_I)); \
ARR[0] = (void *)(ARR + (DIMS_I)); \
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a place where the warning is easy to suppress but the alignment may still be wrong.

I believe DIMS_I and DIMS_J are constant. If so, then you can malloc a struct { TYPE *rows[DIMS_I]; TYPE values[DIMS_I * DIMS_J]; } *prototype;, initialize all DIMS_I pointers in rows, and then set ARR to &prototype->rows[0].

Copy link
Member

Choose a reason for hiding this comment

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

As in #1130, I agree with Dave. Casting to a void pointer to make the compiler quiet is probably not the best fix here.

gnuoyd added a commit that referenced this pull request Nov 8, 2021
…OLS];

}`.  This avoids the double-indirection through pointers and the
additional memory of H5TEST_ALLOCATE_2D_ARRAY().

This change will safely quiet the cast warning that PR #1129 was
intended to fix.
lrknox pushed a commit that referenced this pull request Nov 23, 2021
* Create 2D arrays on the heap by malloc'ing `struct { TYPE arr[ROWS][COLS];
}`.  This avoids the double-indirection through pointers and the
additional memory of H5TEST_ALLOCATE_2D_ARRAY().

This change will safely quiet the cast warning that PR #1129 was
intended to fix.

* Committing clang-format changes

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@gnuoyd
Copy link
Contributor

gnuoyd commented Jan 12, 2022

I believe #1169 fixed this?

@lrknox
Copy link
Collaborator

lrknox commented Jan 14, 2022

Fixed by #1169

@lrknox lrknox closed this Jan 14, 2022
@hyoklee hyoklee deleted the OESS-168-h5test.h branch July 14, 2022 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants