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

Backport fix for Unidata/netcdf-c#2674 #2

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ ARG NETCDF_VERSION
ENV NETCDF_VERSION="${NETCDF_VERSION:-4.9.2}"
ENV NETCDF_SRC_DIR="/usr/local/src/netcdf-c-${NETCDF_VERSION}"
RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \
--mount=target="${NETCDF_SRC_DIR}/patches",type=bind,source=./patches/netcdf-c \
if [ ! -f "${NETCDF_SRC_DIR}/configure" ]; then \
wget -O - https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NETCDF_VERSION}.tar.gz | tar -xz -C /usr/local/src/; \
cd "${NETCDF_SRC_DIR}" ; \
patch -p1 < "./patches/0001-Fix-issue-2674.patch" ; \
fi
RUN --mount=target="${NETCDF_SRC_DIR}",type=cache,sharing=locked \
cd "${NETCDF_SRC_DIR}" \
Expand Down
53 changes: 53 additions & 0 deletions patches/netcdf-c/0001-Fix-issue-2674.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Subject: [PATCH] Fix issue #2674

---
libhdf5/hdf5open.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c
index cb2491ff..e00f426e 100644
--- a/libhdf5/hdf5open.c
+++ b/libhdf5/hdf5open.c
@@ -1205,12 +1205,14 @@ static int get_quantize_info(NC_VAR_INFO_T *var)
{
hid_t attid;
hid_t datasetid;
+ htri_t attr_exists;

/* Try to open an attribute of the correct name for quantize
* info. */
datasetid = ((NC_HDF5_VAR_INFO_T *)var->format_var_info)->hdf_datasetid;
- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITGROOM_ATT_NAME);
+ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITGROOM_ATT_NAME,
+ H5P_DEFAULT, H5P_DEFAULT) : 0;

if (attid > 0)
{
@@ -1218,16 +1220,18 @@ static int get_quantize_info(NC_VAR_INFO_T *var)
}
else
{
- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_GRANULARBR_ATT_NAME);
+ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_GRANULARBR_ATT_NAME,
+ H5P_DEFAULT, H5P_DEFAULT) : 0;
if (attid > 0)
{
var->quantize_mode = NC_QUANTIZE_GRANULARBR;
}
else
{
- attid = H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr_exists = H5Aexists(datasetid, NC_QUANTIZE_BITROUND_ATT_NAME);
+ attid = attr_exists ? H5Aopen_by_name(datasetid, ".", NC_QUANTIZE_BITROUND_ATT_NAME,
+ H5P_DEFAULT, H5P_DEFAULT) : 0;
if (attid > 0)
var->quantize_mode = NC_QUANTIZE_BITROUND;
}
--
2.39.1