diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-05-15 12:20:57 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-05-15 12:20:57 (GMT) |
commit | 758846065953f93503394e1549bf4f3a8f07ab0e (patch) | |
tree | 5e730157957cd611c1ff8fd4a13030c4340e1121 | |
parent | 4328846bde89b58e42f0cc6ba165092f91717b25 (diff) | |
parent | 730d6cc53f3914f951e1177fc29835486b61dcdb (diff) | |
download | hdf5-758846065953f93503394e1549bf4f3a8f07ab0e.zip hdf5-758846065953f93503394e1549bf4f3a8f07ab0e.tar.gz hdf5-758846065953f93503394e1549bf4f3a8f07ab0e.tar.bz2 |
Merge pull request #2580 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:hdf5_1_10_warnings to hdf5_1_10
* commit '730d6cc53f3914f951e1177fc29835486b61dcdb':
Normalization of high-level library with develop. Also brings the warnhist script over.
32 files changed, 961 insertions, 400 deletions
@@ -96,6 +96,7 @@ ./bin/switch_maint_mode _DO_NOT_DISTRIBUTE_ ./bin/timekeeper _DO_NOT_DISTRIBUTE_ ./bin/trace +./bin/warnhist _DO_NOT_DISTRIBUTE_ ./bin/yodconfigure ./bin/batch/ctestP.lsf.in.cmake ./bin/batch/ctestP.sl.in.cmake diff --git a/Makefile.am b/Makefile.am index af3d634..19522f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ ## Makefile.am ## Run automake to generate a Makefile.in from this file. ## -# +# # This makefile mostly just reinvokes make in the various subdirectories # but does so in the correct order. You can alternatively invoke make from # each subdirectory manually. @@ -45,7 +45,7 @@ include $(top_srcdir)/config/commence.am # Since we're explicitly listing DIST_SUBDIRS, we also need to list # directories that are only conditionally built (so that their Makefiles # are cleaned as well). -# Note that `make clean' will not affect the examples or doc directories. +# Note that `make clean' will not affect the examples or doc directories. # Conditionals. These conditionals are defined during configure # Define each variable to empty if it is not used to placate pmake @@ -133,7 +133,7 @@ mostlyclean-local: # 'make install' will now install examples, the same as 'make install-all'. # 'make-install-all' will be redundant but will still work. install: install-recursive install-examples -uninstall: uninstall-recursive uninstall-examples +uninstall: uninstall-recursive uninstall-examples # 'make install-all' also installs examples install-all: @@ -154,7 +154,7 @@ install-doc: uninstall-doc: @echo "docs no longer live in this tree. Use install-examples to install examples." -# `make check-install' or `make installcheck' checks that examples can +# `make check-install' or `make installcheck' checks that examples can # be successfully built installcheck-local: if test -n "${DESTDIR}"; then \ diff --git a/bin/warnhist b/bin/warnhist new file mode 100755 index 0000000..a88474b --- /dev/null +++ b/bin/warnhist @@ -0,0 +1,523 @@ +#!/usr/bin/env perl +require 5.003; +use warnings; + +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Quincey Koziol, koziol@hdfgroup.org +# 9 Aug 2013 +# +# Purpose: Given an input file containing the output from a build of the +# library, gather the file names and line numbers, alias +# identical types of warnings together into a single bin and +# report the number of warnings for each type of warning, each file +# and the total count of warnings + +# Perl modules/settings +use strict; +use Getopt::Std; + +# Global variables, for accumulating information +my $totalcount = 0; +my %warn_count = (); +my $warncount; +my %warn_file = (); +my %warn_file_line = (); +my %file_count = (); +my $filecount; +my $ignorecount = 0; +my @ignorenames; +my %ignored_files = (); +my %warn_file_indices = (); +my %file_warn_indices = (); +my @warn_match_strings; +my @file_match_strings; +my %file_warn = (); +my %file_warn_line = (); +my $current_warning = 0; +my $current_file = 0; +my $warn_index; +my $last_c_name; +my $last_fort_name; +my $last_fort_line; +my $genericize = 1; + +# Display usage +sub do_help { + print "Usage: 'warnhist [-h, --help] [-t <prefix>] [-w <n>] [-W] [-f <n>] [-F] [-s <warning string list>] [-S <file string list] [-l] [-u] [-i <name list>] [file]'\n"; + print "\t-h, --help\tDisplay this usage\n"; + print "\t-t <prefix>\tTrim pathname prefix from filenames, <prefix>\n"; + print "\t-w <n>\tDisplay files for a given warning index list, <n>\n"; + print "\t\t<n> can be a single value, a range, or a comma separated list\n"; + print "\t\tFor example: '0' or '0,4' or '8-10' or '0,2-4,8-10,13'\n"; + print "\t-W\tDisplay files for all warnings\n"; + print "\t-f <n>\tDisplay warnings for a given file index list, <n>\n"; + print "\t\t<n> can be a single value, a range, or a comma separated list\n"; + print "\t\tFor example: '0' or '0,4' or '8-10' or '0,2-4,8-10,13'\n"; + print "\t-F\tDisplay warnings for all files\n"; + print "\t-s <warning string list>\tDisplay files for warnings which contain a string, <warning string list>\n"; + print "\t\t<warning string list> is a comma separated list, with no spaces\n"; + print "\t\tFor example: 'Wunused-dummy-argument' or 'Wunused-dummy-argument,Wunused-variable'\n"; + print "\t-S <file string list>\tDisplay warnings for files which contain a string, <file string list>\n"; + print "\t\t<file string list> is a comma separated list, with no spaces\n"; + print "\t\tFor example: 'H5Fint' or 'H5Fint,H5Gnode'\n"; + print "\t-l\tDisplay line nunbers for file/warning\n"; + print "\t-u\tLeave 'unique' types in warnings, instead of genericizing them\n"; + print "\t-i <name list>\tIgnore named files, <name list>\n"; + print "\t\t<name list> is a comma separated list, with no spaces\n"; + print "\t\tFor example: 'H5LTparse' or 'H5LTparse,H5LTanalyze'\n"; + print "\tfile\tFilename containing build output\n"; + print "\t\tIf no file is given, standard input is used.\n"; + exit; +} + +sub main::HELP_MESSAGE { + do_help(); +} + +# declare the Perl command line flags/options we want to allow +my %options=(); +getopts("FWhut:w:f:s:S:i:l", \%options); + +# Display usage, if requested +if($options{h}) { + do_help(); +} + +# Parse list of file names to ignore +if(exists $options{i}) { + @ignorenames = split /,/, $options{i}; +#print @ignorenames; +} + +# Parse list of warning indices to expand file names +if(exists $options{w}) { + my @tmp_indices; + + @tmp_indices = split /,/, $options{w}; +#print @tmp_indices; + for my $x (@tmp_indices) { +#print "x = '$x'\n"; + if($x =~ /\-/) { + my $start_index; + my $end_index; + +#print "matched = '$x'\n"; + ($start_index, $end_index) = split /\-/, $x; +#print "start_index = '$start_index', end_index = '$end_index'\n"; + for my $y ($start_index..$end_index) { +#print "y = '$y'\n"; + if(!exists $warn_file_indices{$y}) { + $warn_file_indices{$y} = $y; + } + } + } + else { + if(!exists $warn_file_indices{$x}) { + $warn_file_indices{$x} = $x; + } + } + } +#foreach (sort keys %warn_file_indices) { +# print "$_ : $warn_file_indices{$_}\n"; +#} +} + +# Parse list of warning strings to expand file names +if(exists $options{s}) { + @warn_match_strings = split /,/, $options{s}; +# print @warn_match_strings; +} + +# Parse list of file indices to expand warnings +if(exists $options{f}) { + my @tmp_indices; + + @tmp_indices = split /,/, $options{f}; +#print @tmp_indices; + for my $x (@tmp_indices) { +#print "x = '$x'\n"; + if($x =~ /\-/) { + my $start_index; + my $end_index; + +#print "matched = '$x'\n"; + ($start_index, $end_index) = split /\-/, $x; +#print "start_index = '$start_index', end_index = '$end_index'\n"; + for my $y ($start_index..$end_index) { +#print "y = '$y'\n"; + if(!exists $file_warn_indices{$y}) { + $file_warn_indices{$y} = $y; + } + } + } + else { + if(!exists $file_warn_indices{$x}) { + $file_warn_indices{$x} = $x; + } + } + } +#foreach (sort keys %warn_file_indices) { +# print "$_ : $warn_file_indices{$_}\n"; +#} +} + +# Parse list of warning strings for files to expand warnings +if(exists $options{S}) { + @file_match_strings = split /,/, $options{S}; +# print @file_match_strings; +} + +# Check if warnings should stay unique and not be "genericized" +if($options{u}) { + $genericize = 0; +} + +PARSE_LINES: +while (<>) { + my $name; + my $line; + my $prev_line; + my $toss; + my $offset; + my $warning; + my $extra; + my $extra2; + + # Retain last FORTRAN compile line, which comes a few lines before warning + if($_ =~ /.*\.[fF]90:.*/) { + ($last_fort_name, $last_fort_line, $toss) = split /\:/, $_; + ($last_fort_line, $toss) = split /\./, $last_fort_line; + } + + # Retain last C/C++ compile line, which possibly comes a few lines before warning + if($_ =~ /.*[A-Za-z0-9_]\.[cC]:.*/) { + ($last_c_name, $toss) = split /\:/, $_; + } + + # Retain C/C++ compile line, which comes with the line of warning + if($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) { + $last_c_name = $_; + } + + # Skip lines that don't have the word "warning" + next if $_ !~ /[Ww]arning/; + + # Skip warnings from linker + next if $_ =~ /ld: warning:/; + + # Skip warnings from build_py and install_lib + next if $_ =~ /warning: (build_py|install_lib)/; + + # "Hide" the C++ '::' symbol until we've parsed out the parts of the line + while($_ =~ /\:\:/) { + $_ =~ s/\:\:/@@@@/g; + } + + # Check for weird formatting of warning message + if($_ =~ /^cc1: warning:.*/) { + $name = $last_c_name; + $line = "??"; + ($toss, $toss, $warning, $extra, $extra2) = split /\:/, $_; + # Check for CMAKE build with warning on first line and no filename + } elsif($_ =~ /^\s*[Ww]arning:.*/) { + $name = $last_c_name; + $line = "??"; + ($toss, $warning, $extra, $extra2) = split /\:/, $_; + # Check for FORTRAN warning output + } elsif($_ =~ /^Warning:.*/) { + $name = $last_fort_name; + $line = $last_fort_line; + ($toss, $warning, $extra, $extra2) = split /\:/, $_; +#print "1:",$.,":",$_; +# $_ = <>; +#print "2:",$.,":",$_; +# if($_ =~ /^\sFC.*/) { +# $_ = <>; +#print "3:",$.,":",$_; +# } +# ($name, $line, $toss) = split /\:/, $_; +#print "4:","'",$name,"'","-","'",$line,"'","\n"; + # Check for improperly parsed filename or line + if($name =~ /^$/) { + print "Filename is a null string! Input line #$. is: '$_'"; + next + } + if($line =~ /^$/) { + print "Line is a null string! Input line #$. is: '$_'"; + next + } + # Check for non-GCC warning (Solaris/Oracle?) + } elsif($_ =~ /^\".*, line [0-9]+: *[Ww]arning:.*/) { + ($name, $toss, $warning, $extra, $extra2) = split /\:/, $_; + ($name, $line) = split /\,/, $name; + $name =~ s/^\"//g; + $name =~ s/\"$//g; + $line =~ s/^\s*line\s*//g; +# print "name:'", $name, "'-'", $line, "'\n"; +# print "warning:'", $warning, "'\n"; + # Check for Intel icc warning + } elsif($_ =~ /.*[A-Za-z0-9_]\.[chC]\(.*[0-9]\):.*#.*/) { + ($last_c_name, $toss, $warning) = split /\:/, $last_c_name; + ($name, $line) = split /\(/, $last_c_name; + $line =~ s/\)//g; + } else { + # Check for 'character offset' field appended to file & line # + # (This is probably specific to GCC) + if($_ =~ /^.*[0-9]+\:[0-9]+\:/) { + ($name, $line, $offset, $toss, $warning, $extra, $extra2) = split /\:/, $_; + } else { + ($name, $line, $toss, $warning, $extra, $extra2) = split /\:/, $_; + } + } + + # Check for extra ':' followed by more text in original warning string, + # and append the ':' and text back onto the parsed warning + # (Use 'length $extra' idiom to avoid warning when $extra is undefined) + if(length $extra ) { + $warning = join ':', $warning, $extra; + } + if(length $extra2 ) { + $warning = join ':', $warning, $extra2; + } + + # Restore the C++ '::' symbol now that we've parsed out the parts of the line + while($warning =~ /@@@@/) { + $warning =~ s/@@@@/\:\:/g; + } + + # Trim leading '..' paths from filename + while($name =~ /^\.\.\//) { + $name =~ s/^\.\.\///g; + } + + # Check for trimming prefix + if((exists $options{t}) && ($name =~ /$options{t}/)) { + $name =~ s/^$options{t}\///g; + } + + # Check for ignored file + if(exists $options{i}) { + for my $x (@ignorenames) { +#print "x = '$x'\n"; + if($name =~ /$x/) { +# print "matched name = '$name'\n"; + $ignorecount++; + if(!(exists $ignored_files{$name})) { + $ignored_files{$name} = $name; + } + next PARSE_LINES; + } + } + } + + # Check for improperly parsed warning (usually an undefined warning string) + if(!defined $warning) { + print "Warning Undefined! Input line is: '$_'"; + next + } + + # Get rid of leading & trailing whitespace + $warning =~ s/^\s//g; + $warning =~ s/\s$//g; + + # Check for improperly parsed warning + if($warning =~ /^$/) { + print "Warning is a null string! Input line is: '$_'"; + next + } + + # Convert all quotes to ' + $warning =~ s/‘/'/g; + $warning =~ s/’/'/g; + $warning =~ s/"/'/g; + +# +# These skipped messages & "genericizations" may be specific to GCC + + # Skip supplemental warning message + next if $warning =~ /near initialization for/; + + # Skip C++ supplemental warning message + next if $warning =~ /in call to/; + + # Skip GCC warning that should be a note + next if $_ =~ /\(this will be reported only once per input file\)/; + + if($genericize) { + # Eliminate C/C++ "{aka <some type>}" and "{aka '<some type>'}" info + if($warning =~ /\s(\{|\()aka '?[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\ ]*'?(\}|\))/) { + $warning =~ s/\s(\{|\()aka '?[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\ ]*'?(\}|\))//g; + } + + # Genericize C/C++ '<some type>', printf format '%<some format>', and + # "unknown warning group" into '-' + if($warning =~ /'[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=\ ]*'/) { + $warning =~ s/'[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=]+[A-Za-z_0-9\(\)\*\,\[\]\.\<\>\&\:\+\#\-\=\ ]*'/'-'/g; + } + if($warning =~ /'%[\#0\-\ \+]*[,;\:_]?[0-9\*]*\.?[0-9\*]*[hjltzL]*[aAcdeEfFgGinosuxX]'/) { + $warning =~ s/'%[\#0\-\ \+]*[,;\:_]?[0-9\*]*\.?[0-9\*]*[hjltzL]*[aAcdeEfFgGinosuxX]'/'-'/g; + } + + # Genericize C/C++ "<macro>" warnings into "-" + if($warning =~ /"[A-Za-z_0-9]*"/) { + $warning =~ s/"[A-Za-z_0-9]*"/"-"/g; + } + + # Genericize [GCC?] C/C++ warning text about suggessted attribute + if($warning =~ /attribute=[A-Za-z_0-9]*\]/) { + $warning =~ s/=[A-Za-z_0-9]*\]/=-\]/g; + } + + # Genericize FORTRAN "at (<n>)" into "at (-)", "REAL(<n>)" into "REAL(-)", + # and "INTEGER(<n>)" into "INTEGER(-)" + if($warning =~ /.*at\s\([0-9]+\).*/) { + $warning =~ s/at\s\([0-9]+\)/at \(-\)/g; + } + if($warning =~ /.*REAL\([0-9]+\).*/) { + $warning =~ s/REAL\([0-9]+\)/REAL\(-\)/g; + } + if($warning =~ /.*INTEGER\([0-9]+\).*/) { + $warning =~ s/INTEGER\([0-9]+\)/INTEGER\(-\)/g; + } + + # Genericize standalone numbers in warnings + if($warning =~ /(\s|')-?[0-9]+(\s|')/) { + $warning =~ s/-?[0-9]+/-/g; + } + + # Genericize unusual GCC/G++/GFORTRAN warnings that aren't handled above + if($warning =~ /\[deprecation\] [A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]* has been deprecated.*/) { + $warning =~ s/[A-Za-z_0-9]*\([A-Za-z_,0-9]*\) in [A-Za-z_0-9]*/-\(-\) in -/g; + } + } +# print "warning = $warning\n"; +# <end possible GCC-specific code> + + # Check if we've already seen this warning on this line in this file + # (Can happen for warnings from inside header files) + if( !exists $warn_file_line{$warning}{$name}{$line} ) { + # Increment count for [generic] warning + $warn_count{$warning}++; + $warn_file{$warning}{$name}++; + $warn_file_line{$warning}{$name}{$line}++; + + # Increment count for filename + $file_count{$name}++; + $file_warn{$name}{$warning}++; + $file_warn_line{$name}{$warning}{$line}++; + + # Increment total count of warnings + $totalcount++; + } + +# print "name = $name\n"; +# print "line = $line\n"; +# print "offset = $offset\n"; +# print "warning = \"$warning\"\n"; +} + +print "Total unique [non-ignored] warnings: $totalcount\n"; +print "Total ignored warnings: $ignorecount\n"; +$warncount = keys %warn_count; +print "Total unique kinds of warnings: $warncount\n"; +$filecount = keys %file_count; +print "Total files with warnings: $filecount\n\n"; + +# Print warnings in decreasing frequency +print "# of Warnings by frequency (file count)\n"; +print "=======================================\n"; +for my $x (sort {$warn_count{$b} <=> $warn_count{$a}} keys(%warn_count)) { + printf ("[%2d] %4d (%2d) - %s\n", $current_warning++, $warn_count{$x}, scalar(keys %{$warn_file_line{$x}}), $x); + if((exists $options{W}) || (exists $options{w}) || (exists $options{s})) { + my $curr_index = $current_warning - 1; + my $match = 0; + + # Check for string from list in current warning + if(exists $options{s}) { + for my $y (@warn_match_strings) { +# print "y = '$y'\n"; + if($x =~ /$y/) { +# print "matched warning = '$x'\n"; + $match = 1; + last; + } + } + } + + # Check if current warning index matches + if((exists $warn_file_indices{$curr_index}) && $curr_index == $warn_file_indices{$curr_index}) { + $match = 1; + } + + if($match) { + for my $y (sort {$warn_file{$x}{$b} <=> $warn_file{$x}{$a}} keys(%{$warn_file{$x}})) { + printf ("\t%4d - %s\n", $warn_file{$x}{$y}, $y); + if(exists $options{l}) { + my $lines = join ", ", sort {$a <=> $b} keys %{$warn_file_line{$x}{$y}}; + printf("\t\tLines: $lines \n"); + } + } + } + } +} + +# Print warnings in decreasing frequency, by filename +print "\n# of Warnings by filename (warning type)\n"; +print "========================================\n"; +for my $x (sort {$file_count{$b} <=> $file_count{$a}} keys(%file_count)) { + printf ("[%3d] %4d (%2d) - %s\n", $current_file++, $file_count{$x}, scalar(keys %{$file_warn_line{$x}}), $x); + if((exists $options{F}) || (exists $options{f}) || (exists $options{S})) { + my $curr_index = $current_file - 1; + my $match = 0; + + # Check for string from list in current file + if(exists $options{S}) { + for my $y (@file_match_strings) { +# print "y = '$y'\n"; + if($x =~ /$y/) { +# print "matched warning = '$x'\n"; + $match = 1; + last; + } + } + } + + # Check if current file index matches + if((exists $file_warn_indices{$curr_index}) && $curr_index == $file_warn_indices{$curr_index}) { + $match = 1; + } + + if($match) { + for my $y (sort {$file_warn{$x}{$b} <=> $file_warn{$x}{$a}} keys(%{$file_warn{$x}})) { + printf ("\t%4d - %s\n", $file_warn{$x}{$y}, $y); + if(exists $options{l}) { + my $lines = join ", ", sort {$a <=> $b} keys %{$file_warn_line{$x}{$y}}; + printf("\t\tLines: $lines \n"); + } + } + } + } +} + +# Print names of files that were ignored +# Check for ignored file +if(exists $options{i}) { + print "\nIgnored filenames\n"; + print "=================\n"; + for my $x (sort keys(%ignored_files)) { + print "$x\n"; + } +} + diff --git a/configure.ac b/configure.ac index a10f26b..28437b2 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,7 @@ AC_SUBST([AR_FLAGS]) ## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but ## not exported to h5cc (or h5fc, etc.) ## -## H5_ECFLAGS is for warnings that should be treated as errors. +## H5_ECFLAGS (and company) are for warnings that should be treated as errors. ## AC_SUBST([H5_CFLAGS]) AC_SUBST([H5_ECFLAGS]) diff --git a/hl/Makefile.am b/hl/Makefile.am index 769340c..655b42e 100644 --- a/hl/Makefile.am +++ b/hl/Makefile.am @@ -10,7 +10,7 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # -# +# # This makefile mostly just reinvokes make in the various subdirectories # but does so in the correct order. You can alternatively invoke make from # each subdirectory manually. diff --git a/hl/c++/Makefile.am b/hl/c++/Makefile.am index f9ea328..6239a4c 100644 --- a/hl/c++/Makefile.am +++ b/hl/c++/Makefile.am @@ -14,7 +14,7 @@ ## Run automake to generate a Makefile.in from this file. # # High-Level API C++ Makefile(.in) -# +# include $(top_srcdir)/config/commence.am diff --git a/hl/c++/examples/run-hlc++-ex.sh.in b/hl/c++/examples/run-hlc++-ex.sh.in index 43831f5..4aa231f 100644 --- a/hl/c++/examples/run-hlc++-ex.sh.in +++ b/hl/c++/examples/run-hlc++-ex.sh.in @@ -98,5 +98,5 @@ rm *.o rm *.h5 echo -exit $EXIT_VALUE +exit $EXIT_VALUE diff --git a/hl/examples/run-hlc-ex.sh.in b/hl/examples/run-hlc-ex.sh.in index e6d0cc9..f2eec5d 100644 --- a/hl/examples/run-hlc-ex.sh.in +++ b/hl/examples/run-hlc-ex.sh.in @@ -138,5 +138,5 @@ rm *.o rm *.h5 echo -exit $EXIT_VALUE +exit $EXIT_VALUE diff --git a/hl/fortran/Makefile.am b/hl/fortran/Makefile.am index 7d24770..801702c 100644 --- a/hl/fortran/Makefile.am +++ b/hl/fortran/Makefile.am @@ -10,7 +10,7 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # -# +# # This makefile mostly just reinvokes make in the various subdirectories # but does so in the correct order. You can alternatively invoke make from # each subdirectory manually. diff --git a/hl/fortran/examples/ex_ds1.f90 b/hl/fortran/examples/ex_ds1.f90 index 14e2b0c..b31ac8e 100644 --- a/hl/fortran/examples/ex_ds1.f90 +++ b/hl/fortran/examples/ex_ds1.f90 @@ -18,7 +18,7 @@ PROGRAM example_ds IMPLICIT NONE - INTEGER, PARAMETER :: RANK = 2 ! rank of DATA dataset + INTEGER, PARAMETER :: RANK = 2 ! rank of DATA dataset INTEGER, PARAMETER :: DIM_DATA = 12 INTEGER, PARAMETER :: DIM1_SIZE = 3 INTEGER, PARAMETER :: DIM2_SIZE = 4 @@ -33,13 +33,13 @@ PROGRAM example_ds INTEGER(hid_t) :: fid ! file ID INTEGER(hid_t) :: did ! dataset ID INTEGER(hid_t) :: dsid ! DS dataset ID - INTEGER :: rankds = 1 ! rank of DS dataset - INTEGER(hsize_t), DIMENSION(1:rank) :: dims = (/DIM2_SIZE,DIM1_SIZE/) ! size of data dataset - INTEGER, DIMENSION(1:DIM_DATA) :: buf = (/1,2,3,4,5,6,7,8,9,10,11,12/) ! data of data dataset - INTEGER(hsize_t), DIMENSION(1:1) :: s1_dim = (/DIM1_SIZE/) ! size of DS 1 dataset - INTEGER(hsize_t), DIMENSION(1:1) :: s2_dim = (/DIM2_SIZE/) ! size of DS 2 dataset - REAL, DIMENSION(1:DIM1_SIZE) :: s1_wbuf = (/10,20,30/) ! data of DS 1 dataset - REAL, DIMENSION(1:DIM2_SIZE) :: s2_wbuf = (/10,20,50,100/) ! data of DS 2 dataset + INTEGER :: rankds = 1 ! rank of DS dataset + INTEGER(hsize_t), DIMENSION(1:rank) :: dims = (/DIM2_SIZE,DIM1_SIZE/) ! size of data dataset + INTEGER, DIMENSION(1:DIM_DATA) :: buf = (/1,2,3,4,5,6,7,8,9,10,11,12/) ! data of data dataset + INTEGER(hsize_t), DIMENSION(1:1) :: s1_dim = (/DIM1_SIZE/) ! size of DS 1 dataset + INTEGER(hsize_t), DIMENSION(1:1) :: s2_dim = (/DIM2_SIZE/) ! size of DS 2 dataset + REAL, DIMENSION(1:DIM1_SIZE) :: s1_wbuf = (/10,20,30/) ! data of DS 1 dataset + REAL, DIMENSION(1:DIM2_SIZE) :: s2_wbuf = (/10,20,50,100/) ! data of DS 2 dataset INTEGER :: err INTEGER :: num_scales INTEGER(size_t) :: name_len @@ -56,7 +56,7 @@ PROGRAM example_ds ! create a file using default properties CALL H5Fcreate_f("ex_ds1.h5",H5F_ACC_TRUNC_F, fid, err) - ! make a dataset + ! make a dataset CALL H5LTmake_dataset_int_f(fid, DSET_NAME, rank,dims,buf, err) ! make a DS dataset for the first dimension @@ -69,7 +69,7 @@ PROGRAM example_ds ! attach the DS_1_NAME dimension scale to DSET_NAME at dimension 1 ! and then detach it. !------------------------------------------------------------------------- - + ! get the dataset id for DSET_NAME CALL H5Dopen_f(fid, DSET_NAME, did, err) @@ -82,11 +82,11 @@ PROGRAM example_ds ! attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 1 CALL H5DSattach_scale_f(did, dsid, DIM1, err) - ! Test if dimension Scale Attached + ! Test if dimension Scale Attached CALL H5DSis_attached_f(did, dsid, DIM1, is_attached, err) WRITE(*,'(/,5X,3(A,1X),I0,A,L1)') 'Is',TRIM(DS_1_NAME),& 'attached to dimension',DIM1,' ... ',is_attached - + ! Check to see how many Dimension Scales are attached @@ -103,11 +103,11 @@ PROGRAM example_ds CALL H5DSis_attached_f(did, dsid, DIM1, is_attached, err) WRITE(*,'(/,5X,3(A,1X),I0,A,L1)') 'Is',TRIM(DS_1_NAME),& 'attached to dimension',DIM1,' ... ',is_attached - + !------------------------------------------------------------------------- ! set the DS_1_NAME dimension scale to DSET_NAME at dimension 1 !------------------------------------------------------------------------- - + WRITE(*,'(/,5A,I0)') & 'Set Dimension Scale "', TRIM(DS_1_NAME), '" to "', TRIM(DSET_NAME), '" at dimension ', DIM1 @@ -123,11 +123,11 @@ PROGRAM example_ds name = '' CALL H5DSget_scale_name_f(dsid, name, name_len, err) - WRITE(*,'(/,5X,A,A)') 'The Dimension Scale name is ... ', name(1:name_len) + WRITE(*,'(/,5X,A,A)') 'The Dimension Scale name is ... ', name(1:name_len) ! Setting Dimension Scale Label - WRITE(*,'(/,A,I0)') "Setting Dimension Scale label ""X"" for dimension ", DIM1 + WRITE(*,'(/,A,I0)') "Setting Dimension Scale label ""X"" for dimension ", DIM1 CALL H5DSset_label_f(did, DIM1, "X", err) @@ -139,11 +139,11 @@ PROGRAM example_ds ! close DS id CALL H5Dclose_f(dsid, err) - + !------------------------------------------------------------------------- ! attach the DS_2_NAME dimension scale to DSET_NAME !------------------------------------------------------------------------- - + ! get the DS dataset id CALL H5Dopen_f(fid, DS_2_NAME, dsid, err) @@ -163,7 +163,7 @@ PROGRAM example_ds name = '' CALL H5DSget_scale_name_f(dsid, name(1:name_len), name_len, err) - WRITE(*,'(/,5X,A,A)') 'The Dimension Scale name is ... ', name(1:name_len) + WRITE(*,'(/,5X,A,A)') 'The Dimension Scale name is ... ', name(1:name_len) ! Setting Dimension Scale Label @@ -177,13 +177,13 @@ PROGRAM example_ds label_len = 25 label = '' CALL H5DSget_label_f(did, DIM2, label, label_len, err) - + WRITE(*,'(/,5X,A,I0,2A,/)') 'Dimension Scale Label for dimension ', DIM2, ' is ... ', label(1:label_len) ! close DS id CALL H5Dclose_f(dsid, err) - ! close file + ! close file CALL H5Fclose_f(fid, err) END PROGRAM example_ds diff --git a/hl/fortran/examples/run-hlfortran-ex.sh.in b/hl/fortran/examples/run-hlfortran-ex.sh.in index d7de8e3..86acd27 100644 --- a/hl/fortran/examples/run-hlfortran-ex.sh.in +++ b/hl/fortran/examples/run-hlfortran-ex.sh.in @@ -80,5 +80,5 @@ rm *.o rm *.h5 echo -exit $EXIT_VALUE +exit $EXIT_VALUE diff --git a/hl/fortran/src/H5DSfc.c b/hl/fortran/src/H5DSfc.c index 0bb594d..f99fa4d 100644 --- a/hl/fortran/src/H5DSfc.c +++ b/hl/fortran/src/H5DSfc.c @@ -33,15 +33,15 @@ *------------------------------------------------------------------------- */ int_f -h5dsset_scale_c(hid_t_f *dsid, _fcd dimname, size_t_f *dimnamelen) +h5dsset_scale_c(hid_t_f *dsid, _fcd dimname, size_t_f *dimnamelen) { char *c_dimname = NULL; int_f ret_value = 0; - + /* * convert FORTRAN name to C name */ - + if(*dimnamelen != 0) if(NULL == (c_dimname = (char *)HD5f2cstring(dimname, (size_t)*dimnamelen))) HGOTO_DONE(FAIL) @@ -78,17 +78,17 @@ h5dsset_scale_c(hid_t_f *dsid, _fcd dimname, size_t_f *dimnamelen) *------------------------------------------------------------------------- */ int_f -h5dsattach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) +h5dsattach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) { int_f ret_value = 0; - + /* * call H5DSset_scale function. */ - + if(H5DSattach_scale( (hid_t)*did, (hid_t)*dsid, (unsigned)*idx ) < 0) HGOTO_DONE(FAIL) - + done: return ret_value; @@ -111,17 +111,17 @@ h5dsattach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) *------------------------------------------------------------------------- */ int_f -h5dsdetach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) +h5dsdetach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) { int_f ret_value = 0; - + /* * call H5DSset_scale function. */ - + if(H5DSdetach_scale( (hid_t)*did, (hid_t)*dsid, (unsigned)*idx ) < 0) HGOTO_DONE(FAIL) - + done: return ret_value; @@ -144,11 +144,11 @@ h5dsdetach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx) *------------------------------------------------------------------------- */ int_f -h5dsis_attached_c( hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *is_attached) +h5dsis_attached_c( hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *is_attached) { int_f ret_value = 0; htri_t c_is_attached; - + /* * call H5DSis_attached function. */ @@ -157,7 +157,7 @@ h5dsis_attached_c( hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *is_attached) HGOTO_DONE(FAIL) *is_attached = (int_f)c_is_attached; - + done: return ret_value; @@ -179,20 +179,20 @@ h5dsis_attached_c( hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *is_attached) *------------------------------------------------------------------------- */ int_f -h5dsis_scale_c( hid_t_f *did, int_f *is_scale) +h5dsis_scale_c( hid_t_f *did, int_f *is_scale) { int_f ret_value = 0; htri_t c_is_scale; - + /* * call H5DSis_scale function. */ - + if((c_is_scale=H5DSis_scale( (hid_t)*did )) < 0) HGOTO_DONE(FAIL) *is_scale = (int_f)c_is_scale; - + done: return ret_value; @@ -215,15 +215,15 @@ h5dsis_scale_c( hid_t_f *did, int_f *is_scale) *------------------------------------------------------------------------- */ int_f -h5dsset_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *labellen) +h5dsset_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *labellen) { char *c_label = NULL; int_f ret_value = 0; - + /* * convert FORTRAN name to C name */ - + if(NULL == (c_label = (char *)HD5f2cstring(label, (size_t)*labellen))) HGOTO_DONE(FAIL) @@ -258,7 +258,7 @@ h5dsset_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *labellen) *------------------------------------------------------------------------- */ int_f -h5dsget_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *size) +h5dsget_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *size) { char *c_label = NULL; ssize_t size_c = -1; @@ -273,18 +273,18 @@ h5dsget_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *size) /* * call H5DSget_label function. */ - + if( (size_c = H5DSget_label( (hid_t)*did, (unsigned)*idx, c_label, (size_t)*size+1)) < 0) HGOTO_DONE(FAIL) /* * Convert C name to FORTRAN and place it in the given buffer */ - + HD5packFstring(c_label, _fcdtocp(label), (size_t)*size); done: - *size = (size_t_f)size_c; /* Don't subtract '1' because H5DSget_label doesn't include the + *size = (size_t_f)size_c; /* Don't subtract '1' because H5DSget_label doesn't include the * trailing NULL in the length calculation, Ref. HDFFV-7596 */ if(c_label) HDfree(c_label); return ret_value; @@ -307,7 +307,7 @@ done: *------------------------------------------------------------------------- */ int_f -h5dsget_scale_name_c(hid_t_f *did, _fcd name, size_t_f *size) +h5dsget_scale_name_c(hid_t_f *did, _fcd name, size_t_f *size) { char *c_scale_name = NULL; ssize_t size_c = -1; @@ -322,7 +322,7 @@ h5dsget_scale_name_c(hid_t_f *did, _fcd name, size_t_f *size) /* * call H5DSget_scale_name function. */ - + if( (size_c = H5DSget_scale_name( (hid_t)*did, c_scale_name, (size_t)*size+1)) < 0) HGOTO_DONE(FAIL) @@ -354,17 +354,17 @@ done: *------------------------------------------------------------------------- */ int_f -h5dsget_num_scales_c( hid_t_f *did, int_f *idx, int_f *num_scales) +h5dsget_num_scales_c( hid_t_f *did, int_f *idx, int_f *num_scales) { int_f ret_value = 0; - + /* * call H5DSset_scale function. */ - + if( (*num_scales = (int_f)H5DSget_num_scales( (hid_t)*did, (unsigned)*idx)) < 0) HGOTO_DONE(FAIL) - + done: return ret_value; diff --git a/hl/fortran/src/H5LTf90proto.h b/hl/fortran/src/H5LTf90proto.h index 031db2c..44a2fee 100644 --- a/hl/fortran/src/H5LTf90proto.h +++ b/hl/fortran/src/H5LTf90proto.h @@ -174,9 +174,9 @@ h5ltread_dataset_string_c (hid_t_f *loc_id, HDF5_HL_F90CSTUBDLL int_f -h5ltpath_valid_c(hid_t_f *loc_id, - _fcd path, - size_t_f *pathlen, +h5ltpath_valid_c(hid_t_f *loc_id, + _fcd path, + size_t_f *pathlen, int_f *check_object_valid_c); /*------------------------------------------------------------------------- @@ -429,7 +429,7 @@ h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen2, size_t_f *lenmax, _fcd field_names, - size_t_f *maxlen_out); + size_t_f *maxlen_out); #endif /* _H5LTf90proto_H */ diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c index 0f8a58f..3597c3a 100644 --- a/hl/fortran/src/H5LTfc.c +++ b/hl/fortran/src/H5LTfc.c @@ -438,7 +438,7 @@ h5ltget_attribute_c(hid_t_f *loc_id, else goto done; } - + if (ret < 0) goto done; @@ -512,7 +512,7 @@ h5ltget_attribute_string_c(hid_t_f *loc_id, /* * Convert C name to FORTRAN and place it in the given buffer */ - HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buf_size); + HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buf_size); ret_value = 0; @@ -893,9 +893,9 @@ done: */ int_f -h5ltpath_valid_c(hid_t_f *loc_id, - _fcd path, - size_t_f *pathlen, +h5ltpath_valid_c(hid_t_f *loc_id, + _fcd path, + size_t_f *pathlen, int_f *check_object_valid_c) { htri_t ret = -1; @@ -907,7 +907,7 @@ h5ltpath_valid_c(hid_t_f *loc_id, */ if( NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen))) goto done; - + check_object_valid = FALSE; if(*check_object_valid_c == 1) check_object_valid = TRUE; diff --git a/hl/fortran/src/H5TBfc.c b/hl/fortran/src/H5TBfc.c index 331f0bc..285cd84 100644 --- a/hl/fortran/src/H5TBfc.c +++ b/hl/fortran/src/H5TBfc.c @@ -142,7 +142,7 @@ int_f h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset, hid_t_f *field_types, hsize_t_f *chunk_size, - void *fill_data, int_f *compress, + void *fill_data, int_f *compress, size_t_f *char_len_field_names, /* field_names lengths */ size_t_f *max_char_size_field_names, /* char len of fields */ char *field_names, @@ -233,7 +233,7 @@ done: /*------------------------------------------------------------------------- * Function: h5tbread_table_c * -* Purpose: Call H5TBread_table using F2003 features +* Purpose: Call H5TBread_table using F2003 features * * Return: Success: 0, Failure: -1 * @@ -261,7 +261,7 @@ h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfiel */ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - + if(NULL == (c_dst_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) if(NULL == (c_dst_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) @@ -270,7 +270,7 @@ h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfiel for(i = 0; i < c_nfields; i++) { c_dst_offset[i] = (size_t)dst_offset[i]; c_dst_sizes[i] = (size_t)dst_sizes[i]; - } /* end for */ + } /* end for */ /* * call H5TBread_table function. @@ -514,7 +514,7 @@ h5tbinsert_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *name * call H5TBinsert_field function. */ - if(H5TBinsert_field((hid_t)*loc_id, c_name, c_name1, (hid_t)*field_type, + if(H5TBinsert_field((hid_t)*loc_id, c_name, c_name1, (hid_t)*field_type, (hsize_t)*position, NULL, buf) < 0) HGOTO_DONE(FAIL) @@ -683,7 +683,7 @@ h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *n if(H5TBget_field_info((hid_t)*loc_id, c_name, c_field_names, c_field_sizes, c_field_offsets, &c_type_size) < 0) HGOTO_DONE(FAIL) - + /* return values */ /* names array */ @@ -709,7 +709,7 @@ h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *n field_offsets[i] = (size_t_f)c_field_offsets[i]; } /* end for */ - *maxlen_out = (size_t_f)length; + *maxlen_out = (size_t_f)length; done: if(c_name) diff --git a/hl/fortran/test/Makefile.am b/hl/fortran/test/Makefile.am index 0552aaa..5d1ab2e 100644 --- a/hl/fortran/test/Makefile.am +++ b/hl/fortran/test/Makefile.am @@ -36,7 +36,7 @@ check_PROGRAMS=$(TEST_PROG) LIBOBJS=$(top_builddir)/fortran/test/tf_gen.o -LDADD=$(LIBOBJS) $(LIBH5F_HL) $(LIBH5F) $(LIBH5_HL) $(LIBHDF5) +LDADD=$(LIBOBJS) $(LIBH5F_HL) $(LIBH5F) $(LIBH5_HL) $(LIBHDF5) # Source files for the programs tstds_SOURCES=tstds.F90 diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c index 057c43b..0fbdab3 100644 --- a/hl/src/H5DO.c +++ b/hl/src/H5DO.c @@ -90,7 +90,7 @@ H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fi * This routine is copied from the fast forward feature branch: features/hdf5_ff * src/H5FF.c:H5DOappend() with the following modifications: * 1) Remove and replace macro calls such as - * FUNC_ENTER_API, H5TRACE, HGOTO_ERROR + * FUNC_ENTER_API, H5TRACE, HGOTO_ERROR * accordingly because hl does not have these macros * 2) Replace H5I_get_type() by H5Iget_type() * 3) Replace H5P_isa_class() by H5Pisa_class() @@ -103,7 +103,7 @@ H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fi *------------------------------------------------------------------------- */ herr_t -H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, +H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, const void *buf) { hbool_t created_dxpl = FALSE; /* Whether we created a DXPL */ @@ -161,7 +161,7 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, if(H5Sget_simple_extent_dims(space_id, size, NULL) < 0) goto done; - /* Adjust the dimension size of the requested dimension, + /* Adjust the dimension size of the requested dimension, * but first record the old dimension size */ old_size = size[axis]; diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 067992f..520d464 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -143,7 +143,7 @@ herr_t H5DSattach_scale(hid_t did, H5O_info_t oi1, oi2; H5I_type_t it1, it2; int i; - size_t len; + size_t len; int found_ds=0; htri_t is_scale; @@ -156,7 +156,7 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* the dataset cannot be a DS dataset */ - if ( is_scale == 1) + if (is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -177,7 +177,7 @@ herr_t H5DSattach_scale(hid_t did, if ((it2 = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it1 || H5I_DATASET!=it2) + if (H5I_DATASET != it1 || H5I_DATASET != it2) return FAIL; /* the DS dataset cannot have dimension scales */ @@ -202,19 +202,19 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* scalar rank */ - if (rank==0) - rank=1; + if (rank == 0) + rank = 1; /* close dataset space */ if (H5Sclose(sid) < 0) return FAIL; /* parameter range checking */ - if (idx>(unsigned)rank-1) + if (idx > (unsigned)rank-1) return FAIL; /*------------------------------------------------------------------------- @@ -508,7 +508,7 @@ herr_t H5DSattach_scale(hid_t did, *------------------------------------------------------------------------- */ - if((is_ds=H5DSis_scale(dsid)) < 0) + if((is_ds = H5DSis_scale(dsid)) < 0) return FAIL; if(is_ds == 0) { @@ -598,7 +598,7 @@ herr_t H5DSdetach_scale(hid_t did, /* check for valid types of identifiers */ - if(H5I_DATASET!=H5Iget_type(did) || H5I_DATASET!=H5Iget_type(dsid)) + if(H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) return FAIL; if((is_scale = H5DSis_scale(did)) < 0) @@ -626,7 +626,7 @@ herr_t H5DSdetach_scale(hid_t did, *------------------------------------------------------------------------- */ /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if ((has_dimlist = H5LT_find_attribute(did,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; if (has_dimlist == 0) @@ -637,7 +637,7 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ @@ -645,7 +645,7 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* parameter range checking */ - if (idx>(unsigned)rank-1) + if (idx > (unsigned)rank-1) return FAIL; /*------------------------------------------------------------------------- @@ -704,8 +704,7 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* same object, reset */ - if(dsid_oi.fileno == tmp_oi.fileno && dsid_oi.addr == tmp_oi.addr) - { + if(dsid_oi.fileno == tmp_oi.fileno && dsid_oi.addr == tmp_oi.addr) { /* If there are more than one reference in the VL element and the reference we found is not the last one, copy the last one to replace the found one since the order @@ -727,7 +726,7 @@ herr_t H5DSdetach_scale(hid_t did, we do not need to continue the search if it is found */ found_ds = 1; break; - } + } /* end if */ } /* j */ } /* if */ @@ -795,7 +794,7 @@ herr_t H5DSdetach_scale(hid_t did, if(H5Aread(aid, ntid, dsbuf) < 0) goto out; - for(ii=0; ii<nelmts; ii++) { + for(ii = 0; ii < nelmts; ii++) { /* First check if we have the same dimension index */ if(idx == dsbuf[ii].dim_idx) { /* get the reference to the dataset */ @@ -820,7 +819,7 @@ herr_t H5DSdetach_scale(hid_t did, nelmts--; found_dset=1; break; - } /* if */ + } /* end if */ } /* if we have the same dimension index */ } /* ii */ @@ -990,7 +989,7 @@ htri_t H5DSis_attached(hid_t did, if ((it2 = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it1 || H5I_DATASET!=it2) + if (H5I_DATASET != it1 || H5I_DATASET != it2) return FAIL; /*------------------------------------------------------------------------- @@ -1040,7 +1039,7 @@ htri_t H5DSis_attached(hid_t did, goto out; /* read */ - if (H5Aread(aid,tid,buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* iterate all the REFs in this dimension IDX */ @@ -1050,7 +1049,7 @@ htri_t H5DSis_attached(hid_t did, ref = ((hobj_ref_t *)buf[idx].p)[i]; /* get the scale id for this REF */ - if ((dsid_j = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for DS in the parameter list */ @@ -1073,7 +1072,7 @@ htri_t H5DSis_attached(hid_t did, /* close */ - if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf) < 0) + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; if (H5Sclose(sid) < 0) goto out; @@ -1123,7 +1122,7 @@ htri_t H5DSis_attached(hid_t did, if (dsbuf == NULL) goto out; - if (H5Aread(aid,ntid,dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; /*------------------------------------------------------------------------- @@ -1131,7 +1130,7 @@ htri_t H5DSis_attached(hid_t did, *------------------------------------------------------------------------- */ - for(i=0; i<nelmts; i++) + for(i = 0; i < nelmts; i++) { /* get the reference */ ref = dsbuf[i].ref; diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index a4818b8..2a7ed9b 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -44,7 +44,7 @@ herr_t H5IMmake_image_8bit( hid_t loc_id, hsize_t dims[IMAGE8_RANK]; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Initialize the image dimensions */ @@ -104,9 +104,9 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, hsize_t dims[IMAGE24_RANK]; /* check the arguments */ - if (interlace == NULL) + if (interlace == NULL) return -1; - if (dset_name == NULL) + if (dset_name == NULL) return -1; @@ -180,7 +180,7 @@ static herr_t find_palette(hid_t loc_id, int ret = H5_ITER_CONT; /* check the arguments */ - if (name == NULL) + if (name == NULL) return -1; /* Shut compiler up */ @@ -261,9 +261,9 @@ herr_t H5IMget_image_info( hid_t loc_id, int has_attr; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; - if (interlace == NULL) + if (interlace == NULL) return -1; /*assume initially we have no palettes attached*/ @@ -430,7 +430,7 @@ herr_t H5IMread_image( hid_t loc_id, hid_t did; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -483,7 +483,7 @@ herr_t H5IMmake_palette( hid_t loc_id, int has_pal; /* check the arguments */ - if (pal_name == NULL) + if (pal_name == NULL) return -1; /* Check if the dataset already exists */ @@ -548,11 +548,11 @@ herr_t H5IMlink_palette( hid_t loc_id, hsize_t dim_ref; int ok_pal; - + /* check the arguments */ - if (image_name == NULL) + if (image_name == NULL) return -1; - if (pal_name == NULL) + if (pal_name == NULL) return -1; /* The image dataset may or may not have the attribute "PALETTE" @@ -717,9 +717,9 @@ herr_t H5IMunlink_palette( hid_t loc_id, int ok_pal, has_pal; /* check the arguments */ - if(image_name == NULL) + if(image_name == NULL) return -1; - if(pal_name == NULL) + if(pal_name == NULL) return -1; /* Try to find the palette dataset */ @@ -818,7 +818,7 @@ herr_t H5IMget_npalettes( hid_t loc_id, int has_pal; /* check the arguments */ - if(image_name == NULL) + if(image_name == NULL) return -1; /*assume initially we have no palettes attached*/ @@ -916,7 +916,7 @@ herr_t H5IMget_palette_info( hid_t loc_id, hsize_t pal_maxdims[2]; /* check the arguments */ - if (image_name == NULL) + if (image_name == NULL) return -1; /* Open the dataset. */ @@ -1030,9 +1030,9 @@ herr_t H5IMget_palette( hid_t loc_id, hid_t pal_id; /* check the arguments */ - if (image_name == NULL) + if (image_name == NULL) return -1; - if (pal_data == NULL) + if (pal_data == NULL) return -1; @@ -1133,7 +1133,7 @@ herr_t H5IMis_image( hid_t loc_id, herr_t ret; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Assume initially fail condition */ @@ -1237,7 +1237,7 @@ herr_t H5IMis_palette( hid_t loc_id, herr_t ret; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Assume initially fail condition */ diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c index 1669a30..3106ea8 100644 --- a/hl/src/H5LD.c +++ b/hl/src/H5LD.c @@ -209,7 +209,7 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) valid = FALSE; end_of_fields = TRUE; break; - + case '\\': /* escape character */ ++fields_ptr; /* skip it */ if(*fields_ptr == '\0') @@ -241,7 +241,7 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) gotcomma = TRUE; break; - default: + default: *cur++ = *fields_ptr++; gotmember = TRUE; break; @@ -438,7 +438,7 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims /* Get dataset's dataspace */ if((sid = H5Dget_space(did)) < 0) goto done; - + /* Get the number of dimensions */ if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) goto done; @@ -508,7 +508,7 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims /* Get the total size of the dataset's datatypes */ if(0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL))) goto done; - + /* Allocate memory for reading in the elements in the dataset selection */ if(NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize))) goto done; diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 0074d02..5d16d67 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -29,19 +29,19 @@ char *myinput; size_t indent = 0; -/* File Image operations - - A file image is a representation of an HDF5 file in a memory - buffer. In order to perform operations on an image in a similar way +/* File Image operations + + A file image is a representation of an HDF5 file in a memory + buffer. In order to perform operations on an image in a similar way to a file, the application buffer is copied to a FAPL buffer, which - in turn is copied to a VFD buffer. Buffer copying can decrease - performance, especially when using large file images. A solution to - this issue is to simulate the copying of the application buffer, - when actually the same buffer is used for the FAPL and the VFD. - This is implemented by using callbacks that simulate the standard - functions for memory management (additional callbacks are used for - the management of associated data structures). From the application - standpoint, a file handle can be obtained from a file image by using + in turn is copied to a VFD buffer. Buffer copying can decrease + performance, especially when using large file images. A solution to + this issue is to simulate the copying of the application buffer, + when actually the same buffer is used for the FAPL and the VFD. + This is implemented by using callbacks that simulate the standard + functions for memory management (additional callbacks are used for + the management of associated data structures). From the application + standpoint, a file handle can be obtained from a file image by using the API routine H5LTopen_file_image(). This function takes a flag argument that indicates the HDF5 library how to handle the given image; several flag values can be combined by using the bitwise OR operator. @@ -61,9 +61,9 @@ size_t indent = 0; well. The application is responsible to release the image buffer. */ -/* Data structure to pass application data to callbacks. */ +/* Data structure to pass application data to callbacks. */ typedef struct { - void *app_image_ptr; /* Pointer to application buffer */ + void *app_image_ptr; /* Pointer to application buffer */ size_t app_image_size; /* Size of application buffer */ void *fapl_image_ptr; /* Pointer to FAPL buffer */ size_t fapl_image_size; /* Size of FAPL buffer */ @@ -88,17 +88,17 @@ static herr_t udata_free(void *udata); /*------------------------------------------------------------------------- -* Function: image_malloc +* Function: image_malloc * * Purpose: Simulates malloc() function to avoid copying file images. * The application buffer is set to the buffer on only one FAPL. * Then the FAPL buffer can be copied to other FAPL buffers or -* to only one VFD buffer. +* to only one VFD buffer. * * Return: Address of "allocated" buffer, if successful. Otherwise, it returns * NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -109,23 +109,23 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; void * return_value = NULL; - + /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch ( file_image_op ) { /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - if (udata->app_image_ptr == NULL) + if (udata->app_image_ptr == NULL) goto out; - if (udata->app_image_size != size) + if (udata->app_image_size != size) goto out; - if (udata->fapl_image_ptr != NULL) + if (udata->fapl_image_ptr != NULL) goto out; - if (udata->fapl_image_size != 0) + if (udata->fapl_image_size != 0) goto out; - if (udata->fapl_ref_count != 0) + if (udata->fapl_ref_count != 0) goto out; udata->fapl_image_ptr = udata->app_image_ptr; @@ -135,11 +135,11 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - if (udata->fapl_image_ptr == NULL) + if (udata->fapl_image_ptr == NULL) goto out; - if (udata->fapl_image_size != size) + if (udata->fapl_image_size != size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; return_value = udata->fapl_image_ptr; @@ -151,17 +151,17 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) case H5FD_FILE_IMAGE_OP_FILE_OPEN: /* FAPL buffer is "copied" to only one VFD buffer */ - if (udata->vfd_image_ptr != NULL) + if (udata->vfd_image_ptr != NULL) goto out; - if (udata->vfd_image_size != 0) + if (udata->vfd_image_size != 0) goto out; - if (udata->vfd_ref_count != 0) + if (udata->vfd_ref_count != 0) goto out; - if (udata->fapl_image_ptr == NULL) + if (udata->fapl_image_ptr == NULL) goto out; - if (udata->fapl_image_size != size) + if (udata->fapl_image_size != size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; udata->vfd_image_ptr = udata->fapl_image_ptr; @@ -189,15 +189,15 @@ out: /*------------------------------------------------------------------------- * Function: image_memcpy * -* Purpose: Simulates memcpy() function to avoid copying file images. +* Purpose: Simulates memcpy() function to avoid copying file images. * The image buffer can be set to only one FAPL buffer, and * "copied" to only one VFD buffer. The FAPL buffer can be -* "copied" to other FAPLs buffers. +* "copied" to other FAPLs buffers. * * Return: The address of the destination buffer, if successful. Otherwise, it * returns NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -210,31 +210,31 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch(file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - if (dest != udata->fapl_image_ptr) + if (dest != udata->fapl_image_ptr) goto out; - if (src != udata->app_image_ptr) + if (src != udata->app_image_ptr) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (size != udata->app_image_size) + if (size != udata->app_image_size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - if (dest != udata->fapl_image_ptr) + if (dest != udata->fapl_image_ptr) goto out; - if (src != udata->fapl_image_ptr) + if (src != udata->fapl_image_ptr) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (udata->fapl_ref_count < 2) + if (udata->fapl_ref_count < 2) goto out; break; @@ -242,17 +242,17 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file goto out; case H5FD_FILE_IMAGE_OP_FILE_OPEN: - if (dest != udata->vfd_image_ptr) + if (dest != udata->vfd_image_ptr) goto out; - if (src != udata->fapl_image_ptr) + if (src != udata->fapl_image_ptr) goto out; - if (size != udata->vfd_image_size) + if (size != udata->vfd_image_size) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; break; @@ -273,15 +273,15 @@ out: /*------------------------------------------------------------------------- -* Function: image_realloc +* Function: image_realloc * * Purpose: Reallocates the shared application image buffer and updates data -* structures that manage buffer "copying". -* +* structures that manage buffer "copying". +* * Return: Address of reallocated buffer, if successful. Otherwise, it returns -* NULL. +* NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -294,29 +294,29 @@ image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void * void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - /* realloc() is not allowed when the HDF5 library won't release the image + /* realloc() is not allowed when the HDF5 library won't release the image buffer because reallocation may change the address of the buffer. The new address cannot be communicated to the application to release it. */ - if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) - goto out; + if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) + goto out; /* realloc() is not allowed if the image is open in read-only mode */ - if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) - goto out; + if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) + goto out; if (file_image_op == H5FD_FILE_IMAGE_OP_FILE_RESIZE) { - if (udata->vfd_image_ptr != ptr) - goto out; + if (udata->vfd_image_ptr != ptr) + goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; if (NULL == (udata->vfd_image_ptr = HDrealloc(ptr, size))) - goto out; - + goto out; + udata->vfd_image_size = size; return_value = udata->vfd_image_ptr; } /* end if */ @@ -337,9 +337,9 @@ out: * reference counters. Shared application buffer is actually * deallocated if there are no outstanding references. * -* Return: SUCCEED or FAIL +* Return: SUCCEED or FAIL * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -351,19 +351,19 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch(file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - if (udata->fapl_image_ptr != ptr) + if (udata->fapl_image_ptr != ptr) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; udata->fapl_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->fapl_image_ptr); @@ -374,14 +374,14 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) break; case H5FD_FILE_IMAGE_OP_FILE_CLOSE: - if (udata->vfd_image_ptr != ptr) + if (udata->vfd_image_ptr != ptr) goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; udata->vfd_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->vfd_image_ptr); @@ -410,7 +410,7 @@ out: /*------------------------------------------------------------------------- -* Function: udata_copy +* Function: udata_copy * * Purpose: Simulates the copying of the user data structure utilized in the * management of the "copying" of file images. @@ -418,7 +418,7 @@ out: * Return: Address of "newly allocated" structure, if successful. Otherwise, it * returns NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -430,9 +430,9 @@ udata_copy(void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - if (udata->ref_count == 0) + if (udata->ref_count == 0) goto out; udata->ref_count++; @@ -449,11 +449,11 @@ out: * * Purpose: Simulates deallocation of the user data structure utilized in the * management of the "copying" of file images. The data structure is -* actually deallocated when there are no outstanding references. +* actually deallocated when there are no outstanding references. * -* Return: SUCCEED or FAIL +* Return: SUCCEED or FAIL * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -465,9 +465,9 @@ udata_free(void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - if (udata->ref_count == 0) + if (udata->ref_count == 0) goto out; udata->ref_count--; @@ -479,7 +479,7 @@ udata_free(void *_udata) return(SUCCEED); -out: +out: return(FAIL); } /* end udata_free */ @@ -522,7 +522,7 @@ H5LT_make_dataset_numerical( hid_t loc_id, hid_t did = -1, sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Create the data space for the dataset. */ @@ -801,7 +801,7 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, size_t size; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* create a string data type */ @@ -852,11 +852,11 @@ out: /*------------------------------------------------------------------------- * Function: H5LTopen_file_image * -* Purpose: Open a user supplied file image using the core file driver. +* Purpose: Open a user supplied file image using the core file driver. * * Return: File identifier, Failure: -1 * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -871,22 +871,22 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) size_t min_incr = 65536; /* Minimum buffer increment */ double buf_prcnt = 0.1f; /* Percentage of buffer size to set as increment */ - static long file_name_counter; - H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, - &image_realloc, &image_free, - &udata_copy, &udata_free, + static long file_name_counter; + H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, + &image_realloc, &image_free, + &udata_copy, &udata_free, (void *)NULL}; /* check arguments */ - if (buf_ptr == NULL) + if (buf_ptr == NULL) goto out; - if (buf_size == 0) + if (buf_size == 0) goto out; if (flags & (unsigned)~(H5LT_FILE_IMAGE_ALL)) goto out; /* Create FAPL to transmit file image */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto out; /* set allocation increment to a percentage of the supplied buffer size, or @@ -898,7 +898,7 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) alloc_incr = min_incr; /* Configure FAPL to use the core file driver */ - if (H5Pset_fapl_core(fapl, alloc_incr, FALSE) < 0) + if (H5Pset_fapl_core(fapl, alloc_incr, FALSE) < 0) goto out; /* Set callbacks for file image ops ONLY if the file image is NOT copied */ @@ -932,10 +932,10 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) } /* end if */ /* Assign file image in user buffer to FAPL */ - if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) + if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) goto out; - /* set file open flags */ + /* set file open flags */ if (flags & H5LT_FILE_IMAGE_OPEN_RW) file_open_flags = H5F_ACC_RDWR; else @@ -943,17 +943,17 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) /* define a unique file name */ HDsnprintf(file_name, (sizeof(file_name) - 1), "file_image_%ld", file_name_counter++); - - /* Assign file image in FAPL to the core file driver */ - if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) + + /* Assign file image in FAPL to the core file driver */ + if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) goto out; /* Close FAPL */ - if (H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto out; - /* Return file identifier */ - return file_id; + /* Return file identifier */ + return file_id; out: H5E_BEGIN_TRY { @@ -983,7 +983,7 @@ H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void hid_t did; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1178,7 +1178,7 @@ herr_t H5LTread_dataset_string( hid_t loc_id, hid_t tid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1231,7 +1231,7 @@ herr_t H5LTget_dataset_ndims( hid_t loc_id, hid_t sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1291,7 +1291,7 @@ herr_t H5LTget_dataset_info( hid_t loc_id, hid_t sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* open the dataset. */ @@ -1368,9 +1368,9 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d int ret = 0; /* check the arguments */ - if (name == NULL) + if (name == NULL) return ret; - + /* Shut the compiler up */ loc_id = loc_id; linfo = linfo; @@ -1407,13 +1407,18 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d * *------------------------------------------------------------------------- */ - +/* H5Literate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: dset_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LTfind_dataset( hid_t loc_id, const char *dset_name ) { return H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } - +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- * @@ -1455,11 +1460,11 @@ herr_t H5LTset_attribute_string( hid_t loc_id, size_t attr_size; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; - if (attr_data == NULL) + if (attr_data == NULL) return -1; /* Open the object */ @@ -1552,9 +1557,9 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, int has_attr; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -1969,7 +1974,7 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, int ret = H5_ITER_CONT; /* check the arguments */ - if (name == NULL) + if (name == NULL) return H5_ITER_CONT; /* Shut compiler up */ @@ -2033,13 +2038,18 @@ herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) * *------------------------------------------------------------------------- */ - +/* H5Aiterate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: attr_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } - +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- @@ -2066,9 +2076,9 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -2139,9 +2149,9 @@ herr_t H5LTget_attribute_info( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -2220,7 +2230,7 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) hid_t type_id; /* check the arguments */ - if (text == NULL) + if (text == NULL) return -1; if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) @@ -2263,8 +2273,8 @@ out: * *------------------------------------------------------------------------- */ -static char* -realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_add) +static char* +realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add) { size_t size_str_to_add, size_str; @@ -2288,7 +2298,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad /* find the size of the current buffer */ size_str = HDstrlen(buf); - /* Check to make sure the appended string does not + /* Check to make sure the appended string does not * extend past the allocated buffer; if it does then truncate the string */ if(size_str < *len - 1) { @@ -2360,7 +2370,6 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) { char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - unsigned char *copy = NULL; /*a pointer to value array */ int nmembs; /*number of members */ char tmp_str[TMP_LEN]; int nchars; /*number of output characters */ @@ -2418,17 +2427,15 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "%*s ", MAX(0, 16 - nchars), ""); + HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); + tmp_str[MAX(3, 19 - nchars)] = '\0'; if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value + (size_t)i * dst_size; if (H5T_SGN_NONE == H5Tget_sign(native)) - HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int*)((void *)copy))); + HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); else - HDsnprintf(tmp_str, TMP_LEN, "%d", *((int*)((void *)copy))); + HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; @@ -2450,8 +2457,12 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) out: if(0 == nmembs) { - HDsnprintf(tmp_str, TMP_LEN, "\n%*s <empty>", (int)(indt + 4), ""); + str = realloc_and_append(no_ubuf, str_len, str, "\n"); + HDassert((indt + 4) < TMP_LEN); + HDmemset(tmp_str, ' ', (indt + 4) + 1); + tmp_str[(indt + 4)] = '\0'; str = realloc_and_append(no_ubuf, str_len, str, tmp_str); + str = realloc_and_append(no_ubuf, str_len, str, " <empty>"); } /* end if */ /* Release resources */ @@ -2544,7 +2555,7 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) goto out; - + if(lang != H5LT_DDL) { HDsnprintf(dt_str, *slen, "only DDL is supported for now"); goto out; @@ -3111,9 +3122,9 @@ herr_t H5LTget_attribute_string( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -3121,9 +3132,9 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) { - H5Oclose(obj_id); + H5Oclose(obj_id); return -1; } @@ -3537,9 +3548,9 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, hid_t attr_id = -1; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -3779,7 +3790,7 @@ H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) ret_value = FALSE; goto done; } - + /* Determine if link resolves to an actual object */ if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 47be98a..6df7c4b 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -20,7 +20,7 @@ /* user supplied image buffer. The same image is open with the core driver. */ #define H5LT_FILE_IMAGE_DONT_RELEASE 0x0004 /* The HDF5 lib won't */ /* deallocate user supplied image buffer. The user application is reponsible */ -/* for doing so. */ +/* for doing so. */ #define H5LT_FILE_IMAGE_ALL 0x0007 typedef enum H5LT_lang_t { diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index a4bcbd4..c54c41f 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -102,7 +102,7 @@ herr_t H5TBmake_table(const char *table_title, if (field_names == NULL) { goto out; } - + dims[0] = nrecords; dims_chunk[0] = chunk_size; @@ -300,7 +300,7 @@ herr_t H5TBappend_records(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* get the original number of records and fields */ @@ -374,7 +374,7 @@ herr_t H5TBwrite_records(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* open the dataset. */ @@ -477,9 +477,9 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; - if (field_names == NULL) + if (field_names == NULL) goto out; /* create xfer properties to preserve initialized data */ @@ -640,7 +640,7 @@ herr_t H5TBwrite_fields_index(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* create xfer properties to preserve initialized data */ @@ -801,7 +801,7 @@ herr_t H5TBread_table(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* open the dataset. */ @@ -878,7 +878,7 @@ herr_t H5TBread_records(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* get the number of records and fields */ @@ -959,9 +959,9 @@ herr_t H5TBread_fields_name(hid_t loc_id, /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; - if (field_names == NULL) + if (field_names == NULL) goto out; /* open the dataset */ @@ -1029,7 +1029,7 @@ herr_t H5TBread_fields_name(hid_t loc_id, /* check to make sure field was found, no reason to continue if it does not exist */ if(j == 0) goto out; - + /* get the dataspace handle */ if((sid = H5Dget_space(did)) < 0) goto out; @@ -1121,7 +1121,7 @@ herr_t H5TBread_fields_index(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* open the dataset. */ @@ -1281,9 +1281,9 @@ herr_t H5TBdelete_record(hid_t loc_id, unsigned char *tmp_buf = NULL; herr_t ret_val = -1; - + /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- @@ -1446,7 +1446,7 @@ herr_t H5TBinsert_record(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- @@ -1601,9 +1601,9 @@ herr_t H5TBadd_records_from(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name1 == NULL) + if (dset_name1 == NULL) goto out; - if (dset_name2 == NULL) + if (dset_name2 == NULL) goto out; /*------------------------------------------------------------------------- @@ -1754,11 +1754,11 @@ herr_t H5TBcombine_tables(hid_t loc_id1, herr_t ret_val = -1; /* check the arguments */ - if (dset_name1 == NULL) + if (dset_name1 == NULL) goto out; - if (dset_name2 == NULL) + if (dset_name2 == NULL) goto out; - if (dset_name3 == NULL) + if (dset_name3 == NULL) goto out; /*------------------------------------------------------------------------- @@ -2117,9 +2117,9 @@ herr_t H5TBinsert_field(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; - if (field_name == NULL) + if (field_name == NULL) goto out; /* get the number of records and fields */ @@ -2532,9 +2532,9 @@ herr_t H5TBdelete_field(hid_t loc_id, /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; - if (field_name == NULL) + if (field_name == NULL) goto out; /* get the number of records and fields */ @@ -2982,7 +2982,7 @@ htri_t H5TBAget_fill(hid_t loc_id, htri_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* get the number of records and fields */ @@ -3014,7 +3014,7 @@ htri_t H5TBAget_fill(hid_t loc_id, out: if(src_offset) HDfree(src_offset); - + return ret_val; } /* end H5TBAget_fill() */ @@ -3054,7 +3054,7 @@ herr_t H5TBget_table_info(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* open the dataset. */ @@ -3145,7 +3145,7 @@ herr_t H5TBget_field_info(hid_t loc_id, herr_t ret_val = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) goto out; /* open the dataset. */ @@ -3253,9 +3253,9 @@ hbool_t H5TB_find_field(const char *field, const char *field_list) const char *end; /* check the arguments */ - if (field == NULL) + if (field == NULL) return FALSE; - if (field_list == NULL) + if (field_list == NULL) return FALSE; while((end = HDstrstr(start, ",")) != 0) { diff --git a/hl/test/gen_test_ld.c b/hl/test/gen_test_ld.c index d717a47..981aded 100644 --- a/hl/test/gen_test_ld.c +++ b/hl/test/gen_test_ld.c @@ -13,23 +13,23 @@ #include "H5LDprivate.h" /* - * WATCH.h5: file with various types of datasets for testing-- + * WATCH.h5: file with various types of datasets for testing-- * - * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: - * DSET_ONE: one-dimensional dataset - * DSET_TWO: two-dimensional dataset - * DSET_CMPD: one-dimensional dataset with compound type + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with - * escape/separator characters - * DSET_CMPD_TWO: two-dimensional dataset with compound type - * - * The following datasets are one-dimensional, chunked, max. dimension setting: - * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY - * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE - * - * The following datasets are one-dimensional: - * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE - * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ #define ONE_DIMS0 10 #define MAX_ONE_DIMS0 100 diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index fd2d0d2..504a3f5 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -467,7 +467,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Dclose() failed"); } /* end for */ - PASSED() + PASSED(); HL_TESTING2("close file images"); diff --git a/hl/tools/gif2h5/Makefile.am b/hl/tools/gif2h5/Makefile.am index 9ffde58..9de2135 100644 --- a/hl/tools/gif2h5/Makefile.am +++ b/hl/tools/gif2h5/Makefile.am @@ -29,9 +29,9 @@ bin_PROGRAMS=gif2h5 h52gif h52gif_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) gif2h5_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c +gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c -h52gif_SOURCES=hdf2gif.c hdfgifwr.c +h52gif_SOURCES=hdf2gif.c hdfgifwr.c # Programs all depend on the hdf5 library, the tools library, and the HL @@ -42,7 +42,7 @@ if BUILD_TESTS_CONDITIONAL TEST_SCRIPT=h52giftest.sh check_SCRIPTS=$(TEST_SCRIPT) noinst_PROGRAMS=h52gifgentst - h52gifgentst_SOURCES=h52gifgentst.c + h52gifgentst_SOURCES=h52gifgentst.c endif CHECK_CLEANFILES+=*.h5 diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 8cd8a8e..129fa60 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -57,12 +57,12 @@ GIFBYTE *Raster; /* The raster data stream, unblocked * /* The hash table used by the decompressor */ -int Prefix[4096]; -int Suffix[4096]; +int *Prefix; +int *Suffix; /* An output array used by the decompressor */ -int OutCode[1025]; +int *OutCode; /* The color map, read from the GIF header */ @@ -159,6 +159,19 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) { int i; + if (!(Prefix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(Suffix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(OutCode = calloc(1024, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + XC = 0; YC = 0; Pass = 0; @@ -309,5 +322,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) Code = ReadCode(); } + free(Prefix); + free(Suffix); + free(OutCode); + return Image; } diff --git a/hl/tools/gif2h5/h52giftest.sh.in b/hl/tools/gif2h5/h52giftest.sh.in index 5643e30..02c9e89 100644 --- a/hl/tools/gif2h5/h52giftest.sh.in +++ b/hl/tools/gif2h5/h52giftest.sh.in @@ -70,20 +70,20 @@ echo "" # Positive tests for h52gif echo "**validate the h52gif tool processes input correctly..." -TESTING "./h52gif h52giftst.h5 image1.gif -i image" +TESTING "./h52gif h52giftst.h5 image1.gif -i image" TOOLTEST ./h52gif $TESTFILE1 image1.gif -i image echo "" # Negative tests. echo "**verify that the h52gif tool handles error conditions correctly..." # nonexisting dataset name -TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image" -TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image" +TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image" +TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image" # this test should have failed but it did not. Comment it out for now. -#TESTING "./h52gif h52giftst.h5 image.gif -i palette" -#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette" -TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel" -TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel" +#TESTING "./h52gif h52giftst.h5 image.gif -i palette" +#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette" +TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel" +TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel" echo "" # all done. summarize results. diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index ed3e9e9..d44ff7a 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -69,45 +69,6 @@ static void char_init(), char_out(), flush_char(); static byte pc2nc[256]; -/*************************************************************/ -int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, - byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, - int colorstyle, int BitsPerPixel) -{ - int InitCodeSize; - int i; - byte *pic8 = pic; - - /* Shut compiler up... */ - ptype=ptype; - rmap=rmap; - gmap=gmap; - bmap=bmap; - numcols=numcols; - colorstyle=colorstyle; - - for (i = 0; i < 256; i++) { - pc2nc[i] = pc2ncmap[i]; - } - - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - - if (!fp) { - fprintf(stderr, "WriteGIF: file not open for writing\n" ); - return (1); - } - - compress(InitCodeSize+1, fp, pic8, w*h); - - if (ferror(fp)) - return -1; - - return 0 ; -} - /***********************************************************************/ static unsigned long cur_accum = 0; static int cur_bits = 0; @@ -123,8 +84,8 @@ static int maxbits = XV_BITS; /* user settable max # bits/code */ static int maxcode; /* maximum code, given n_bits */ static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */ -static count_int htab [HSIZE]; -static unsigned short codetab [HSIZE]; +static count_int *htab; +static unsigned short *codetab; #define HashTabOf(i) htab[i] #define CodeTabOf(i) codetab[i] @@ -173,6 +134,57 @@ static FILE *g_outfile; static int ClearCode; static int EOFCode; +/*************************************************************/ +int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, + byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, + int colorstyle, int BitsPerPixel) +{ + int InitCodeSize; + int i; + byte *pic8 = pic; + + if (!(htab = calloc(HSIZE, sizeof(count_int)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + if (!(codetab = calloc(HSIZE, sizeof(unsigned short)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + + /* Shut compiler up... */ + ptype=ptype; + rmap=rmap; + gmap=gmap; + bmap=bmap; + numcols=numcols; + colorstyle=colorstyle; + + for (i = 0; i < 256; i++) { + pc2nc[i] = pc2ncmap[i]; + } + + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + + if (!fp) { + fprintf(stderr, "WriteGIF: file not open for writing\n"); + return 1; + } + + compress(InitCodeSize+1, fp, pic8, w*h); + + free(htab); + free(codetab); + + if (ferror(fp)) + return -1; + + return 0 ; +} + /********************************************************/ static void compress(int init_bits, FILE *outfile, byte *data, int len) { @@ -194,8 +206,6 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len) /* initialize 'compress' globals */ maxbits = XV_BITS; maxmaxcode = 1<<XV_BITS; - memset(htab, 0, sizeof(htab)); - memset(codetab, 0, sizeof(codetab)); hsize = HSIZE; free_ent = 0; clear_flg = 0; diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c index 4dcf25e..6b59ea1 100644 --- a/hl/tools/h5watch/extend_dset.c +++ b/hl/tools/h5watch/extend_dset.c @@ -66,7 +66,7 @@ typedef struct set_t { * * Extending a two-dimensional dataset by action1 and action2. * --action1 and action2 can be a positive # or negative # or 0. - * + * *********************************************************************** */ static herr_t @@ -399,12 +399,12 @@ main(int argc, const char *argv[]) if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { if(extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_ONE) || - !HDstrcmp(dname, DSET_ALLOC_LATE) || + } else if(!HDstrcmp(dname, DSET_ONE) || + !HDstrcmp(dname, DSET_ALLOC_LATE) || !HDstrcmp(dname, DSET_ALLOC_EARLY)) { if(extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_TWO) || + } else if(!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { if(extend_dset_two(fname, dname, action1, action2) < 0) goto error; diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c index 18e15fc..19c9876 100644 --- a/hl/tools/h5watch/h5watchgentest.c +++ b/hl/tools/h5watch/h5watchgentest.c @@ -15,23 +15,23 @@ #include "H5HLprivate2.h" /* - * WATCH.h5: file with various types of datasets for testing-- + * WATCH.h5: file with various types of datasets for testing-- * - * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: - * DSET_ONE: one-dimensional dataset - * DSET_TWO: two-dimensional dataset - * DSET_CMPD: one-dimensional dataset with compound type + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with - * escape/separator characters - * DSET_CMPD_TWO: two-dimensional dataset with compound type - * - * The following datasets are one-dimensional, chunked, max. dimension setting: - * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY - * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE - * - * The following datasets are one-dimensional: - * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE - * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ #define ONE_DIMS0 10 #define MAX_ONE_DIMS0 100 diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c index 7d11a73..7258c0f 100644 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -13,7 +13,7 @@ /* Purpose: This is a small program that checks if the HDF5_DRIVER * environment variable is set to a value that supports SWMR. - * + * * It is intended for use in shell scripts. */ |