Skip to content

Commit 31f75f7

Browse files
authored
Eliminate easy warnings, fix some code issues. (#22)
* Eliminate easy warnings, fix some code issues. * Check for positive edges in fill buffer * Add CHECK status to examples * Rename and move macro to hdf.h header * Fix comment, Correct flag variable for CXX
1 parent 618a935 commit 31f75f7

File tree

153 files changed

+9322
-9036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+9322
-9036
lines changed

CMakeInstallation.cmake

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
3434
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
3535
COMPONENT configinstall
3636
)
37-
endif ()
3837

39-
#-----------------------------------------------------------------------------
40-
# Export all exported targets to the build tree for use by parent project
41-
#-----------------------------------------------------------------------------
42-
if (NOT HDF4_EXTERNALLY_CONFIGURED)
38+
#-----------------------------------------------------------------------------
39+
# Export all exported targets to the build tree for use by parent project
40+
#-----------------------------------------------------------------------------
4341
export (
4442
TARGETS ${HDF4_LIBRARIES_TO_EXPORT} ${HDF4_LIB_DEPENDENCIES} ${HDF4_UTILS_TO_EXPORT}
4543
FILE ${HDF4_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
@@ -184,7 +182,7 @@ HDF_README_PROPERTIES(HDF4_BUILD_FORTRAN)
184182
#-----------------------------------------------------------------------------
185183
# Configure the COPYING.txt file for the windows binary package
186184
#-----------------------------------------------------------------------------
187-
if (WIN32 OR MINGW)
185+
if (WIN32)
188186
configure_file (${HDF4_SOURCE_DIR}/COPYING ${HDF4_BINARY_DIR}/COPYING.txt @ONLY)
189187
endif ()
190188

@@ -193,8 +191,7 @@ endif ()
193191
#-----------------------------------------------------------------------------
194192
if (NOT HDF4_EXTERNALLY_CONFIGURED)
195193
install (
196-
FILES
197-
${HDF4_SOURCE_DIR}/COPYING
194+
FILES ${HDF4_SOURCE_DIR}/COPYING
198195
DESTINATION ${HDF4_INSTALL_DATA_DIR}
199196
COMPONENT hdfdocuments
200197
)
@@ -203,7 +200,7 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
203200
${HDF4_SOURCE_DIR}/release_notes/USING_HDF4_CMake.txt
204201
${HDF4_SOURCE_DIR}/release_notes/RELEASE.txt
205202
)
206-
if (WIN32 OR MINGW)
203+
if (WIN32)
207204
set (release_files
208205
${release_files}
209206
${HDF4_SOURCE_DIR}/release_notes/USING_HDF4_VS.txt
@@ -216,7 +213,7 @@ if (NOT HDF4_EXTERNALLY_CONFIGURED)
216213
${HDF4_SOURCE_DIR}/release_notes/HISTORY.txt
217214
${HDF4_SOURCE_DIR}/release_notes/INSTALL
218215
)
219-
if (WIN32 OR MINGW)
216+
if (WIN32)
220217
set (release_files
221218
${release_files}
222219
${HDF4_SOURCE_DIR}/release_notes/INSTALL_Windows.txt

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ if (POLICY CMP0074)
55
cmake_policy (SET CMP0074 NEW)
66
endif ()
77

8+
if (POLICY CMP0083)
9+
cmake_policy (SET CMP0083 NEW)
10+
endif ()
11+
812
#-----------------------------------------------------------------------------
913
# Instructions for use : Normal Build
1014
#
@@ -37,8 +41,8 @@ endif ()
3741
set (CMAKE_IGNORE_EOL "--ignore-eol")
3842
if (CMAKE_VERSION VERSION_LESS "3.14.0")
3943
set (CMAKE_IGNORE_EOL "")
40-
# if (WIN32)
41-
# message (FATAL_ERROR "Windows builds require a minimum of CMake 3.14")
44+
#if(CMAKE_VERSION VERSION_LESS "3.14.0" AND WIN32)
45+
# MESSAGE(FATAL_ERROR "Windows builds requires a minimum of CMake 3.14")
4246
# endif()
4347
endif ()
4448

@@ -397,13 +401,17 @@ INCLUDE_DIRECTORIES (${HDF4_INCLUDE_DIRECTORIES} )
397401
# Certain systems may add /Debug or /Release to output paths
398402
# and we need to call the executable from inside the CMake configuration
399403
#-----------------------------------------------------------------------------
404+
set (EXE_EXT "")
400405
if (WIN32)
406+
set (EXE_EXT ".exe")
401407
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
402408
if (MSVC)
403409
add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1 _CONSOLE)
404410
endif ()
405411
endif ()
406412

413+
option (HDF5_MINGW_STATIC_GCC_LIBS "Statically link libgcc/libstdc++" OFF)
414+
407415
if (MSVC)
408416
set (CMAKE_MFC_FLAG 0)
409417
set (WIN_COMPILE_FLAGS "")

config/cmake/HDFCompilerFlags.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ else ()
161161
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=implicit-function-declaration")
162162
endif ()
163163
if (CMAKE_CXX_COMPILER_LOADED)
164-
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
164+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
165165
if (_INTEL_WINDOWS)
166-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wcheck /Wall")
166+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wcheck /Wall")
167167
else ()
168-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcheck -Wall")
168+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcheck -Wall")
169169
endif ()
170170
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
171171
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra")

config/cmake/README.txt.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The contents of this directory are:
1919

2020
This binary was built with the ZLIB and SZIP/Libaec external libraries and are
2121
included for convenience. Libaec is an unrestricted open-source replacement for SZIP
22-
(Encoder ENABLED).
22+
(version 1.0.4, Encoder ENABLED).
2323

2424
The official ZLIB and SZIP/Libaec pages are at:
2525

config/cmake/cacheinit.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set (CMAKE_INSTALL_FRAMEWORK_PREFIX "Library/Frameworks" CACHE STRING "Framework
88

99
set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)
1010

11-
set (HDF_PACKAGE_NAMESPACE "hdf4::" CACHE STRING "Name for HDF package namespace" FORCE)
11+
set (HDF_PACKAGE_NAMESPACE "hdf4::" CACHE STRING "Name for HDF package namespace (can be empty)" FORCE)
1212

1313
set (HDF4_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE)
1414

@@ -48,6 +48,8 @@ set (HDF4_PACKAGE_EXTLIBS OFF CACHE BOOL "(WINDOWS)CPACK - include external libr
4848

4949
set (HDF4_NO_PACKAGES OFF CACHE BOOL "CPACK - Disable packaging" FORCE)
5050

51+
set (HDF4_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" FORCE)
52+
5153
set (HDF4_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT SVN TGZ)" FORCE)
5254
set_property (CACHE HDF4_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT SVN TGZ)
5355

config/cmake/mccacheinit.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ set (USE_LIBAEC ON CACHE BOOL "Use libaec szip replacement" FORCE)
5757

5858
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Debug" FORCE)
5959

60-
set (JPEG_TGZ_NAME "JPEG8d.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE)
60+
set (JPEG_TGZ_NAME "JPEG9d.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE)
6161

6262
set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
6363
set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package" FORCE)
6464
set (SZIP_PACKAGE_NAME "szip" CACHE STRING "Name of SZIP package" FORCE)
65-
6665
set (JPEG_PACKAGE_NAME "jpeg" CACHE STRING "Name of JPEG package" FORCE)

hdf/examples/AN_create_annotation.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,90 +28,109 @@ int main( )
2828
* Create the HDF file.
2929
*/
3030
file_id = Hopen (FILE_NAME, DFACC_CREATE, 0);
31+
CHECK_NOT_VAL(file_id, FAIL, "Hopen");
3132

3233
/*
3334
* Initialize the AN interface.
3435
*/
3536
an_id = ANstart (file_id);
37+
CHECK_NOT_VAL(an_id, FAIL, "ANstart");
3638

3739
/*
3840
* Create the file label.
3941
*/
4042
file_label_id = ANcreatef (an_id, AN_FILE_LABEL);
43+
CHECK_NOT_VAL(file_label_id, FAIL, "AN_FILE_LABEL");
4144

4245
/*
4346
* Write the annotations to the file label.
4447
*/
45-
status_32 = ANwriteann (file_label_id, FILE_LABEL_TXT,
46-
strlen (FILE_LABEL_TXT));
48+
status_32 = ANwriteann (file_label_id, FILE_LABEL_TXT, strlen (FILE_LABEL_TXT));
49+
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");
4750

4851
/*
4952
* Create file description.
5053
*/
5154
file_desc_id = ANcreatef (an_id, AN_FILE_DESC);
55+
CHECK_NOT_VAL(file_desc_id, FAIL, "ANcreatef");
5256

5357
/*
54-
* Write the annotation to the file description.
58+
* Write the annotation to the file description.
5559
*/
56-
status_32 = ANwriteann (file_desc_id, FILE_DESC_TXT,
57-
strlen (FILE_DESC_TXT));
60+
status_32 = ANwriteann (file_desc_id, FILE_DESC_TXT, strlen (FILE_DESC_TXT));
61+
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");
5862

5963
/*
60-
* Create a vgroup in the V interface. Note that the vgroup's ref number
64+
* Create a vgroup in the V interface. Note that the vgroup's ref number
6165
* is set to -1 for creating and the access mode is "w" for writing.
6266
*/
6367
status_n = Vstart (file_id);
68+
CHECK_NOT_VAL(status_n, FAIL, "Vstart");
6469
vgroup_id = Vattach (file_id, -1, "w");
70+
CHECK_NOT_VAL(vgroup_id, FAIL, "Vattach");
6571
status_32 = Vsetname (vgroup_id, VG_NAME);
72+
CHECK_NOT_VAL(status_32, FAIL, "Vsetname");
6673

6774
/*
6875
* Obtain the tag and ref number of the vgroup for subsequent
69-
* references.
76+
* references.
7077
*/
7178
vgroup_tag = (uint16) VQuerytag (vgroup_id);
7279
vgroup_ref = (uint16) VQueryref (vgroup_id);
7380

7481
/*
75-
* Create the data label for the vgroup identified by its tag
82+
* Create the data label for the vgroup identified by its tag
7683
* and ref number.
7784
*/
7885
data_label_id = ANcreate (an_id, vgroup_tag, vgroup_ref, AN_DATA_LABEL);
86+
CHECK_NOT_VAL(data_label_id, FAIL, "ANcreate");
7987

8088
/*
8189
* Write the annotation text to the data label.
8290
*/
83-
status_32 = ANwriteann (data_label_id, DATA_LABEL_TXT,
84-
strlen (DATA_LABEL_TXT));
91+
status_32 = ANwriteann (data_label_id, DATA_LABEL_TXT, strlen (DATA_LABEL_TXT));
92+
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");
8593

8694
/*
87-
* Create the data description for the vgroup identified by its tag
95+
* Create the data description for the vgroup identified by its tag
8896
* and ref number.
8997
*/
9098
data_desc_id = ANcreate (an_id, vgroup_tag, vgroup_ref, AN_DATA_DESC);
99+
CHECK_NOT_VAL(data_desc_id, FAIL, "ANcreate");
91100

92101
/*
93102
* Write the annotation text to the data description.
94103
*/
95104
status_32 = ANwriteann (data_desc_id, DATA_DESC_TXT, strlen (DATA_DESC_TXT));
105+
CHECK_NOT_VAL(status_32, FAIL, "ANwriteann");
96106

97107
/*
98108
* Teminate access to the vgroup and to the V interface.
99109
*/
100110
status_32 = Vdetach (vgroup_id);
111+
CHECK_NOT_VAL(status_32, FAIL, "Vdetach");
101112
status_n = Vend (file_id);
113+
CHECK_NOT_VAL(status_n, FAIL, "Vend");
102114

103115
/*
104116
* Terminate access to each annotation explicitly.
105117
*/
106118
status_n = ANendaccess (file_label_id);
119+
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
107120
status_n = ANendaccess (file_desc_id);
121+
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
108122
status_n = ANendaccess (data_label_id);
123+
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
109124
status_n = ANendaccess (data_desc_id);
125+
CHECK_NOT_VAL(status_n, FAIL, "ANendaccess");
110126

111127
/*
112128
* Terminate access to the AN interface and close the HDF file.
113129
*/
114130
status_32 = ANend (an_id);
131+
CHECK_NOT_VAL(status_32, FAIL, "ANend");
115132
status_n = Hclose (file_id);
133+
CHECK_NOT_VAL(status_n, FAIL, "Hclose");
134+
116135
return 0;
117136
}

hdf/examples/AN_get_annotation_info.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ int main( )
99

1010
intn status_n; /* returned status for functions returning an intn */
1111
int32 status_32, /* returned status for functions returning an int32*/
12-
file_id, an_id, ann_id,
12+
file_id, an_id,
1313
n_annots, /* number of annotations */
14-
*ann_list, /* list of annotation identifiers */
14+
*ann_list = NULL, /* list of annotation identifiers */
1515
vgroup_ref, /* reference number of the vgroup */
1616
index; /* index of an annotation in the annotation list */
1717
ann_type annot_type = AN_DATA_DESC; /* annotation to be obtained*/
@@ -29,16 +29,19 @@ int main( )
2929
* Initialize the V interface.
3030
*/
3131
status_n = Vstart (file_id);
32+
CHECK_NOT_VAL(status_n, FAIL, "Vstart");
3233

3334
/*
3435
* Get the vgroup named VG_NAME.
3536
*/
3637
vgroup_ref = Vfind (file_id, VG_NAME);
38+
CHECK_NOT_VAL(vgroup_ref, FAIL, "Vfind");
3739

3840
/*
3941
* Initialize the AN interface and obtain an interface id.
4042
*/
4143
an_id = ANstart (file_id);
44+
CHECK_NOT_VAL(an_id, FAIL, "ANstart");
4245

4346
/*
4447
* Get the number of object descriptions. Note that, since ANnumann takes
@@ -55,25 +58,26 @@ int main( )
5558
ann_list = malloc (n_annots * sizeof (int32));
5659

5760
/*
58-
* Get the list of identifiers of the annotations attached to the
61+
* Get the list of identifiers of the annotations attached to the
5962
* vgroup and of type annot_type.
6063
*/
61-
n_annots = ANannlist (an_id, annot_type, vgroup_tag, (uint16)vgroup_ref,
64+
n_annots = ANannlist (an_id, annot_type, vgroup_tag, (uint16)vgroup_ref,
6265
ann_list);
6366

6467
/*
65-
* Get each annotation identifier from the list then display the
68+
* Get each annotation identifier from the list then display the
6669
* tag/ref number pair of the corresponding annotation.
6770
*/
6871
printf ("List of annotations of type AN_DATA_DESC:\n");
6972
for (index = 0; index < n_annots; index++)
7073
{
7174
/*
72-
* Get and display the ref number of the annotation from
75+
* Get and display the ref number of the annotation from
7376
* its identifier.
7477
*/
7578
status_32 = ANid2tagref (ann_list[index], &ann_tag, &ann_ref);
76-
printf ("Annotation index %d: tag = %s\nreference number= %d\n",
79+
CHECK_NOT_VAL(status_32, FAIL, "ANid2tagref");
80+
printf ("Annotation index %d: tag = %s\nreference number= %d\n",
7781
index, ann_tag == DFTAG_DIA ? "DFTAG_DIA (data description)":
7882
"Incorrect", ann_ref);
7983
} /* for */
@@ -83,25 +87,28 @@ int main( )
8387
* Get and display an annotation type from an annotation tag.
8488
*/
8589
annot_type = ANtag2atype (DFTAG_FID);
86-
printf ("\nAnnotation type of DFTAG_FID (file label) is %s\n",
90+
printf ("\nAnnotation type of DFTAG_FID (file label) is %s\n",
8791
annot_type == AN_FILE_LABEL ? "AN_FILE_LABEL":"Incorrect");
8892

8993
/*
9094
* Get and display an annotation tag from an annotation type.
9195
*/
9296
ann_tag = ANatype2tag (AN_DATA_LABEL);
93-
printf ("\nAnnotation tag of AN_DATA_LABEL is %s\n",
97+
printf ("\nAnnotation tag of AN_DATA_LABEL is %s\n",
9498
ann_tag == DFTAG_DIL ? "DFTAG_DIL (data label)":"Incorrect");
9599

96100
/*
97101
* Terminate access to the AN interface and close the HDF file.
98102
*/
99103
status_32 = ANend (an_id);
104+
CHECK_NOT_VAL(status_32, FAIL, "ANend");
100105
status_n = Hclose (file_id);
106+
CHECK_NOT_VAL(status_n, FAIL, "Hclose");
101107

102108
/*
103109
* Free the space allocated for the annotation identifier list.
104110
*/
105111
free (ann_list);
112+
106113
return 0;
107114
}

0 commit comments

Comments
 (0)