Source: libminc
Version: 2.3.00-3
Severity: important

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Please find attached a patch to support building against HDF5-1.10 currently in 
experimental. This patch is a backport of two upstream commits related to 
hdf5-1.10 support. Please see upstream ticket #74 [1].

[1] https://github.com/BIC-MNI/libminc/issues/74

I intend to request a transition slot this week, and will NMU if need be.

Thanks,

_g.

- -- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

-----BEGIN PGP SIGNATURE-----

iQEcBAEBCAAGBQJYDnQdAAoJEO/obGx//s+DMucIAKfPWkyHBDzPJIaB4OCqp6dk
kwZPq8YbvikQL+y71IXLDNncxytiqQpakbLHhcokK/+DqZu6c5j1tNOnQTRvgaXc
oCfLd4Fh5/bYtAGs1TtnCw0FEje3qUtA4in4TEy9lKcuXwVHYrrFOxqiv1N4Xznj
GbpvIEjM1nR4IIP2s4zs0ZM0Q437bEV6rZejWnKypB9AlHAQafx2Cf/zG82oYlHX
AlqnjUJW3Uoc0IBe6RvOFvt8LHG1vm8HSy+zQBeLGGCoC8b5qc7xiCQVu01G5+sR
eocifRf60srli2i4sB0uUsDE1EpE6D+jBRQY/Kw6QNSqbO2g7x5dNvT8BC2zgoA=
=JOhL
-----END PGP SIGNATURE-----
diff -Nru libminc-2.3.00/debian/changelog libminc-2.3.00/debian/changelog
--- libminc-2.3.00/debian/changelog	2016-09-02 09:40:37.000000000 +0200
+++ libminc-2.3.00/debian/changelog	2016-10-20 19:31:12.000000000 +0200
@@ -1,3 +1,10 @@
+libminc (2.3.00-3.1) unstable; urgency=medium
+
+  * Non-maintainer upload
+  * New patch to support HDF5 1.10
+
+ -- Gilles Filippini <p...@debian.org>  Thu, 20 Oct 2016 19:31:10 +0200
+
 libminc (2.3.00-3) unstable; urgency=medium
 
   * Wrote watch file
