schwehr / hdf5-old

Hierarchical Data Format (HDF) 5
Other
0 stars 0 forks source link

const trouble with H5A_create(), H5A_write(), H5A_read(), H5FS_sect_try_shrink_eoa() #2

Open schwehr opened 10 years ago

schwehr commented 10 years ago

mem_type and type arguments maybe shouldn't be const. Or someone needs to carefully evaluate what should be const for each function starting from the ground up.

found via clang -Werror=incompatible-pointer-types-discards-qualifiers (clang 5.1 on Mac OSX 10.9 and xcode 5.1.1)

-H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
+H5A_create(const H5G_loc_t *loc, const char *name, /* const */  H5T_t *type,

-H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id)
+H5A_write(H5A_t *attr, /* const */ H5T_t *mem_type, const void *buf, hid_t dxpl_id)

-H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id)
+H5A_read(const H5A_t *attr, /* const */ H5T_t *mem_type, void *buf, hid_t dxpl_id)

-H5FS_sect_try_shrink_eoa(const H5F_t *f, hid_t dxpl_id, const H5FS_t *fspace, void *op_data)
+H5FS_sect_try_shrink_eoa(H5F_t *f, hid_t dxpl_id, /* const */ H5FS_t *fspace, void *op_data)

clang complaints:

clang -DHAVE_CONFIG_H -I. -I/sw/include -UNDEBUG -DH5AC_DEBUG -DH5B_DEBUG -DH5B2_DEBUG -DH5D_DEBUG -DH5E_DEBUG -DH5F_DEBUG -DH5G_DEBUG -DH5HG_DEBUG -DH5HL_DEBUG -DH5I_DEBUG -DH5MF_DEBUG -DH5MM_DEBUG -DH5O_DEBUG -DH5P_DEBUG -DH5S_DEBUG -DH5T_DEBUG -DH5V_DEBUG -DH5Z_DEBUG -DH5_DEBUG_API -Wall -Wextra -MT H5A.lo -MD -MP -MF .deps/H5A.Tpo -c H5A.c  -fno-common -DPIC -o .libs/H5A.o
H5A.c:432:45: warning: passing 'const H5T_t *' (aka 'const struct H5T_t *') to
      parameter of type 'H5T_t *' (aka 'struct H5T_t *') discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
    if(NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL)))
                                            ^~~~
./H5Tprivate.h:109:31: note: passing argument to parameter 'old_dt' here
H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method);
                              ^
H5A.c:999:62: warning: passing 'const H5T_t *' (aka 'const struct H5T_t *') to
      parameter of type 'H5T_t *' (aka 'struct H5T_t *') discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
  ...if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)...
                                                      ^~~~~~~~
./H5Tprivate.h:109:31: note: passing argument to parameter 'old_dt' here
H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method);
                              ^
H5A.c:1159:71: warning: passing 'const H5T_t *' (aka 'const struct H5T_t *') to
      parameter of type 'H5T_t *' (aka 'struct H5T_t *') discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
  ...(dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FA...
                                                   ^~~~~~~~
./H5Tprivate.h:109:31: note: passing argument to parameter