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

fix reading of byte-swapped input files (#95) #101

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/H5Zzfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,6 @@ get_zfp_info_from_cd_values(size_t cd_nelmts, unsigned int const *cd_values,

/* Do a read of *just* magic to detect possible codec version mismatch */
if (0 == (Z zfp_read_header(zstr, zfld, ZFP_HEADER_MAGIC)))
H5Z_ZFP_PUSH_AND_GOTO(H5E_PLINE, H5E_BADVALUE, 0, "ZFP codec version mismatch");
Z zfp_stream_rewind(zstr);

/* Now, read ZFP *full* header */
if (0 == (Z zfp_read_header(zstr, zfld, ZFP_HEADER_FULL)))
{
herr_t conv;

Expand All @@ -479,9 +474,14 @@ get_zfp_info_from_cd_values(size_t cd_nelmts, unsigned int const *cd_values,
H5Z_ZFP_PUSH_AND_GOTO(H5E_PLINE, H5E_BADVALUE, 0, "header endian-swap failed");

Z zfp_stream_rewind(zstr);
if (0 == (Z zfp_read_header(zstr, zfld, ZFP_HEADER_FULL)))
H5Z_ZFP_PUSH_AND_GOTO(H5E_PLINE, H5E_CANTGET, 0, "reading header failed");
if (0 == (Z zfp_read_header(zstr, zfld, ZFP_HEADER_MAGIC)))
H5Z_ZFP_PUSH_AND_GOTO(H5E_PLINE, H5E_CANTGET, 0, "ZFP codec version mismatch");
}
Z zfp_stream_rewind(zstr);

/* Now, read ZFP *full* header */
if (0 == (Z zfp_read_header(zstr, zfld, ZFP_HEADER_FULL)))
H5Z_ZFP_PUSH_AND_GOTO(H5E_PLINE, H5E_CANTGET, 0, "reading header failed");

/* Get ZFP stream mode and field meta */
*zfp_mode = Z zfp_stream_mode(zstr);
Expand Down