diff -Nru libminc-2.3.00/debian/patches/hdf5-1.10-support.patch libminc-2.3.00/debian/patches/hdf5-1.10-support.patch
--- libminc-2.3.00/debian/patches/hdf5-1.10-support.patch	1970-01-01 01:00:00.000000000 +0100
+++ libminc-2.3.00/debian/patches/hdf5-1.10-support.patch	2016-10-20 20:37:42.000000000 +0200
@@ -0,0 +1,451 @@
+Description: don't assume hid_t === int since this is no longer true
+ in HDF5 1.10.
+ This is a backport of upstream commits d99dd01 and 92ba4fa related
+ to issue #74 [1].
+ .
+ [1] https://github.com/BIC-MNI/libminc/issues/74
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -45,7 +45,8 @@ struct m2_dim {
+ 
+ static struct m2_file {
+     struct m2_file *link;
+-    hid_t fd;
++    int   fd;                   /* our fake file id */
++    hid_t file_id;              /* actual hdf5 file id */
+     int wr_ok;                  /* non-zero if write OK */
+     int resolution;		/* Resolution setting. */
+     int nvars;
+@@ -74,18 +75,20 @@ hdf_id_check(int fd)
+ }
+ 
+ static struct m2_file *
+-hdf_id_add(int fd)
++hdf_id_add(hid_t file_id)
+ {
+     struct m2_file *new;
++    static unsigned short _id = 0;       /* at most 2^16 id's */
+ 
+     new = (struct m2_file *) malloc(sizeof (struct m2_file));
+     if (new != NULL) {
+-	new->fd = fd;
++        new->fd = HDF5_ID_MIN + _id++;
++        new->file_id = file_id;
+ 	new->resolution = 0;
+ 	new->nvars = 0;
+ 	new->ndims = 0;
+ 	new->link =_m2_list;
+-        new->grp_id = H5Gopen1(fd, MI2_GRPNAME);
++        new->grp_id = H5Gopen1(file_id, MI2_GRPNAME);
+         new->comp_type = MI2_COMP_UNKNOWN;
+         new->comp_param = 0;
+         new->chunk_type = MI2_CHUNK_UNKNOWN;
+@@ -99,7 +102,7 @@ hdf_id_add(int fd)
+     return (new);
+ }
+ 
+-static int 
++static int
+ hdf_id_del(int fd)
+ {
+     struct m2_file *curr, *prev;
+@@ -142,6 +145,7 @@ hdf_id_del(int fd)
+ 	    }
+ 
+             H5Gclose(curr->grp_id);
++            H5Fclose(curr->file_id);
+ 	    free(curr);
+ 	    return (MI_NOERROR);
+ 	}
+@@ -187,7 +191,7 @@ hdf_var_add(struct m2_file *file, const
+       strncpy(new->name, name, NC_MAX_NAME - 1);
+       strncpy(new->path, path, NC_MAX_NAME - 1);
+       new->is_cmpd = 0;
+-      new->dset_id = H5Dopen1(file->fd, path);
++      new->dset_id = H5Dopen1(file->file_id, path);
+       new->ftyp_id = H5Dget_type(new->dset_id);
+       new->mtyp_id = H5Tget_native_type(new->ftyp_id, H5T_DIR_ASCEND);
+       new->fspc_id = H5Dget_space(new->dset_id);
+@@ -490,7 +494,7 @@ hdf_attinq(int fd, int varid, const char
+       return (MI_ERROR);
+   }
+ 
+-  if (varid == NC_GLOBAL) {
++  if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+       var = NULL;
+       loc_id = file->grp_id;
+   } 
+@@ -591,7 +595,7 @@ hdf_attinq(int fd, int varid, const char
+ }
+ 
+ static int
+-hdf_put_dimorder(struct m2_file *file, int dst_id, int ndims, 
++hdf_put_dimorder(struct m2_file *file, hid_t dst_id, int ndims, 
+ 		 const int *dims_ptr)
+ {
+     int i;
+@@ -626,6 +630,9 @@ hdf_put_dimorder(struct m2_file *file, i
+     if (att_id >= 0) {
+ 	H5Awrite(att_id, typ_id, str_buf);
+     }
++    else {
++      fprintf(stderr, "Failed to create dimorder %lx\n", dst_id);
++    }
+   
+     H5Aclose(att_id);
+     H5Sclose(spc_id);
+@@ -634,7 +641,7 @@ hdf_put_dimorder(struct m2_file *file, i
+ }
+ 
+ static int 
+-hdf_get_dimorder(struct m2_file *file, int dst_id, int ndims, int *dims_ptr)
++hdf_get_dimorder(struct m2_file *file, hid_t dst_id, int ndims, int *dims_ptr)
+ {
+     char *str_ptr;
+     char *tmp_ptr;
+@@ -974,7 +981,7 @@ hdf_attget(int fd, int varid, const char
+         return (MI_ERROR);
+     }
+ 
+-    if (varid == NC_GLOBAL) {
++    if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+         var = NULL;
+         loc_id = file->grp_id;
+     } 
+@@ -1120,11 +1127,11 @@ hdf_attput(int fd, int varid, const char
+             H5Pclose(new_plst_id);
+             H5Sclose(var->fspc_id);
+ 
+-            if (H5Gunlink(fd, var->path) < 0) {
++            if (H5Gunlink(file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+-            if (H5Gmove2(file->grp_id, temp, fd, var->path) < 0) {
++            if (H5Gmove2(file->grp_id, temp, file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+@@ -1196,7 +1203,7 @@ hdf_attput(int fd, int varid, const char
+     att_id = H5Acreate2(loc_id, attnm, ftyp_id, spc_id, H5P_DEFAULT, H5P_DEFAULT);
+     
+     if (att_id < 0)
+-        goto cleanup;
++      goto cleanup;
+ 
+     /* Save the value.
+     */
+@@ -1261,10 +1268,10 @@ int
+ hdf_vardef(int fd, const char *varnm, nc_type vartype, int ndims, 
+            const int *dimids)
+ {
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int spc_id = -1;
+-    int prp_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t spc_id = -1;
++    hid_t prp_id = -1;
+     int status = MI_ERROR;
+     int i;
+     long length;
+@@ -1392,7 +1399,7 @@ hdf_vardef(int fd, const char *varnm, nc
+     }
+     
+     H5E_BEGIN_TRY {
+-        dst_id = H5Dcreate2(fd, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
++        dst_id = H5Dcreate2(file->file_id, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
+     } H5E_END_TRY;
+ 
+     if (dst_id < 0) {
+@@ -1465,10 +1472,10 @@ hdf_varget(int fd, int varid, const long
+ 	   void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id = -1;
+-  int typ_id = -1;
+-  int fspc_id = -1;
+-  int mspc_id = -1;
++  hid_t dst_id = -1;
++  hid_t typ_id = -1;
++  hid_t fspc_id = -1;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -1560,8 +1567,8 @@ hdf_varget(int fd, int varid, const long
+ }
+ 
+ int 
+-hdf_varputg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_varputg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, const void *value)
+ {
+     int status = MI_ERROR;      /* Assume guilty */
+@@ -1577,10 +1584,10 @@ hdf_varputg(int fd, int varid, const lon
+ 
+     struct m2_var *varp;
+     struct m2_file *file;
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int fspc_id = -1;
+-    int mspc_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t fspc_id = -1;
++    hid_t mspc_id = -1;
+ 
+     if ((file = hdf_id_check(fd)) == NULL) {
+ 	return (MI_ERROR);
+@@ -1747,8 +1754,8 @@ hdf_varputg(int fd, int varid, const lon
+ }
+ 
+ int 
+-hdf_vargetg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_vargetg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, void *value)
+ {
+     int status = MI_NOERROR;
+@@ -1910,10 +1917,10 @@ hdf_varput(int fd, int varid, const long
+ 	   const void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id;
+-  int typ_id;
+-  int fspc_id;
+-  int mspc_id = -1;
++  hid_t dst_id;
++  hid_t typ_id;
++  hid_t fspc_id;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -2085,6 +2092,7 @@ herr_t hdf_copy_attr(hid_t in_id, const
+       * don't overwrite the existing value.
+       */
+      status = MI_NOERROR;
++     fprintf(stderr, "Failed to create attribute '%s'\n", attr_name);
+      goto cleanup;
+    }
+    
+@@ -2195,7 +2203,7 @@ hdf_open_dsets(struct m2_file *file, hid
+ int
+ hdf_open(const char *path, int mode)
+ {
+-    hid_t fd;
++    hid_t file_id;
+     hid_t grp_id;
+     hid_t dset_id;
+     struct m2_file *file;
+@@ -2210,28 +2218,28 @@ hdf_open(const char *path, int mode)
+ 
+             prp_id = H5Pcreate(H5P_FILE_ACCESS);
+             H5Pset_fapl_mmap(prp_id, 8192, 1);
+-            fd = H5Fopen(path, mode & 0x7FFF, prp_id);
++            file_id = H5Fopen(path, mode & 0x7FFF, prp_id);
+             H5Pclose(prp_id);
+         }
+         else {
+-            fd = H5Fopen(path, mode, H5P_DEFAULT);
++            file_id = H5Fopen(path, mode, H5P_DEFAULT);
+         }
+ #else
+-        fd = H5Fopen(path, mode, H5P_DEFAULT);
++        file_id = H5Fopen(path, mode, H5P_DEFAULT);
+ #endif
+     } H5E_END_TRY;
+ 
+-    if (fd < 0) {
++    if (file_id < 0) {
+       return (MI_ERROR);
+     }
+ 
+-    file = hdf_id_add(fd);	/* Add it to the list */
++    file = hdf_id_add(file_id);	/* Add it to the list */
+     file->wr_ok = (mode & H5F_ACC_RDWR) != 0;
+ 
+     /* Open the image variables.
+      */
+     H5E_BEGIN_TRY {
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image");
+         if (dset_id >= 0) {
+             hid_t type_id;
+             int is_compound = 0;
+@@ -2262,7 +2270,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+     
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-min");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-min");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemin, "/minc-2.0/image/0/image-min", 
+@@ -2270,7 +2278,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+ 
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-max");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-max");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemax, "/minc-2.0/image/0/image-max", 
+@@ -2281,16 +2289,16 @@ hdf_open(const char *path, int mode)
+ 
+     /* Open all of the datasets in the "dimensions" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/dimensions", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/dimensions", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/dimensions/", 1);
+     H5Gclose(grp_id);
+ 
+     /* Open all of the datasets in the "info" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/info", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/info", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/info/", 0);
+     H5Gclose(grp_id);
+-    return (fd);
++    return (file->fd);
+ }
+ 
+ /** Create an HDF5 file. */
+@@ -2298,7 +2306,7 @@ int
+ hdf_create(const char *path, int cmode, struct mi2opts *opts_ptr)
+ {
+     hid_t grp_id;
+-    hid_t fd;
++    hid_t file_id;
+     hid_t tmp_id;
+     struct m2_file *file;
+     hid_t hdf_gpid;
+@@ -2319,10 +2327,10 @@ hdf_create(const char *path, int cmode,
+     H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);
+ 
+     H5E_BEGIN_TRY {
+-        fd = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
++        file_id = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
+     } H5E_END_TRY;
+-    if (fd < 0) {
+-      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, fd);
++    if (file_id < 0) {
++      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, (int)file_id);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+     }
+@@ -2332,7 +2340,7 @@ hdf_create(const char *path, int cmode,
+     /* Create the default groups.
+      * Should we use a non-zero value for size_hint (parameter 3)???
+      */
+-    if ((grp_id = H5Gcreate2(fd, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
++    if ((grp_id = H5Gcreate2(file_id, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
+       fprintf(stderr, "Error creating groups on line %d\n", __LINE__);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+@@ -2369,7 +2377,7 @@ hdf_create(const char *path, int cmode,
+     H5Gclose(tmp_id);
+     H5Gclose(grp_id);
+ 
+-    file = hdf_id_add(fd);      /* Add it to the list */
++    file = hdf_id_add(file_id); /* Add it to the list */
+     if (file == NULL) {
+         fprintf(stderr, "Error adding ID to list.\n");
+         H5Eprint1(stderr);
+@@ -2384,7 +2392,7 @@ hdf_create(const char *path, int cmode,
+         file->chunk_type = opts_ptr->chunk_type;
+         file->chunk_param = opts_ptr->chunk_param;
+     }
+-    return ((int) fd);
++    return (file->fd);
+ }
+ 
+ int
+@@ -2392,7 +2400,6 @@ hdf_close(int fd)
+ {
+     hdf_dim_commit(fd);         /* Make sure all dimensions were saved. */
+     hdf_id_del(fd);		/* Delete it from the list. */
+-    H5Fclose(fd);
+     return (MI_NOERROR);
+ }
+ 
+@@ -2412,4 +2419,22 @@ hdf_access(const char *path)
+     return (status > 0);        /* Return non-zero if success */
+ }
+ 
++/*
++ * Flushes the hdf file to disk
++ */
++int 
++hdf_flush(int fd)
++{
++    struct m2_file *file;
++    if ((file = hdf_id_check(fd))!=NULL ) {
++        /* Commit the (entire) file to disk. */
++        if (H5Fflush(file->file_id, H5F_SCOPE_GLOBAL) < 0) {
++            return MI_ERROR;
++        }
++        return MI_NOERROR;
++    }
++    return MI_ERROR;
++}
++
++
+ #endif /* MINC2 defined */
+Index: libminc-2.3.00/libsrc/hdf_convenience.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.h
++++ libminc-2.3.00/libsrc/hdf_convenience.h
+@@ -49,4 +49,5 @@ extern int hdf_open(const char *path, in
+ extern int hdf_create(const char *path, int mode, struct mi2opts *opts_ptr);
+ extern int hdf_close(int fd);
+ extern int hdf_access(const char *path);
++extern int hdf_flush(int fd);
+ 
+Index: libminc-2.3.00/libsrc/minc_compat.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc_compat.c
++++ libminc-2.3.00/libsrc/minc_compat.c
+@@ -358,14 +358,9 @@ MI2redef(int fd)
+ MNCAPI int
+ MI2sync(int fd)
+ {
+-    if (MI2_ISH5OBJ(fd)) {
++    if (MI2_ISH5OBJ(fd) ) {
+         /* Commit the (entire) file to disk. */
+-        if (H5Fflush(fd, H5F_SCOPE_GLOBAL) < 0) {
+-            return (MI_ERROR);
+-        }
+-        else {
+-            return (MI_NOERROR);
+-        }
++        return hdf_flush(fd);
+     }
+     else {
+         return (ncsync(fd));
+Index: libminc-2.3.00/libsrc/minc.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc.h
++++ libminc-2.3.00/libsrc/minc.h
+@@ -617,7 +617,13 @@ struct mi2opts {
+     int chunk_param;
+ };
+ 
+-#define MI2_ISH5OBJ(x) (H5Iget_type(x) > 0)
++/* This is hackish in that it assumes that all NetCDF handles returned
++ * by ncopen/nccreate will be small integers. Historically this is
++ * true, but it could break someday. We used to use an HDF5 call, but
++ * that broke when HDF5 switched from 32 to 64 bits for hid_t.
++ */
++#define HDF5_ID_MIN 0x30000000
++#define MI2_ISH5OBJ(x) (x >= HDF5_ID_MIN)
+ 
+ MNCAPI int micreatex(const char *path, int cmode, struct mi2opts *opts_ptr);
+ 
diff -Nru libminc-2.3.00/debian/patches/libhdf5-1.10.patch libminc-2.3.00/debian/patches/libhdf5-1.10.patch
--- libminc-2.3.00/debian/patches/libhdf5-1.10.patch	1970-01-01 01:00:00.000000000 +0100
+++ libminc-2.3.00/debian/patches/libhdf5-1.10.patch	2016-10-20 19:29:50.000000000 +0200
@@ -0,0 +1,26 @@
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -74,7 +74,7 @@ hdf_id_check(int fd)
+ }
+ 
+ static struct m2_file *
+-hdf_id_add(int fd)
++hdf_id_add(hid_t fd)
+ {
+     struct m2_file *new;
+ 
+Index: libminc-2.3.00/libsrc/netcdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/netcdf_convenience.c
++++ libminc-2.3.00/libsrc/netcdf_convenience.c
+@@ -595,7 +595,7 @@ MNCAPI int miopen(const char *path, int
+ #if MINC2
+ MNCAPI int micreatex(const char *path, int cmode, struct mi2opts *opts_ptr)
+ {
+-    int fd;
++    hid_t fd;
+ 
+     MI_SAVE_ROUTINE_NAME("micreate");
+ 
diff -Nru libminc-2.3.00/debian/patches/series libminc-2.3.00/debian/patches/series
--- libminc-2.3.00/debian/patches/series	2016-08-25 15:25:30.000000000 +0200
+++ libminc-2.3.00/debian/patches/series	2016-10-20 20:26:41.000000000 +0200
@@ -3,3 +3,4 @@
 use-system-nifti
 fix-endian-issues-label-data.patch
 Use-system-FindHDF5-CMake-module.patch
+hdf5-1.10-support.patch
diff -Nru libminc-2.3.00/debian/patches/upstream-92ba4fa.patch libminc-2.3.00/debian/patches/upstream-92ba4fa.patch
--- libminc-2.3.00/debian/patches/upstream-92ba4fa.patch	1970-01-01 01:00:00.000000000 +0100
+++ libminc-2.3.00/debian/patches/upstream-92ba4fa.patch	2016-10-20 20:24:44.000000000 +0200
@@ -0,0 +1,70 @@
+From 92ba4fa2b8b88e02d5372b93a92a02f4e62385bc Mon Sep 17 00:00:00 2001
+From: "Vladimir S. FONOV" <vladimir.fo...@gmail.com>
+Date: Thu, 8 Sep 2016 15:01:42 -0400
+Subject: [PATCH] Fixing function forgotten in
+ d99dd01632dbcb62870870557b333142b9117e9a , related to #74
+
+---
+ libsrc/hdf_convenience.c | 18 ++++++++++++++++++
+ libsrc/hdf_convenience.h |  1 +
+ libsrc/minc_compat.c     |  9 ++-------
+ 3 files changed, 21 insertions(+), 7 deletions(-)
+
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -2412,4 +2412,22 @@ hdf_access(const char *path)
+     return (status > 0);        /* Return non-zero if success */
+ }
+ 
++/*
++ * Flushes the hdf file to disk
++ */
++int 
++hdf_flush(int fd)
++{
++    struct m2_file *file;
++    if ((file = hdf_id_check(fd))!=NULL ) {
++        /* Commit the (entire) file to disk. */
++        if (H5Fflush(file->file_id, H5F_SCOPE_GLOBAL) < 0) {
++            return MI_ERROR;
++        }
++        return MI_NOERROR;
++    }
++    return MI_ERROR;
++}
++
++
+ #endif /* MINC2 defined */
+Index: libminc-2.3.00/libsrc/hdf_convenience.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.h
++++ libminc-2.3.00/libsrc/hdf_convenience.h
+@@ -49,4 +49,5 @@ extern int hdf_open(const char *path, in
+ extern int hdf_create(const char *path, int mode, struct mi2opts *opts_ptr);
+ extern int hdf_close(int fd);
+ extern int hdf_access(const char *path);
++extern int hdf_flush(int fd);
+ 
+Index: libminc-2.3.00/libsrc/minc_compat.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc_compat.c
++++ libminc-2.3.00/libsrc/minc_compat.c
+@@ -358,14 +358,9 @@ MI2redef(int fd)
+ MNCAPI int
+ MI2sync(int fd)
+ {
+-    if (MI2_ISH5OBJ(fd)) {
++    if (MI2_ISH5OBJ(fd) ) {
+         /* Commit the (entire) file to disk. */
+-        if (H5Fflush(fd, H5F_SCOPE_GLOBAL) < 0) {
+-            return (MI_ERROR);
+-        }
+-        else {
+-            return (MI_NOERROR);
+-        }
++        return hdf_flush(fd);
+     }
+     else {
+         return (ncsync(fd));
diff -Nru libminc-2.3.00/debian/patches/upstream-d99dd01.patch libminc-2.3.00/debian/patches/upstream-d99dd01.patch
--- libminc-2.3.00/debian/patches/upstream-d99dd01.patch	1970-01-01 01:00:00.000000000 +0100
+++ libminc-2.3.00/debian/patches/upstream-d99dd01.patch	2016-10-20 20:24:12.000000000 +0200
@@ -0,0 +1,402 @@
+From d99dd01632dbcb62870870557b333142b9117e9a Mon Sep 17 00:00:00 2001
+From: "Robert D. Vincent" <robert.d.vinc...@mcgill.ca>
+Date: Wed, 27 Jul 2016 08:15:04 -0400
+Subject: [PATCH] Fix #74, don't assume hid_t === int since this is no longer
+ true in HDF5 1.10.
+
+---
+ libsrc/hdf_convenience.c | 121 +++++++++++++++++++++++++----------------------
+ libsrc/minc.h            |   8 +++-
+ 2 files changed, 71 insertions(+), 58 deletions(-)
+
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -45,7 +45,8 @@ struct m2_dim {
+ 
+ static struct m2_file {
+     struct m2_file *link;
+-    hid_t fd;
++    int   fd;                   /* our fake file id */
++    hid_t file_id;              /* actual hdf5 file id */
+     int wr_ok;                  /* non-zero if write OK */
+     int resolution;		/* Resolution setting. */
+     int nvars;
+@@ -74,18 +75,20 @@ hdf_id_check(int fd)
+ }
+ 
+ static struct m2_file *
+-hdf_id_add(int fd)
++hdf_id_add(hid_t file_id)
+ {
+     struct m2_file *new;
++    static unsigned short _id = 0;       /* at most 2^16 id's */
+ 
+     new = (struct m2_file *) malloc(sizeof (struct m2_file));
+     if (new != NULL) {
+-	new->fd = fd;
++        new->fd = HDF5_ID_MIN + _id++;
++        new->file_id = file_id;
+ 	new->resolution = 0;
+ 	new->nvars = 0;
+ 	new->ndims = 0;
+ 	new->link =_m2_list;
+-        new->grp_id = H5Gopen1(fd, MI2_GRPNAME);
++        new->grp_id = H5Gopen1(file_id, MI2_GRPNAME);
+         new->comp_type = MI2_COMP_UNKNOWN;
+         new->comp_param = 0;
+         new->chunk_type = MI2_CHUNK_UNKNOWN;
+@@ -99,7 +102,7 @@ hdf_id_add(int fd)
+     return (new);
+ }
+ 
+-static int 
++static int
+ hdf_id_del(int fd)
+ {
+     struct m2_file *curr, *prev;
+@@ -142,6 +145,7 @@ hdf_id_del(int fd)
+ 	    }
+ 
+             H5Gclose(curr->grp_id);
++            H5Fclose(curr->file_id);
+ 	    free(curr);
+ 	    return (MI_NOERROR);
+ 	}
+@@ -187,7 +191,7 @@ hdf_var_add(struct m2_file *file, const
+       strncpy(new->name, name, NC_MAX_NAME - 1);
+       strncpy(new->path, path, NC_MAX_NAME - 1);
+       new->is_cmpd = 0;
+-      new->dset_id = H5Dopen1(file->fd, path);
++      new->dset_id = H5Dopen1(file->file_id, path);
+       new->ftyp_id = H5Dget_type(new->dset_id);
+       new->mtyp_id = H5Tget_native_type(new->ftyp_id, H5T_DIR_ASCEND);
+       new->fspc_id = H5Dget_space(new->dset_id);
+@@ -490,7 +494,7 @@ hdf_attinq(int fd, int varid, const char
+       return (MI_ERROR);
+   }
+ 
+-  if (varid == NC_GLOBAL) {
++  if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+       var = NULL;
+       loc_id = file->grp_id;
+   } 
+@@ -591,7 +595,7 @@ hdf_attinq(int fd, int varid, const char
+ }
+ 
+ static int
+-hdf_put_dimorder(struct m2_file *file, int dst_id, int ndims, 
++hdf_put_dimorder(struct m2_file *file, hid_t dst_id, int ndims, 
+ 		 const int *dims_ptr)
+ {
+     int i;
+@@ -626,6 +630,9 @@ hdf_put_dimorder(struct m2_file *file, i
+     if (att_id >= 0) {
+ 	H5Awrite(att_id, typ_id, str_buf);
+     }
++    else {
++      fprintf(stderr, "Failed to create dimorder %lx\n", dst_id);
++    }
+   
+     H5Aclose(att_id);
+     H5Sclose(spc_id);
+@@ -634,7 +641,7 @@ hdf_put_dimorder(struct m2_file *file, i
+ }
+ 
+ static int 
+-hdf_get_dimorder(struct m2_file *file, int dst_id, int ndims, int *dims_ptr)
++hdf_get_dimorder(struct m2_file *file, hid_t dst_id, int ndims, int *dims_ptr)
+ {
+     char *str_ptr;
+     char *tmp_ptr;
+@@ -974,7 +981,7 @@ hdf_attget(int fd, int varid, const char
+         return (MI_ERROR);
+     }
+ 
+-    if (varid == NC_GLOBAL) {
++    if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+         var = NULL;
+         loc_id = file->grp_id;
+     } 
+@@ -1120,11 +1127,11 @@ hdf_attput(int fd, int varid, const char
+             H5Pclose(new_plst_id);
+             H5Sclose(var->fspc_id);
+ 
+-            if (H5Gunlink(fd, var->path) < 0) {
++            if (H5Gunlink(file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+-            if (H5Gmove2(file->grp_id, temp, fd, var->path) < 0) {
++            if (H5Gmove2(file->grp_id, temp, file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+@@ -1196,7 +1203,7 @@ hdf_attput(int fd, int varid, const char
+     att_id = H5Acreate2(loc_id, attnm, ftyp_id, spc_id, H5P_DEFAULT, H5P_DEFAULT);
+     
+     if (att_id < 0)
+-        goto cleanup;
++      goto cleanup;
+ 
+     /* Save the value.
+     */
+@@ -1261,10 +1268,10 @@ int
+ hdf_vardef(int fd, const char *varnm, nc_type vartype, int ndims, 
+            const int *dimids)
+ {
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int spc_id = -1;
+-    int prp_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t spc_id = -1;
++    hid_t prp_id = -1;
+     int status = MI_ERROR;
+     int i;
+     long length;
+@@ -1392,7 +1399,7 @@ hdf_vardef(int fd, const char *varnm, nc
+     }
+     
+     H5E_BEGIN_TRY {
+-        dst_id = H5Dcreate2(fd, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
++        dst_id = H5Dcreate2(file->file_id, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
+     } H5E_END_TRY;
+ 
+     if (dst_id < 0) {
+@@ -1465,10 +1472,10 @@ hdf_varget(int fd, int varid, const long
+ 	   void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id = -1;
+-  int typ_id = -1;
+-  int fspc_id = -1;
+-  int mspc_id = -1;
++  hid_t dst_id = -1;
++  hid_t typ_id = -1;
++  hid_t fspc_id = -1;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -1560,8 +1567,8 @@ hdf_varget(int fd, int varid, const long
+ }
+ 
+ int 
+-hdf_varputg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_varputg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, const void *value)
+ {
+     int status = MI_ERROR;      /* Assume guilty */
+@@ -1577,10 +1584,10 @@ hdf_varputg(int fd, int varid, const lon
+ 
+     struct m2_var *varp;
+     struct m2_file *file;
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int fspc_id = -1;
+-    int mspc_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t fspc_id = -1;
++    hid_t mspc_id = -1;
+ 
+     if ((file = hdf_id_check(fd)) == NULL) {
+ 	return (MI_ERROR);
+@@ -1747,8 +1754,8 @@ hdf_varputg(int fd, int varid, const lon
+ }
+ 
+ int 
+-hdf_vargetg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_vargetg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, void *value)
+ {
+     int status = MI_NOERROR;
+@@ -1910,10 +1917,10 @@ hdf_varput(int fd, int varid, const long
+ 	   const void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id;
+-  int typ_id;
+-  int fspc_id;
+-  int mspc_id = -1;
++  hid_t dst_id;
++  hid_t typ_id;
++  hid_t fspc_id;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -2085,6 +2092,7 @@ herr_t hdf_copy_attr(hid_t in_id, const
+       * don't overwrite the existing value.
+       */
+      status = MI_NOERROR;
++     fprintf(stderr, "Failed to create attribute '%s'\n", attr_name);
+      goto cleanup;
+    }
+    
+@@ -2195,7 +2203,7 @@ hdf_open_dsets(struct m2_file *file, hid
+ int
+ hdf_open(const char *path, int mode)
+ {
+-    hid_t fd;
++    hid_t file_id;
+     hid_t grp_id;
+     hid_t dset_id;
+     struct m2_file *file;
+@@ -2210,28 +2218,28 @@ hdf_open(const char *path, int mode)
+ 
+             prp_id = H5Pcreate(H5P_FILE_ACCESS);
+             H5Pset_fapl_mmap(prp_id, 8192, 1);
+-            fd = H5Fopen(path, mode & 0x7FFF, prp_id);
++            file_id = H5Fopen(path, mode & 0x7FFF, prp_id);
+             H5Pclose(prp_id);
+         }
+         else {
+-            fd = H5Fopen(path, mode, H5P_DEFAULT);
++            file_id = H5Fopen(path, mode, H5P_DEFAULT);
+         }
+ #else
+-        fd = H5Fopen(path, mode, H5P_DEFAULT);
++        file_id = H5Fopen(path, mode, H5P_DEFAULT);
+ #endif
+     } H5E_END_TRY;
+ 
+-    if (fd < 0) {
++    if (file_id < 0) {
+       return (MI_ERROR);
+     }
+ 
+-    file = hdf_id_add(fd);	/* Add it to the list */
++    file = hdf_id_add(file_id);	/* Add it to the list */
+     file->wr_ok = (mode & H5F_ACC_RDWR) != 0;
+ 
+     /* Open the image variables.
+      */
+     H5E_BEGIN_TRY {
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image");
+         if (dset_id >= 0) {
+             hid_t type_id;
+             int is_compound = 0;
+@@ -2262,7 +2270,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+     
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-min");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-min");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemin, "/minc-2.0/image/0/image-min", 
+@@ -2270,7 +2278,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+ 
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-max");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-max");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemax, "/minc-2.0/image/0/image-max", 
+@@ -2281,16 +2289,16 @@ hdf_open(const char *path, int mode)
+ 
+     /* Open all of the datasets in the "dimensions" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/dimensions", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/dimensions", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/dimensions/", 1);
+     H5Gclose(grp_id);
+ 
+     /* Open all of the datasets in the "info" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/info", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/info", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/info/", 0);
+     H5Gclose(grp_id);
+-    return (fd);
++    return (file->fd);
+ }
+ 
+ /** Create an HDF5 file. */
+@@ -2298,7 +2306,7 @@ int
+ hdf_create(const char *path, int cmode, struct mi2opts *opts_ptr)
+ {
+     hid_t grp_id;
+-    hid_t fd;
++    hid_t file_id;
+     hid_t tmp_id;
+     struct m2_file *file;
+     hid_t hdf_gpid;
+@@ -2319,10 +2327,10 @@ hdf_create(const char *path, int cmode,
+     H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);
+ 
+     H5E_BEGIN_TRY {
+-        fd = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
++        file_id = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
+     } H5E_END_TRY;
+-    if (fd < 0) {
+-      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, fd);
++    if (file_id < 0) {
++      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, (int)file_id);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+     }
+@@ -2332,7 +2340,7 @@ hdf_create(const char *path, int cmode,
+     /* Create the default groups.
+      * Should we use a non-zero value for size_hint (parameter 3)???
+      */
+-    if ((grp_id = H5Gcreate2(fd, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
++    if ((grp_id = H5Gcreate2(file_id, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
+       fprintf(stderr, "Error creating groups on line %d\n", __LINE__);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+@@ -2369,7 +2377,7 @@ hdf_create(const char *path, int cmode,
+     H5Gclose(tmp_id);
+     H5Gclose(grp_id);
+ 
+-    file = hdf_id_add(fd);      /* Add it to the list */
++    file = hdf_id_add(file_id); /* Add it to the list */
+     if (file == NULL) {
+         fprintf(stderr, "Error adding ID to list.\n");
+         H5Eprint1(stderr);
+@@ -2384,7 +2392,7 @@ hdf_create(const char *path, int cmode,
+         file->chunk_type = opts_ptr->chunk_type;
+         file->chunk_param = opts_ptr->chunk_param;
+     }
+-    return ((int) fd);
++    return (file->fd);
+ }
+ 
+ int
+@@ -2392,7 +2400,6 @@ hdf_close(int fd)
+ {
+     hdf_dim_commit(fd);         /* Make sure all dimensions were saved. */
+     hdf_id_del(fd);		/* Delete it from the list. */
+-    H5Fclose(fd);
+     return (MI_NOERROR);
+ }
+ 
+Index: libminc-2.3.00/libsrc/minc.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc.h
++++ libminc-2.3.00/libsrc/minc.h
+@@ -617,7 +617,13 @@ struct mi2opts {
+     int chunk_param;
+ };
+ 
+-#define MI2_ISH5OBJ(x) (H5Iget_type(x) > 0)
++/* This is hackish in that it assumes that all NetCDF handles returned
++ * by ncopen/nccreate will be small integers. Historically this is
++ * true, but it could break someday. We used to use an HDF5 call, but
++ * that broke when HDF5 switched from 32 to 64 bits for hid_t.
++ */
++#define HDF5_ID_MIN 0x30000000
++#define MI2_ISH5OBJ(x) (x >= HDF5_ID_MIN)
+ 
+ MNCAPI int micreatex(const char *path, int cmode, struct mi2opts *opts_ptr);
+ 
diff -Nru libminc-2.3.00/debian/rules libminc-2.3.00/debian/rules
--- libminc-2.3.00/debian/rules	2015-09-05 08:03:54.000000000 +0200
+++ libminc-2.3.00/debian/rules	2016-10-20 19:29:50.000000000 +0200
@@ -1,5 +1,6 @@
 #! /usr/bin/make -f
 
+export DEB_CPPFLAGS_MAINT_APPEND := -Wconversion
 
 ARCH = $(shell dpkg-architecture -qDEB_TARGET_MULTIARCH)
 

Reply via email to