From 36eb05f1cd2d2deb59f12e05ebba20460c46d8de Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 1 May 2024 16:52:45 -0500 Subject: [PATCH 1/8] Refactor error handling code to eliminate internal ID calls. All calls to the H5I routines are now made in API routines (sometimes in FUNC_ENTER/LEAVE_* macros), except for some calls to H5E_clear_stack() within the library, but I'm planning to remove those over time. Also, made all the library internal error messages into static const variables, instead of malloc'ing them, which means that they can just be referenced and not copied. Several new and updated auto-generated header files were necessary to enable this. Signed-off-by: Quincey Koziol --- bin/h5vers | 2 + bin/make_err | 177 ++++++-- src/CMakeLists.txt | 2 + src/H5D.c | 4 +- src/H5Dint.c | 2 +- src/H5Dvirtual.c | 4 +- src/H5E.c | 851 +++---------------------------------- src/H5Edeprec.c | 28 +- src/H5Eint.c | 1016 ++++++++++++++++++++++++++++++++++++++++---- src/H5Emajdef.h | 65 +++ src/H5Emindef.h | 212 +++++++++ src/H5Epkg.h | 64 +-- src/H5Eprivate.h | 11 +- src/H5FDfamily.c | 4 +- src/H5FDonion.c | 2 +- src/H5Fint.c | 18 +- src/H5Gint.c | 2 +- src/H5Gloc.c | 2 +- src/H5Gnode.c | 2 +- src/H5Gstab.c | 2 +- src/H5Gtraverse.c | 2 +- src/H5Iint.c | 74 +--- src/H5Iprivate.h | 1 - src/H5Ocopy.c | 2 +- src/H5Oint.c | 2 +- src/H5SM.c | 4 +- src/H5T.c | 14 +- src/H5Tcommit.c | 2 +- src/H5VLcallback.c | 2 +- src/H5Z.c | 8 +- src/H5private.h | 2 +- src/H5public.h | 4 + src/Makefile.am | 6 +- 33 files changed, 1519 insertions(+), 1074 deletions(-) create mode 100644 src/H5Emajdef.h create mode 100644 src/H5Emindef.h diff --git a/bin/h5vers b/bin/h5vers index 29470e1968b..129ad1bf526 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -95,6 +95,8 @@ sub setvers { $_[0] =~ s/^(\#\s*define\s+H5_VERS_MINOR\s+)\d+/$1$vers[1]/m; $_[0] =~ s/^(\#\s*define\s+H5_VERS_RELEASE\s+)\d+/$1$vers[2]/m; $_[0] =~ s/^(\#\s*define\s+H5_VERS_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_STR\s+\")[^\"]*/ + sprintf("%s%d.%d.%d%s%s", $1, @vers[0,1,2], $vers[3]?"-":"", $vers[3])/me; $_[0] =~ s/^(\#\s*define\s+H5_VERS_INFO\s+\")[^\"]*/ sprintf("%sHDF5 library version: %d.%d.%d%s%s", $1, @vers[0,1,2], $vers[3]?"-":"", $vers[3])/me; diff --git a/bin/make_err b/bin/make_err index 618a2df46ac..c83ed4d2450 100755 --- a/bin/make_err +++ b/bin/make_err @@ -47,7 +47,7 @@ sub print_warning ($) { my $fh = shift; print $fh "\n/* Generated automatically by bin/make_err -- do not edit */\n"; - print $fh "/* Add new errors to H5err.txt file */\n\n"; + print $fh "/* Add new errors to H5err.txt file */\n"; } ############################################################################## @@ -92,7 +92,7 @@ sub parse_line ($) { # Get the major error's name & description ($name, $desc) = ($line =~ /^\s*MAJOR,\s*(\w*),\s*(.*)\n/); #print "MAJOR: name=$name, desc=$desc\n"; - + # Check if the name already exists as a major or minor error message if(exists($major{$name}) || exists($minor{$name})) { die "duplicated name: $name"; @@ -103,12 +103,12 @@ sub parse_line ($) { } # Parse minor error lines elsif($line =~ /^\s*MINOR,/) { - my $min_section; # Minor errors have a section they below to also + my $min_section; # Minor errors have a section they belong to also # Get the minor error's section, name & description ($min_section, $name, $desc) = ($line =~ /^\s*MINOR,\s*(\w*),\s*(\w*),\s*(.*)\n/); #print "MINOR: min_section=$min_section, name=$name, desc=$desc\n"; - + # Check for valid section if(!exists($section{$min_section})) { die "unknown section: $min_section"; @@ -121,7 +121,7 @@ sub parse_line ($) { # Store the minor errors in a hash table, indexed by the name $minor{$name}=$desc; - + # Add the minor error to the list for the section push @{$section_list{$min_section}}, $name; } @@ -130,7 +130,7 @@ sub parse_line ($) { # Get the section's name & description ($name, $desc) = ($line =~ /^\s*SECTION,\s*(\w*),\s*(.*)\n/); #print "SECTION: name=$name, desc=$desc\n"; - + # Check if the section has already been defined if(exists($section{$name})) { die "duplicated name: $name"; @@ -178,10 +178,10 @@ sub create_public ($) { print HEADER "\n/*********************/\n"; print HEADER "/* Major error codes */\n"; print HEADER "/*********************/\n\n"; - foreach $name (keys %major) { + foreach $name (sort keys %major) { printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; } - foreach $name (keys %major) { + foreach $name (sort keys %major) { printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$major{$name}; } @@ -189,14 +189,14 @@ sub create_public ($) { print HEADER "\n/*********************/\n"; print HEADER "/* Minor error codes */\n"; print HEADER "/*********************/\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n/* $sect_desc */\n"; + foreach $sect_name (sort keys %section) { + print HEADER "\n/* $section{$sect_name} */\n"; # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { + for $name (sort @{$section_list{$sect_name}}) { printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; } - for $name ( @{$section_list{$sect_name}}) { + for $name (sort @{$section_list{$sect_name}}) { printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$minor{$name}; } } @@ -213,6 +213,84 @@ sub create_public ($) { close HEADER; } +############################################################################## +# Create the generated portion of the H5E major message definition code +# +sub create_majdef ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Emajdef.h"; # Name of file to generate + my $name; # Name of error message + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the major errors + print HEADER "\n/***********************************/\n"; + print HEADER "/* Major error message definitions */\n"; + print HEADER "/***********************************/\n\n"; + print HEADER "/* clang-format off */\n"; + foreach $name (sort keys %major) { + printf HEADER "static const H5E_msg_t ${name}_msg_s = {false, \"${major{$name}}\", H5E_MAJOR, &H5E_err_cls_s};\n"; + } + print HEADER "/* clang-format on */\n"; + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Create the generated portion of the H5E minor message definition code +# +sub create_mindef ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Emindef.h"; # Name of file to generate + my $name; # Name of error message + my $sect_name; # Section of minor error messages + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the minor error sections + print HEADER "\n/***********************************/\n"; + print HEADER "/* Minor error message definitions */\n"; + print HEADER "/***********************************/\n\n"; + print HEADER "/* clang-format off */\n"; + foreach $sect_name (sort keys %section) { + print HEADER "\n/* $sect_name: $section{$sect_name} */\n"; + + # Iterate over all the minor errors in each section + for $name (sort @{$section_list{$sect_name}}) { + printf HEADER "static const H5E_msg_t ${name}_msg_s = {false, \"${minor{$name}}\", H5E_MINOR, &H5E_err_cls_s};\n"; + } + } + print HEADER "/* clang-format on */\n"; + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + ############################################################################## # Create the generated portion of the H5E initialization code # @@ -220,11 +298,13 @@ sub create_init ($) { my $prefix = shift; # Get the prefix for the generated file my $file = "H5Einit.h"; # Name of file to generate my $name; # Name of error message + my $last_name; # Name of previous error message my $desc; # Description of error message my $sect_name; # Section of minor error messages my $sect_desc; # Description of section my $first_major = 0; # Whether the first major error code was saved my $first_minor = 0; # Whether the first minor error code was saved + my $num_msg; # Number of messages # Rename previous file # rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; @@ -239,14 +319,14 @@ sub create_init ($) { print_startprotect(*HEADER, $file); # Iterate over all the major errors + $num_msg = 0; print HEADER "\n/*********************/\n"; print HEADER "/* Major error codes */\n"; print HEADER "/*********************/\n\n"; - foreach $name (keys %major) { - print HEADER " "x(0*$indent),"assert(${name}_g==H5I_INVALID_HID);\n"; - print HEADER " "x(0*$indent),"if((msg = H5E__create_msg(cls, H5E_MAJOR, \"${major{$name}}\"))==NULL)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\");\n"; - print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, false))<0)\n"; + foreach $name (sort keys %major) { + print HEADER "/* $name */\n"; + print HEADER " "x(0*$indent),"assert(H5I_INVALID_HID == ${name}_g);\n"; + print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &${name}_msg_s, false)) < 0)\n"; print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n"; if ($first_major == 0) { print HEADER " "x(0*$indent),"\n/* Remember first major error code ID */\n"; @@ -255,24 +335,25 @@ sub create_init ($) { $first_major = 1; } $last_name = $name; + $num_msg++; } print HEADER " "x(0*$indent),"\n/* Remember last major error code ID */\n"; print HEADER " "x(0*$indent),"assert(H5E_last_maj_id_g==H5I_INVALID_HID);\n"; print HEADER " "x(0*$indent),"H5E_last_maj_id_g = ${last_name}_g;\n\n"; # Iterate over all the minor error sections + $num_msg = 0; print HEADER "\n/*********************/\n"; print HEADER "/* Minor error codes */\n"; print HEADER "/*********************/\n\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n"," "x(0*$indent),"/* $sect_desc */\n"; + foreach $sect_name (sort keys %section) { + print HEADER "\n/* $section{$sect_name} */\n"; # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - print HEADER " "x(0*$indent),"assert(${name}_g==H5I_INVALID_HID);\n"; - print HEADER " "x(0*$indent),"if((msg = H5E__create_msg(cls, H5E_MINOR, \"${minor{$name}}\"))==NULL)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\");\n"; - print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, true))<0)\n"; + for $name (sort @{$section_list{$sect_name}}) { + print HEADER "/* $name */\n"; + print HEADER " "x(0*$indent),"assert(H5I_INVALID_HID == ${name}_g);\n"; + print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &${name}_msg_s, false)) < 0)\n"; print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n"; if ($first_minor == 0) { @@ -282,6 +363,7 @@ sub create_init ($) { $first_minor = 1; } $last_name = $name; + $num_msg++; } } print HEADER " "x(0*$indent),"\n/* Remember last minor error code ID */\n"; @@ -319,25 +401,25 @@ sub create_term ($) { # Iterate over all the major errors print HEADER "\n/* Reset major error IDs */\n"; - foreach $name (keys %major) { - print HEADER " "x($indent),"\n${name}_g="; + foreach $name (sort keys %major) { + print HEADER " "x($indent),"${name}_g =\n"; } - print HEADER " H5I_INVALID_HID;\n"; - print HEADER " "x(0*$indent),"H5E_first_maj_id_g = H5I_INVALID_HID;\n\n"; + print HEADER " "x(2*$indent),"H5I_INVALID_HID;\n"; + print HEADER "\n"," "x(0*$indent),"H5E_first_maj_id_g = H5I_INVALID_HID;\n"; print HEADER " "x(0*$indent),"H5E_last_maj_id_g = H5I_INVALID_HID;\n\n"; # Iterate over all the minor error sections print HEADER "\n/* Reset minor error IDs */\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n"," "x(0*$indent),"\n/* $sect_desc */"; + foreach $sect_name (sort keys %section) { + print HEADER "\n/* $sect_name: $section{$sect_name} */\n"; # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - print HEADER " "x($indent),"\n${name}_g="; + for $name (sort @{$section_list{$sect_name}}) { + print HEADER " "x($indent),"${name}_g =\n"; } } - print HEADER " H5I_INVALID_HID;\n"; - print HEADER " "x(0*$indent),"H5E_first_min_id_g = H5I_INVALID_HID;\n\n"; + print HEADER " "x(2*$indent),"H5I_INVALID_HID;\n"; + print HEADER "\n"," "x(0*$indent),"H5E_first_min_id_g = H5I_INVALID_HID;\n"; print HEADER " "x(0*$indent),"H5E_last_min_id_g = H5I_INVALID_HID;\n\n"; print_endprotect(*HEADER, $file); @@ -356,6 +438,7 @@ sub create_define ($) { my $desc; # Description of error message my $sect_name; # Section of minor error messages my $sect_desc; # Description of section + my $num_msg; # Number of messages # Rename previous file # rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; @@ -370,21 +453,29 @@ sub create_define ($) { print_startprotect(*HEADER, $file); # Iterate over all the major errors + $num_msg = 0; print HEADER "\n/* Major error IDs */\n"; - foreach $name (keys %major) { - printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$major{$name}; + foreach $name (sort keys %major) { + printf HEADER "hid_t %-20s = H5I_INVALID_HID; /* %s */\n","${name}_g",$major{$name}; + $num_msg++; } + print HEADER "\n/* Number of major error messages */\n"; + printf HEADER "#define H5E_NUM_MAJ_ERRORS %d\n", $num_msg; # Iterate over all the minor error sections + $num_msg = 0; print HEADER "\n/* Minor error IDs */\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n/* $sect_desc */\n"; + foreach $sect_name (sort keys %section) { + print HEADER "\n/* $sect_name: $section{$sect_name} */\n"; # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$minor{$name}; + for $name (sort @{$section_list{$sect_name}}) { + printf HEADER "hid_t %-20s = H5I_INVALID_HID; /* %s */\n","${name}_g",$minor{$name}; + $num_msg++; } } + print HEADER "\n/* Number of minor error messages */\n"; + printf HEADER "#define H5E_NUM_MIN_ERRORS %d\n", $num_msg; print_endprotect(*HEADER, $file); @@ -409,10 +500,14 @@ for $file (@ARGV) { } } close SOURCE; - + # Create header files print "Generating 'H5Epubgen.h'\n"; create_public($prefix); + print "Generating 'H5Emajdef.h'\n"; + create_majdef($prefix); + print "Generating 'H5Emindef.h'\n"; + create_mindef($prefix); print "Generating 'H5Einit.h'\n"; create_init($prefix); print "Generating 'H5Eterm.h'\n"; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51464d53f5e..577e43521d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -881,6 +881,8 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Edefin.h ${HDF5_SRC_DIR}/H5Einit.h + ${HDF5_SRC_DIR}/H5Emajdef.h + ${HDF5_SRC_DIR}/H5Emindef.h ${HDF5_SRC_DIR}/H5Epkg.h ${HDF5_SRC_DIR}/H5Eprivate.h ${HDF5_SRC_DIR}/H5Eterm.h diff --git a/src/H5D.c b/src/H5D.c index d15c4fa2dcd..d014d27cacb 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -2137,7 +2137,7 @@ H5Dformat_convert(hid_t dset_id) /* Convert the dataset */ if (H5VL_dataset_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTUPDATE, FAIL, "can't convert dataset format"); done: FUNC_LEAVE_API(ret_value) @@ -2442,7 +2442,7 @@ H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t op, void *op_dat /* Iterate over the chunks */ if ((ret_value = H5VL_dataset_optional(vol_obj, &vol_cb_args, dxpl_id, H5_REQUEST_NULL)) < 0) - HERROR(H5E_BADITER, H5E_BADITER, "error iterating over dataset chunks"); + HERROR(H5E_DATASET, H5E_BADITER, "error iterating over dataset chunks"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Dint.c b/src/H5Dint.c index 71ddda387c7..66340c8fa54 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1495,7 +1495,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) /* Check if dataset was already open */ if (NULL == (shared_fo = (H5D_shared_t *)H5FO_opened(dataset->oloc.file, dataset->oloc.addr))) { /* Clear any errors from H5FO_opened() */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Open the dataset object */ if (H5D__open_oid(dataset, dapl_id) < 0) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index d6ab1a8836c..11874878fd7 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -884,7 +884,7 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir src_file_open = true; else /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ else /* Source file is ".", use the virtual dataset's file */ @@ -906,7 +906,7 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir /* Dataset does not exist */ if (NULL == source_dset->dset) { /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); source_dset->dset_exists = false; } /* end if */ diff --git a/src/H5E.c b/src/H5E.c index 4f2edd78ebf..b6be0a53084 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -57,10 +57,6 @@ /* Local Macros */ /****************/ -/* HDF5 error class */ -#define H5E_CLS_NAME "HDF5" -#define H5E_CLS_LIB_NAME "HDF5" - /******************/ /* Local Typedefs */ /******************/ @@ -72,30 +68,13 @@ /********************/ /* Local Prototypes */ /********************/ -/* Static function declarations */ -static herr_t H5E__set_default_auto(H5E_t *stk); -static H5E_cls_t *H5E__register_class(const char *cls_name, const char *lib_name, const char *version); -static herr_t H5E__unregister_class(H5E_cls_t *cls, void **request); -static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); -static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata); -static herr_t H5E__close_msg(H5E_msg_t *err, void **request); -static H5E_msg_t *H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); -static H5E_t *H5E__get_current_stack(void); -static herr_t H5E__set_current_stack(H5E_t *estack); -static herr_t H5E__close_stack(H5E_t *err_stack, void **request); -static ssize_t H5E__get_num(const H5E_t *err_stack); -static herr_t H5E__print2(hid_t err_stack, FILE *stream); -static herr_t H5E__append_stack(H5E_t *dst_estack, const H5E_t *src_stack); /*********************/ /* Package Variables */ /*********************/ -/* First & last major and minor error codes registered by the library */ -hid_t H5E_first_maj_id_g = H5I_INVALID_HID; -hid_t H5E_last_maj_id_g = H5I_INVALID_HID; -hid_t H5E_first_min_id_g = H5I_INVALID_HID; -hid_t H5E_last_min_id_g = H5I_INVALID_HID; +/* Declare extern the free list to manage the H5E_stack_t struct */ +H5FL_EXTERN(H5E_stack_t); /*****************************/ /* Library Private Variables */ @@ -105,280 +84,6 @@ hid_t H5E_last_min_id_g = H5I_INVALID_HID; /* Local Variables */ /*******************/ -/* Declare a free list to manage the H5E_t struct */ -H5FL_DEFINE_STATIC(H5E_t); - -/* Declare a free list to manage the H5E_cls_t struct */ -H5FL_DEFINE_STATIC(H5E_cls_t); - -/* Declare a free list to manage the H5E_msg_t struct */ -H5FL_DEFINE_STATIC(H5E_msg_t); - -/* Error class ID class */ -static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ - H5I_ERROR_CLASS, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5E__unregister_class /* Callback routine for closing objects of this class */ -}}; - -/* Error message ID class */ -static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ - H5I_ERROR_MSG, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ -}}; - -/* Error stack ID class */ -static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ - H5I_ERROR_STACK, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5E__close_stack /* Callback routine for closing objects of this class */ -}}; - -/*------------------------------------------------------------------------- - * Function: H5E_init - * - * Purpose: Initialize the interface from some other layer. - * - * Return: Success: non-negative - * Failure: negative - *------------------------------------------------------------------------- - */ -herr_t -H5E_init(void) -{ - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - char lib_vers[128]; /* Buffer to constructu library version within */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Initialize the ID group for the error class IDs */ - if (H5I_register_type(H5I_ERRCLS_CLS) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); - - /* Initialize the ID group for the major error IDs */ - if (H5I_register_type(H5I_ERRMSG_CLS) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); - - /* Initialize the ID group for the error stacks */ - if (H5I_register_type(H5I_ERRSTK_CLS) < 0) - HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); - -#ifndef H5_HAVE_THREADSAFE - H5E_stack_g[0].nused = 0; - H5E__set_default_auto(H5E_stack_g); -#endif /* H5_HAVE_THREADSAFE */ - - /* Allocate the HDF5 error class */ - assert(H5E_ERR_CLS_g == (-1)); - snprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, - (strlen(H5_VERS_SUBRELEASE) > 0 ? "-" H5_VERS_SUBRELEASE : "")); - if (NULL == (cls = H5E__register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "class initialization failed"); - if ((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls, false)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class"); - -/* Include the automatically generated error code initialization */ -#include "H5Einit.h" - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/*------------------------------------------------------------------------- - * Function: H5E_term_package - * - * Purpose: Terminates the H5E interface - * - * Return: Success: Positive if anything is done that might - * affect other interfaces; zero otherwise. - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -int -H5E_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - int64_t ncls, nmsg, nstk; - - /* Check if there are any open error stacks, classes or messages */ - ncls = H5I_nmembers(H5I_ERROR_CLASS); - nmsg = H5I_nmembers(H5I_ERROR_MSG); - nstk = H5I_nmembers(H5I_ERROR_STACK); - - if ((ncls + nmsg + nstk) > 0) { - /* Clear the default error stack. Note that - * the following H5I_clear_type calls do not - * force the clears and will not be able to - * clear any error message IDs that are still - * in use by the default error stack unless we - * clear that stack manually. - * - * Error message IDs will typically still be - * in use by the default error stack when the - * application does H5E_BEGIN/END_TRY cleanup - * at the very end. - */ - H5E_clear_stack(NULL); - - /* Clear any outstanding error stacks */ - if (nstk > 0) - (void)H5I_clear_type(H5I_ERROR_STACK, false, false); - - /* Clear all the error classes */ - if (ncls > 0) { - (void)H5I_clear_type(H5I_ERROR_CLASS, false, false); - - /* Reset the HDF5 error class, if its been closed */ - if (H5I_nmembers(H5I_ERROR_CLASS) == 0) - H5E_ERR_CLS_g = -1; - } /* end if */ - - /* Clear all the error messages */ - if (nmsg > 0) { - (void)H5I_clear_type(H5I_ERROR_MSG, false, false); - - /* Reset the HDF5 error messages, if they've been closed */ - if (H5I_nmembers(H5I_ERROR_MSG) == 0) { -/* Include the automatically generated error code termination */ -#include "H5Eterm.h" - } /* end if */ - } /* end if */ - - n++; /*H5I*/ - } /* end if */ - else { - /* Destroy the error class, message, and stack id groups */ - n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); - - } /* end else */ - - FUNC_LEAVE_NOAPI(n) -} /* end H5E_term_package() */ - -/*-------------------------------------------------------------------------- - * Function: H5E__set_default_auto - * - * Purpose: Initialize "automatic" error stack reporting info to library - * default - * - * Return: SUCCEED/FAIL - * - *-------------------------------------------------------------------------- - */ -static herr_t -H5E__set_default_auto(H5E_t *stk) -{ - FUNC_ENTER_PACKAGE_NOERR - -#ifndef H5_NO_DEPRECATED_SYMBOLS -#ifdef H5_USE_16_API_DEFAULT - stk->auto_op.vers = 1; -#else /* H5_USE_16_API */ - stk->auto_op.vers = 2; -#endif /* H5_USE_16_API_DEFAULT */ - - stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; - stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5E__print2; - stk->auto_op.is_default = true; -#else /* H5_NO_DEPRECATED_SYMBOLS */ - stk->auto_op.func2 = (H5E_auto2_t)H5E__print2; -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - stk->auto_data = NULL; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E__set_default_auto() */ - -#ifdef H5_HAVE_THREADSAFE -/*------------------------------------------------------------------------- - * Function: H5E__get_stack - * - * Purpose: Support function for H5E__get_my_stack() to initialize and - * acquire per-thread error stack. - * - * Return: Success: Pointer to an error stack struct (H5E_t *) - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -H5E_t * -H5E__get_stack(void) -{ - H5E_t *estack = NULL; - - FUNC_ENTER_PACKAGE_NOERR - - estack = (H5E_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); - - if (!estack) { - /* No associated value with current thread - create one */ -#ifdef H5_HAVE_WIN_THREADS - /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ - estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t)); -#else - /* Use malloc here since this has to match the free in the - * destructor and we want to avoid the codestack there. - */ - estack = (H5E_t *)malloc(sizeof(H5E_t)); -#endif /* H5_HAVE_WIN_THREADS */ - assert(estack); - - /* Set the thread-specific info */ - estack->nused = 0; - H5E__set_default_auto(estack); - - /* (It's not necessary to release this in this API, it is - * released by the "key destructor" set up in the H5TS - * routines. See calls to pthread_key_create() in H5TS.c -QAK) - */ - H5TS_set_thread_local_value(H5TS_errstk_key_g, (void *)estack); - } /* end if */ - - /* Set return value */ - FUNC_LEAVE_NOAPI(estack) -} /* end H5E__get_stack() */ -#endif /* H5_HAVE_THREADSAFE */ - -/*------------------------------------------------------------------------- - * Function: H5E__free_class - * - * Purpose: Private function to free an error class. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__free_class(H5E_cls_t *cls) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check arguments */ - assert(cls); - - /* Free error class structure */ - cls->cls_name = (char *)H5MM_xfree((void *)cls->cls_name); - cls->lib_name = (char *)H5MM_xfree((void *)cls->lib_name); - cls->lib_vers = (char *)H5MM_xfree((void *)cls->lib_vers); - cls = H5FL_FREE(H5E_cls_t, cls); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E__free_class() */ - /*------------------------------------------------------------------------- * Function: H5Eregister_class * @@ -413,52 +118,6 @@ H5Eregister_class(const char *cls_name, const char *lib_name, const char *versio FUNC_LEAVE_API(ret_value) } /* end H5Eregister_class() */ -/*------------------------------------------------------------------------- - * Function: H5E__register_class - * - * Purpose: Private function to register an error class. - * - * Return: Success: Pointer to an error class struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static H5E_cls_t * -H5E__register_class(const char *cls_name, const char *lib_name, const char *version) -{ - H5E_cls_t *cls = NULL; /* Pointer to error class */ - H5E_cls_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - assert(cls_name); - assert(lib_name); - assert(version); - - /* Allocate space for new error class */ - if (NULL == (cls = H5FL_CALLOC(H5E_cls_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Duplicate string information */ - if (NULL == (cls->cls_name = strdup(cls_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - if (NULL == (cls->lib_name = strdup(lib_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - if (NULL == (cls->lib_vers = strdup(version))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Set the return value */ - ret_value = cls; - -done: - if (!ret_value) - if (cls && H5E__free_class(cls) < 0) - HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class"); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__register_class() */ - /*------------------------------------------------------------------------- * Function: H5Eunregister_class * @@ -490,37 +149,6 @@ H5Eunregister_class(hid_t class_id) FUNC_LEAVE_API(ret_value) } /* end H5Eunregister_class() */ -/*------------------------------------------------------------------------- - * Function: H5E__unregister_class - * - * Purpose: Private function to close an error class. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__unregister_class(H5E_cls_t *cls, void H5_ATTR_UNUSED **request) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - assert(cls); - - /* Iterate over all the messages and delete those in this error class */ - if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, false) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_BADITER, FAIL, "unable to free all messages in this error class"); - - /* Free error class structure */ - if (H5E__free_class(cls) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "unable to free error class"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__unregister_class() */ - /*------------------------------------------------------------------------- * Function: H5Eget_class_name * @@ -551,75 +179,6 @@ H5Eget_class_name(hid_t class_id, char *name /*out*/, size_t size) FUNC_LEAVE_API(ret_value) } /* end H5Eget_class_name() */ -/*------------------------------------------------------------------------- - * Function: H5E__get_class_name - * - * Purpose: Private function to retrieve error class name. - * - * Return: Success: Name length (zero means no name) - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static ssize_t -H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) -{ - ssize_t len = -1; /* Length of error class's name */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Check arguments */ - assert(cls); - - /* Get the class's name */ - len = (ssize_t)strlen(cls->cls_name); - - /* Set the user's buffer, if provided */ - if (name) { - strncpy(name, cls->cls_name, size); - if ((size_t)len >= size) - name[size - 1] = '\0'; - } /* end if */ - - /* Return the full length */ - FUNC_LEAVE_NOAPI(len) -} /* end H5E__get_class_name() */ - -/*------------------------------------------------------------------------- - * Function: H5E__close_msg_cb - * - * Purpose: H5I_iterate callback function to close error messages in the - * error class. - * - * Return: Success: H5_ITER_CONT (0) - * Failure: H5_ITER_ERROR (-1) - * - *------------------------------------------------------------------------- - */ -static int -H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) -{ - H5E_msg_t *err_msg = (H5E_msg_t *)obj_ptr; - H5E_cls_t *cls = (H5E_cls_t *)udata; - int ret_value = H5_ITER_CONT; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - assert(err_msg); - - /* Close the message if it is in the class being closed */ - if (err_msg->cls == cls) { - if (H5E__close_msg(err_msg, NULL) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "unable to close error message"); - if (NULL == H5I_remove(obj_id)) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove error message"); - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__close_msg_cb() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_msg * @@ -648,31 +207,6 @@ H5Eclose_msg(hid_t err_id) FUNC_LEAVE_API(ret_value) } /* end H5Eclose_msg() */ -/*------------------------------------------------------------------------- - * Function: H5E__close_msg - * - * Purpose: Private function to close an error message. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__close_msg(H5E_msg_t *err, void H5_ATTR_UNUSED **request) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check arguments */ - assert(err); - - /* Release message */ - err->msg = (char *)H5MM_xfree((void *)err->msg); - /* Don't free err->cls here */ - err = H5FL_FREE(H5E_msg_t, err); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E__close_msg() */ - /*------------------------------------------------------------------------- * Function: H5Ecreate_msg * @@ -714,50 +248,6 @@ H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) FUNC_LEAVE_API(ret_value) } /* end H5Ecreate_msg() */ -/*------------------------------------------------------------------------- - * Function: H5E__create_msg - * - * Purpose: Private function to create a major or minor error. - * - * Return: Success: Pointer to a message struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static H5E_msg_t * -H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) -{ - H5E_msg_t *msg = NULL; /* Pointer to new error message */ - H5E_msg_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - assert(cls); - assert(msg_type == H5E_MAJOR || msg_type == H5E_MINOR); - assert(msg_str); - - /* Allocate new message object */ - if (NULL == (msg = H5FL_MALLOC(H5E_msg_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Fill new message object */ - msg->cls = cls; - msg->type = msg_type; - if (NULL == (msg->msg = strdup(msg_str))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Set return value */ - ret_value = msg; - -done: - if (!ret_value) - if (msg && H5E__close_msg(msg, NULL) < 0) - HDONE_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, NULL, "unable to close error message"); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__create_msg() */ - /*------------------------------------------------------------------------- * Function: H5Eget_msg * @@ -801,13 +291,13 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type /*out*/, char *msg_str /*out*/, size_t hid_t H5Ecreate_stack(void) { - H5E_t *stk; /* Error stack */ + H5E_stack_t *stk; /* Error stack */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) /* Allocate a new error stack */ - if (NULL == (stk = H5FL_CALLOC(H5E_t))) + if (NULL == (stk = H5FL_CALLOC(H5E_stack_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed"); /* Set the "automatic" error reporting info to the library default */ @@ -835,7 +325,7 @@ H5Ecreate_stack(void) hid_t H5Eget_current_stack(void) { - H5E_t *stk; /* Error stack */ + H5E_stack_t *stk; /* Error stack */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ /* Don't clear the error stack! :-) */ @@ -853,68 +343,6 @@ H5Eget_current_stack(void) FUNC_LEAVE_API(ret_value) } /* end H5Eget_current_stack() */ -/*------------------------------------------------------------------------- - * Function: H5E__get_current_stack - * - * Purpose: Private function to register an error stack. - * - * Return: Success: Pointer to an error class struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static H5E_t * -H5E__get_current_stack(void) -{ - H5E_t *current_stack; /* Pointer to the current error stack */ - H5E_t *estack_copy = NULL; /* Pointer to new error stack to return */ - unsigned u; /* Local index variable */ - H5E_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Get a pointer to the current error stack */ - if (NULL == (current_stack = H5E__get_my_stack())) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack"); - - /* Allocate a new error stack */ - if (NULL == (estack_copy = H5FL_CALLOC(H5E_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Make a copy of current error stack */ - estack_copy->nused = current_stack->nused; - for (u = 0; u < current_stack->nused; u++) { - H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ - - /* Get pointers into the current error stack location */ - current_error = &(current_stack->slot[u]); - new_error = &(estack_copy->slot[u]); - - /* Set error stack entry */ - if (H5E__set_stack_entry(new_error, current_error->file_name, current_error->func_name, - current_error->line, current_error->cls_id, current_error->maj_num, - current_error->min_num, current_error->desc) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, NULL, "can't set error entry"); - } /* end for */ - - /* Copy the "automatic" error reporting information */ - estack_copy->auto_op = current_stack->auto_op; - estack_copy->auto_data = current_stack->auto_data; - - /* Empty current error stack */ - H5E_clear_stack(current_stack); - - /* Set the return value */ - ret_value = estack_copy; - -done: - if (ret_value == NULL) - if (estack_copy) - estack_copy = H5FL_FREE(H5E_t, estack_copy); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__get_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eset_current_stack * @@ -928,13 +356,13 @@ H5E__get_current_stack(void) herr_t H5Eset_current_stack(hid_t err_stack) { - H5E_t *estack; + H5E_stack_t *estack; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) if (err_stack != H5E_DEFAULT) { - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); /* Set the current error stack */ @@ -953,54 +381,6 @@ H5Eset_current_stack(hid_t err_stack) FUNC_LEAVE_API(ret_value) } /* end H5Eset_current_stack() */ -/*------------------------------------------------------------------------- - * Function: H5E__set_current_stack - * - * Purpose: Private function to replace an error stack. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__set_current_stack(H5E_t *estack) -{ - H5E_t *current_stack; /* Default error stack */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - assert(estack); - - /* Get a pointer to the current error stack */ - if (NULL == (current_stack = H5E__get_my_stack())) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); - - /* Empty current error stack */ - H5E_clear_stack(current_stack); - - /* Copy new stack to current error stack */ - current_stack->nused = estack->nused; - for (u = 0; u < current_stack->nused; u++) { - H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ - - /* Get pointers into the current error stack location */ - current_error = &(current_stack->slot[u]); - new_error = &(estack->slot[u]); - - /* Set error stack entry */ - if (H5E__set_stack_entry(current_error, new_error->file_name, new_error->func_name, new_error->line, - new_error->cls_id, new_error->maj_num, new_error->min_num, - new_error->desc) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set error entry"); - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__set_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_stack * @@ -1034,32 +414,6 @@ H5Eclose_stack(hid_t stack_id) FUNC_LEAVE_API(ret_value) } /* end H5Eclose_stack() */ -/*------------------------------------------------------------------------- - * Function: H5E__close_stack - * - * Purpose: Private function to close an error stack. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__close_stack(H5E_t *estack, void H5_ATTR_UNUSED **request) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Sanity check */ - assert(estack); - - /* Release the stack's error information */ - H5E_clear_stack(estack); - - /* Free the stack structure */ - estack = H5FL_FREE(H5E_t, estack); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E__close_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eget_num * @@ -1073,7 +427,7 @@ H5E__close_stack(H5E_t *estack, void H5_ATTR_UNUSED **request) ssize_t H5Eget_num(hid_t error_stack_id) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1086,10 +440,10 @@ H5Eget_num(hid_t error_stack_id) } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Get the error stack to operate on */ - if (NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an error stack ID"); } /* end else */ @@ -1101,26 +455,6 @@ H5Eget_num(hid_t error_stack_id) FUNC_LEAVE_API(ret_value) } /* end H5Eget_num() */ -/*------------------------------------------------------------------------- - * Function: H5E__get_num - * - * Purpose: Private function to retrieve number of errors in error stack. - * - * Return: Success: The number of errors - * Failure: -1 (can't fail at this time) - * - *------------------------------------------------------------------------- - */ -static ssize_t -H5E__get_num(const H5E_t *estack) -{ - FUNC_ENTER_PACKAGE_NOERR - - assert(estack); - - FUNC_LEAVE_NOAPI((ssize_t)estack->nused) -} /* end H5E__get_num() */ - /*------------------------------------------------------------------------- * Function: H5Epop * @@ -1133,7 +467,7 @@ H5E__get_num(const H5E_t *estack) herr_t H5Epop(hid_t err_stack, size_t count) { - H5E_t *estack; + H5E_stack_t *estack; herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1146,10 +480,10 @@ H5Epop(hid_t err_stack, size_t count) } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Get the error stack to operate on */ - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1188,10 +522,11 @@ herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) { + H5E_stack_t *estack; /* Pointer to error stack to modify */ va_list ap; /* Varargs info */ - H5E_t *estack; /* Pointer to error stack to modify */ - char *tmp = NULL; /* Buffer to place formatted description in */ bool va_started = false; /* Whether the variable argument list is open */ + const char *tmp_file; /* Copy of the file name */ + const char *tmp_func; /* Copy of the function name */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1201,10 +536,10 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid estack = NULL; else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Get the error stack to operate on */ - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1217,22 +552,30 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid va_start(ap, fmt); va_started = true; - /* Use the vasprintf() routine, since it does what we're trying to do below */ - if (HDvasprintf(&tmp, fmt, ap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + /* Duplicate string information */ + if (NULL == (tmp_file = strdup(file))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string"); + if (NULL == (tmp_func = strdup(func))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string"); + + /* Increment refcount on non-library IDs */ + if (cls_id != H5E_ERR_CLS_g) + if (H5I_inc_ref(cls_id, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment class ID"); + if (maj_id < H5E_first_maj_id_g || maj_id > H5E_last_maj_id_g) + if (H5I_inc_ref(maj_id, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID"); + if (min_id < H5E_first_min_id_g || min_id > H5E_last_min_id_g) + if (H5I_inc_ref(min_id, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID"); /* Push the error on the stack */ - if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(estack, true, tmp_file, tmp_func, line, cls_id, maj_id, min_id, fmt, &ap) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack"); done: if (va_started) va_end(ap); - /* Memory was allocated with HDvasprintf so it needs to be freed - * with free - */ - if (tmp) - free(tmp); FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ @@ -1249,7 +592,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid herr_t H5Eclear2(hid_t err_stack) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1260,14 +603,14 @@ H5Eclear2(hid_t err_stack) estack = NULL; else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ /* Clear the error stack */ - if (H5E_clear_stack(estack) < 0) + if (H5E__clear_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack"); done: @@ -1302,44 +645,6 @@ H5Eprint2(hid_t err_stack, FILE *stream) FUNC_LEAVE_API(ret_value) } /* end H5Eprint2() */ -/*------------------------------------------------------------------------- - * Function: H5E__print2 - * - * Purpose: Internal helper routine for H5Eprint2. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__print2(hid_t err_stack, FILE *stream) -{ - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Need to check for errors */ - if (err_stack == H5E_DEFAULT) { - if (NULL == (estack = H5E__get_my_stack())) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); - } /* end if */ - else { - /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); - - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); - } /* end else */ - - /* Print error stack */ - if (H5E__print(estack, stream, false) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__print2() */ - /*------------------------------------------------------------------------- * Function: H5Ewalk2 * @@ -1353,7 +658,7 @@ H5E__print2(hid_t err_stack, FILE *stream) herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_walk_op_t op; /* Operator for walking error stack */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1367,9 +672,9 @@ H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, voi } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); - if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1398,7 +703,7 @@ H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, voi herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*out*/) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_auto_op_t op; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1411,9 +716,9 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1456,7 +761,7 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_auto_op_t op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1469,9 +774,9 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1514,7 +819,7 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) herr_t H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1526,9 +831,9 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) } /* end if */ else { /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); } /* end else */ @@ -1557,16 +862,16 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) herr_t H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_stack) { - H5E_t *dst_stack, *src_stack; /* Error stacks */ + H5E_stack_t *dst_stack, *src_stack; /* Error stacks */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API(FAIL) /* Check args */ - if (NULL == (dst_stack = (H5E_t *)H5I_object_verify(dst_stack_id, H5I_ERROR_STACK))) + if (NULL == (dst_stack = (H5E_stack_t *)H5I_object_verify(dst_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst_stack_id not a error stack ID"); - if (NULL == (src_stack = (H5E_t *)H5I_object_verify(src_stack_id, H5I_ERROR_STACK))) + if (NULL == (src_stack = (H5E_stack_t *)H5I_object_verify(src_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src_stack_id not a error stack ID"); /* Append the source stack to the destination stack */ @@ -1584,51 +889,3 @@ H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_sta done: FUNC_LEAVE_API(ret_value) } /* end H5Eappend_stack() */ - -/*------------------------------------------------------------------------- - * Function: H5E__append_stack - * - * Purpose: Private function to append error stacks. - * - * Return: Non-negative value on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E__append_stack(H5E_t *dst_stack, const H5E_t *src_stack) -{ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(dst_stack); - assert(src_stack); - - /* Copy the errors from the source stack to the destination stack */ - for (u = 0; u < src_stack->nused; u++) { - const H5E_error2_t *src_error; /* Pointers to source error on stack */ - H5E_error2_t *dst_error; /* Pointers to destination error on stack */ - - /* Get pointers into the current error stack location */ - src_error = &(src_stack->slot[u]); - dst_error = &(dst_stack->slot[dst_stack->nused]); - - /* Set error stack entry */ - if (H5E__set_stack_entry(dst_error, src_error->file_name, src_error->func_name, src_error->line, - src_error->cls_id, src_error->maj_num, src_error->min_num, - src_error->desc) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set error entry"); - - /* Increment # of errors in destination stack */ - dst_stack->nused++; - - /* Check for destination stack full */ - if (dst_stack->nused >= H5E_NSLOTS) - break; - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__append_stack() */ diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 1f85b00c8f2..ed7b92828d7 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -182,13 +182,29 @@ H5Eget_minor(H5E_minor_t min) herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str) { + const char *tmp_file; /* Copy of the file name */ + const char *tmp_func; /* Copy of the function name */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) + /* Duplicate string information */ + if (NULL == (tmp_file = strdup(file))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string"); + if (NULL == (tmp_func = strdup(func))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string"); + + /* Increment refcount on non-library IDs */ + if (maj < H5E_first_maj_id_g || maj > H5E_last_maj_id_g) + if (H5I_inc_ref(maj, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID"); + if (min < H5E_first_min_id_g || min > H5E_last_min_id_g) + if (H5I_inc_ref(min, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID"); + /* Push the error on the default error stack */ - if (H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) + if (H5E__push_stack(NULL, true, tmp_file, tmp_func, line, H5E_ERR_CLS_g, maj, min, str, NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack"); done: @@ -214,7 +230,7 @@ H5Eclear1(void) FUNC_ENTER_API_NOCLEAR(FAIL) /* Clear the default error stack */ - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack"); done: @@ -237,7 +253,7 @@ H5Eclear1(void) herr_t H5Eprint1(FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -268,7 +284,7 @@ H5Eprint1(FILE *stream) herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_walk_op_t walk_op; /* Error stack walking callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -304,7 +320,7 @@ H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data) herr_t H5Eget_auto1(H5E_auto1_t *func /*out*/, void **client_data /*out*/) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_auto_op_t auto_op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ @@ -352,7 +368,7 @@ H5Eget_auto1(H5E_auto1_t *func /*out*/, void **client_data /*out*/) herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ + H5E_stack_t *estack; /* Error stack to operate on */ H5E_auto_op_t auto_op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Eint.c b/src/H5Eint.c index e59988d0264..75a5a2f0bd8 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -30,6 +30,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Epkg.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5TSprivate.h" /* Thread stuff */ @@ -38,6 +39,10 @@ /* Local Macros */ /****************/ +/* HDF5 error class */ +#define H5E_CLS_NAME "HDF5" +#define H5E_CLS_LIB_NAME "HDF5" + /******************/ /* Local Typedefs */ /******************/ @@ -59,7 +64,15 @@ typedef struct H5E_print_t { static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); -static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); +static herr_t H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *src_entry); +static herr_t H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc, va_list *ap); +static herr_t H5E__clear_entries(H5E_stack_t *estack, size_t nentries); +static herr_t H5E__unregister_class(H5E_cls_t *cls, void **request); +static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata); +static void H5E__free_msg(H5E_msg_t *msg); +static herr_t H5E__close_msg(H5E_msg_t *err, void **request); +static herr_t H5E__close_stack(H5E_stack_t *err_stack, void **request); /*********************/ /* Package Variables */ @@ -69,9 +82,18 @@ static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); /* * The current error stack. */ -H5E_t H5E_stack_g[1]; +H5E_stack_t H5E_stack_g[1]; #endif /* H5_HAVE_THREADSAFE */ +/* Declare a free list to manage the H5E_stack_t struct */ +H5FL_DEFINE(H5E_stack_t); + +/* Declare a free list to manage the H5E_cls_t struct */ +H5FL_DEFINE_STATIC(H5E_cls_t); + +/* Declare a free list to manage the H5E_msg_t struct */ +H5FL_DEFINE_STATIC(H5E_msg_t); + /*****************************/ /* Library Private Variables */ /*****************************/ @@ -98,6 +120,739 @@ char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; int H5E_mpi_error_str_len; #endif /* H5_HAVE_PARALLEL */ +/* First & last major and minor error codes registered by the library */ +hid_t H5E_first_maj_id_g = H5I_INVALID_HID; +hid_t H5E_last_maj_id_g = H5I_INVALID_HID; +hid_t H5E_first_min_id_g = H5I_INVALID_HID; +hid_t H5E_last_min_id_g = H5I_INVALID_HID; + +/* Error class ID class */ +static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ + H5I_ERROR_CLASS, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5E__unregister_class /* Callback routine for closing objects of this class */ +}}; + +/* Error message ID class */ +static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ + H5I_ERROR_MSG, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ +}}; + +/* Error stack ID class */ +static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ + H5I_ERROR_STACK, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5E__close_stack /* Callback routine for closing objects of this class */ +}}; + +/* Library's error class */ +static const H5E_cls_t H5E_err_cls_s = {false, H5E_CLS_NAME, H5E_CLS_LIB_NAME, H5_VERS_STR}; + +/* Include the automatically generated major error message definitions */ +#include "H5Emajdef.h" + +/* Include the automatically generated minor error message definitions */ +#include "H5Emindef.h" + +/*------------------------------------------------------------------------- + * Function: H5E_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5E_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Initialize the ID group for the error class IDs */ + if (H5I_register_type(H5I_ERRCLS_CLS) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); + + /* Initialize the ID group for the major error IDs */ + if (H5I_register_type(H5I_ERRMSG_CLS) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); + + /* Initialize the ID group for the error stacks */ + if (H5I_register_type(H5I_ERRSTK_CLS) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTINIT, FAIL, "unable to initialize ID group"); + +#ifndef H5_HAVE_THREADSAFE + H5E_stack_g[0].nused = 0; + H5E__set_default_auto(H5E_stack_g); +#endif /* H5_HAVE_THREADSAFE */ + + /* Register the HDF5 error class */ + if ((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, &H5E_err_cls_s, false)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class"); + +/* Include the automatically generated error code initialization */ +#include "H5Einit.h" + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + +/*------------------------------------------------------------------------- + * Function: H5E_term_package + * + * Purpose: Terminates the H5E interface + * + * Return: Success: Positive if anything is done that might + * affect other interfaces; zero otherwise. + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +int +H5E_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + int64_t ncls, nmsg, nstk; + + /* Check if there are any open error stacks, classes or messages */ + ncls = H5I_nmembers(H5I_ERROR_CLASS); + nmsg = H5I_nmembers(H5I_ERROR_MSG); + nstk = H5I_nmembers(H5I_ERROR_STACK); + + if ((ncls + nmsg + nstk) > 0) { + /* Clear the default error stack. Note that + * the following H5I_clear_type calls do not + * force the clears and will not be able to + * clear any error message IDs that are still + * in use by the default error stack unless we + * clear that stack manually. + * + * Error message IDs will typically still be + * in use by the default error stack when the + * application does H5E_BEGIN/END_TRY cleanup + * at the very end. + */ + H5E_clear_stack(); + + /* Clear any outstanding error stacks */ + if (nstk > 0) + (void)H5I_clear_type(H5I_ERROR_STACK, false, false); + + /* Clear all the error classes */ + if (ncls > 0) { + (void)H5I_clear_type(H5I_ERROR_CLASS, false, false); + + /* Reset the HDF5 error class, if its been closed */ + if (H5I_nmembers(H5I_ERROR_CLASS) == 0) + H5E_ERR_CLS_g = H5I_INVALID_HID; + } /* end if */ + + /* Clear all the error messages */ + if (nmsg > 0) { + (void)H5I_clear_type(H5I_ERROR_MSG, false, false); + + /* Reset the HDF5 error messages, if they've been closed */ + if (H5I_nmembers(H5I_ERROR_MSG) == 0) { +/* Include the automatically generated error code termination */ +#include "H5Eterm.h" + } /* end if */ + } /* end if */ + + n++; /*H5I*/ + } /* end if */ + else { + /* Destroy the error class, message, and stack id groups */ + n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); + + } /* end else */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5E_term_package() */ + +#ifdef H5_HAVE_THREADSAFE +/*------------------------------------------------------------------------- + * Function: H5E__get_stack + * + * Purpose: Support function for H5E__get_my_stack() to initialize and + * acquire per-thread error stack. + * + * Return: Success: Pointer to an error stack struct (H5E_t *) + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5E_stack_t * +H5E__get_stack(void) +{ + H5E_stack_t *estack = NULL; + + FUNC_ENTER_PACKAGE_NOERR + + estack = (H5E_stack_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); + + if (!estack) { + /* No associated value with current thread - create one */ +#ifdef H5_HAVE_WIN_THREADS + /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ + estack = (H5E_stack_t *)LocalAlloc(LPTR, sizeof(H5E_stack_t)); +#else + /* Use malloc here since this has to match the free in the + * destructor and we want to avoid the codestack there. + */ + estack = (H5E_stack_t *)malloc(sizeof(H5E_stack_t)); +#endif /* H5_HAVE_WIN_THREADS */ + assert(estack); + + /* Set the thread-specific info */ + estack->nused = 0; + H5E__set_default_auto(estack); + + /* (It's not necessary to release this in this API, it is + * released by the "key destructor" set up in the H5TS + * routines. See calls to pthread_key_create() in H5TS.c -QAK) + */ + H5TS_set_thread_local_value(H5TS_errstk_key_g, (void *)estack); + } /* end if */ + + /* Set return value */ + FUNC_LEAVE_NOAPI(estack) +} /* end H5E__get_stack() */ +#endif /* H5_HAVE_THREADSAFE */ + +/*------------------------------------------------------------------------- + * Function: H5E__free_class + * + * Purpose: Private function to free an error class. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__free_class(H5E_cls_t *cls) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + assert(cls); + + /* Free resources, if application registered this class */ + if (cls->app_cls) { + /* Free error class structure */ + cls->cls_name = H5MM_xfree_const(cls->cls_name); + cls->lib_name = H5MM_xfree_const(cls->lib_name); + cls->lib_vers = H5MM_xfree_const(cls->lib_vers); + cls = H5FL_FREE(H5E_cls_t, cls); + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E__free_class() */ + +/*------------------------------------------------------------------------- + * Function: H5E__register_class + * + * Purpose: Private function to register an error class. + * + * Return: Success: Pointer to an error class struct + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5E_cls_t * +H5E__register_class(const char *cls_name, const char *lib_name, const char *version) +{ + H5E_cls_t *cls = NULL; /* Pointer to error class */ + H5E_cls_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(cls_name); + assert(lib_name); + assert(version); + + /* Allocate space for new error class */ + if (NULL == (cls = H5FL_CALLOC(H5E_cls_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + + /* Application registered class */ + cls->app_cls = true; + + /* Duplicate string information */ + if (NULL == (cls->cls_name = strdup(cls_name))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL == (cls->lib_name = strdup(lib_name))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL == (cls->lib_vers = strdup(version))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + + /* Set the return value */ + ret_value = cls; + +done: + if (!ret_value) + if (cls && H5E__free_class(cls) < 0) + HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__register_class() */ + +/*------------------------------------------------------------------------- + * Function: H5E__unregister_class + * + * Purpose: Private function to close an error class. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__unregister_class(H5E_cls_t *cls, void H5_ATTR_UNUSED **request) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(cls); + + /* Iterate over all the messages and delete those in this error class */ + if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_BADITER, FAIL, "unable to free all messages in this error class"); + + /* Free error class structure */ + if (H5E__free_class(cls) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "unable to free error class"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__unregister_class() */ + +/*------------------------------------------------------------------------- + * Function: H5E__get_class_name + * + * Purpose: Private function to retrieve error class name. + * + * Return: Success: Name length (zero means no name) + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) +{ + ssize_t len = -1; /* Length of error class's name */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + assert(cls); + + /* Get the class's name */ + len = (ssize_t)strlen(cls->cls_name); + + /* Set the user's buffer, if provided */ + if (name) { + strncpy(name, cls->cls_name, size); + if ((size_t)len >= size) + name[size - 1] = '\0'; + } /* end if */ + + /* Return the full length */ + FUNC_LEAVE_NOAPI(len) +} /* end H5E__get_class_name() */ + +/*------------------------------------------------------------------------- + * Function: H5E__close_msg_cb + * + * Purpose: H5I_iterate callback function to close error messages in the + * error class. + * + * Return: Success: H5_ITER_CONT (0) + * Failure: H5_ITER_ERROR (-1) + * + *------------------------------------------------------------------------- + */ +static int +H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) +{ + H5E_msg_t *err_msg = (H5E_msg_t *)obj_ptr; + H5E_cls_t *cls = (H5E_cls_t *)udata; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(err_msg); + + /* Close the message if it is in the class being closed */ + if (err_msg->cls == cls) { + if (H5E__close_msg(err_msg, NULL) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "unable to close error message"); + if (NULL == H5I_remove(obj_id)) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove error message"); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__close_msg_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5E__free_msg + * + * Purpose: Private function to free an application error message. + * + * Return: none + * + *------------------------------------------------------------------------- + */ +static void +H5E__free_msg(H5E_msg_t *msg) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + assert(msg); + assert(msg->app_msg); + + /* Free resources */ + msg->msg = H5MM_xfree_const(msg->msg); + msg = H5FL_FREE(H5E_msg_t, msg); + + FUNC_LEAVE_NOAPI_VOID +} /* end H5E__free_msg() */ + +/*------------------------------------------------------------------------- + * Function: H5E__close_msg + * + * Purpose: Private function to close an error message. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__close_msg(H5E_msg_t *err, void H5_ATTR_UNUSED **request) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + assert(err); + + /* Free resources, if application registered this message */ + if (err->app_msg) + /* Free message */ + H5E__free_msg(err); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E__close_msg() */ + +/*------------------------------------------------------------------------- + * Function: H5E__create_msg + * + * Purpose: Private function to create a major or minor error. + * + * Return: Success: Pointer to a message struct + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5E_msg_t * +H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) +{ + H5E_msg_t *msg = NULL; /* Pointer to new error message */ + H5E_msg_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(cls); + assert(msg_type == H5E_MAJOR || msg_type == H5E_MINOR); + assert(msg_str); + + /* Allocate new message object */ + if (NULL == (msg = H5FL_CALLOC(H5E_msg_t))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, NULL, "memory allocation failed"); + + /* Fill new message object */ + msg->app_msg = true; + msg->cls = cls; + msg->type = msg_type; + if (NULL == (msg->msg = strdup(msg_str))) + HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, NULL, "memory allocation failed"); + + /* Set return value */ + ret_value = msg; + +done: + if (!ret_value) + if (msg) + H5E__free_msg(msg); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__create_msg() */ + +/*------------------------------------------------------------------------- + * Function: H5E__get_current_stack + * + * Purpose: Private function to register an error stack. + * + * Return: Success: Pointer to an error class struct + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5E_stack_t * +H5E__get_current_stack(void) +{ + H5E_stack_t *current_stack; /* Pointer to the current error stack */ + H5E_stack_t *estack_copy = NULL; /* Pointer to new error stack to return */ + unsigned u; /* Local index variable */ + H5E_stack_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get a pointer to the current error stack */ + if (NULL == (current_stack = H5E__get_my_stack())) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack"); + + /* Allocate a new error stack */ + if (NULL == (estack_copy = H5FL_CALLOC(H5E_stack_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + + /* Make a copy of current error stack */ + estack_copy->nused = current_stack->nused; + for (u = 0; u < current_stack->nused; u++) + if (H5E__copy_stack_entry(&estack_copy->entries[u], ¤t_stack->entries[u]) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, NULL, "can't set error entry"); + + /* Copy the "automatic" error reporting information */ + estack_copy->auto_op = current_stack->auto_op; + estack_copy->auto_data = current_stack->auto_data; + + /* Empty current error stack */ + H5E__clear_stack(current_stack); + + /* Set the return value */ + ret_value = estack_copy; + +done: + if (ret_value == NULL) + if (estack_copy) + estack_copy = H5FL_FREE(H5E_stack_t, estack_copy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__get_current_stack() */ + +/*------------------------------------------------------------------------- + * Function: H5E__set_current_stack + * + * Purpose: Private function to replace an error stack. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5E__set_current_stack(H5E_stack_t *estack) +{ + H5E_stack_t *current_stack; /* Default error stack */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + assert(estack); + + /* Get a pointer to the current error stack */ + if (NULL == (current_stack = H5E__get_my_stack())) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); + + /* Empty current error stack */ + H5E__clear_stack(current_stack); + + /* Copy new stack to current error stack */ + current_stack->nused = estack->nused; + for (u = 0; u < current_stack->nused; u++) + if (H5E__copy_stack_entry(¤t_stack->entries[u], &estack->entries[u]) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set error entry"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__set_current_stack() */ + +/*------------------------------------------------------------------------- + * Function: H5E__close_stack + * + * Purpose: Private function to close an error stack. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__close_stack(H5E_stack_t *estack, void H5_ATTR_UNUSED **request) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + assert(estack); + + /* Release the stack's error information */ + H5E__clear_stack(estack); + + /* Free the stack structure */ + estack = H5FL_FREE(H5E_stack_t, estack); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E__close_stack() */ + +/*------------------------------------------------------------------------- + * Function: H5E__get_num + * + * Purpose: Private function to retrieve number of errors in error stack. + * + * Return: Success: The number of errors + * Failure: -1 (can't fail at this time) + * + *------------------------------------------------------------------------- + */ +ssize_t +H5E__get_num(const H5E_stack_t *estack) +{ + FUNC_ENTER_PACKAGE_NOERR + + assert(estack); + + FUNC_LEAVE_NOAPI((ssize_t)estack->nused) +} /* end H5E__get_num() */ + +/*------------------------------------------------------------------------- + * Function: H5E__print2 + * + * Purpose: Internal helper routine for H5Eprint2. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5E__print2(hid_t err_stack, FILE *stream) +{ + H5E_stack_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Need to check for errors */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); + } /* end if */ + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(); + + if (NULL == (estack = (H5E_stack_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID"); + } /* end else */ + + /* Print error stack */ + if (H5E__print(estack, stream, false) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__print2() */ + +/*------------------------------------------------------------------------- + * Function: H5E__append_stack + * + * Purpose: Private function to append error stacks. + * + * Return: Non-negative value on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5E__append_stack(H5E_stack_t *dst_stack, const H5E_stack_t *src_stack) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(dst_stack); + assert(src_stack); + + /* Copy the errors from the source stack to the destination stack */ + for (u = 0; u < src_stack->nused; u++) { + /* Copy error stack entry */ + if (H5E__copy_stack_entry(&dst_stack->entries[dst_stack->nused], &src_stack->entries[u]) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set error entry"); + + /* Increment # of errors in destination stack */ + dst_stack->nused++; + + /* Check for destination stack full */ + if (dst_stack->nused >= H5E_MAX_ENTRIES) + break; + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__append_stack() */ + +/*-------------------------------------------------------------------------- + * Function: H5E__set_default_auto + * + * Purpose: Initialize "automatic" error stack reporting info to library + * default + * + * Return: SUCCEED/FAIL + * + *-------------------------------------------------------------------------- + */ +void +H5E__set_default_auto(H5E_stack_t *stk) +{ + FUNC_ENTER_PACKAGE_NOERR + +#ifndef H5_NO_DEPRECATED_SYMBOLS +#ifdef H5_USE_16_API_DEFAULT + stk->auto_op.vers = 1; +#else /* H5_USE_16_API */ + stk->auto_op.vers = 2; +#endif /* H5_USE_16_API_DEFAULT */ + + stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; + stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5E__print2; + stk->auto_op.is_default = true; +#else /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_op.func2 = (H5E_auto2_t)H5E__print2; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + stk->auto_data = NULL; + + + FUNC_LEAVE_NOAPI_VOID +} /* end H5E__set_default_auto() */ + /*------------------------------------------------------------------------- * Function: H5E__get_msg * @@ -173,12 +928,12 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) { H5E_print_t *eprint = (H5E_print_t *)client_data; FILE *stream; /* I/O stream to print output to */ - H5E_cls_t *cls_ptr; /* Pointer to error class */ + const H5E_cls_t *cls_ptr; /* Pointer to error class */ H5E_msg_t *maj_ptr; /* Pointer to major error info */ H5E_msg_t *min_ptr; /* Pointer to minor error info */ const char *maj_str = "No major description"; /* Major error description */ const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + bool have_desc = true; /* Flag to indicate whether the error has a "real" description */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -250,7 +1005,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) /* Check for "real" error description - used to format output more nicely */ if (err_desc->desc == NULL || strlen(err_desc->desc) == 0) - have_desc = 0; + have_desc = false; /* Print error message */ fprintf(stream, "%*s#%03d: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, @@ -301,7 +1056,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) H5E_msg_t *min_ptr; /* Pointer to minor error info */ const char *maj_str = "No major description"; /* Major error description */ const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + bool have_desc = true; /* Flag to indicate whether the error has a "real" description */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -378,7 +1133,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) /* Check for "real" error description - used to format output more nicely */ if (err_desc->desc == NULL || strlen(err_desc->desc) == 0) - have_desc = 0; + have_desc = false; /* Print error message */ fprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, @@ -404,7 +1159,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5E__print(const H5E_t *estack, FILE *stream, bool bk_compatible) +H5E__print(const H5E_stack_t *estack, FILE *stream, bool bk_compatible) { H5E_print_t eprint; /* Callback information to pass to H5E_walk() */ H5E_walk_op_t walk_op; /* Error stack walking callback */ @@ -474,7 +1229,7 @@ H5E__print(const H5E_t *estack, FILE *stream, bool bk_compatible) *------------------------------------------------------------------------- */ herr_t -H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, void *client_data) +H5E__walk(const H5E_stack_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, void *client_data) { int i; /* Local index variable */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -499,12 +1254,12 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o if (H5E_WALK_UPWARD == direction) { for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; - old_err.func_name = estack->slot[i].func_name; - old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.maj_num = estack->entries[i].err.maj_num; + old_err.min_num = estack->entries[i].err.min_num; + old_err.file_name = estack->entries[i].err.file_name; + old_err.func_name = estack->entries[i].err.func_name; + old_err.line = estack->entries[i].err.line; + old_err.desc = estack->entries[i].err.desc; ret_value = (op->u.func1)(i, &old_err, client_data); } /* end for */ @@ -513,12 +1268,12 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; - old_err.func_name = estack->slot[i].func_name; - old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.maj_num = estack->entries[i].err.maj_num; + old_err.min_num = estack->entries[i].err.min_num; + old_err.file_name = estack->entries[i].err.file_name; + old_err.func_name = estack->entries[i].err.func_name; + old_err.line = estack->entries[i].err.line; + old_err.desc = estack->entries[i].err.desc; ret_value = (op->u.func1)((int)(estack->nused - (size_t)(i + 1)), &old_err, client_data); } /* end for */ @@ -537,13 +1292,13 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o ret_value = SUCCEED; if (H5E_WALK_UPWARD == direction) { for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) - ret_value = (op->u.func2)((unsigned)i, estack->slot + i, client_data); + ret_value = (op->u.func2)((unsigned)i, &estack->entries[i].err, client_data); } /* end if */ else { H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) - ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, - client_data); + ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), + &estack->entries[i].err, client_data); } /* end else */ if (ret_value < 0) @@ -567,7 +1322,7 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o *------------------------------------------------------------------------- */ herr_t -H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data) +H5E__get_auto(const H5E_stack_t *estack, H5E_auto_op_t *op, void **client_data) { FUNC_ENTER_PACKAGE_NOERR @@ -603,7 +1358,7 @@ H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data) *------------------------------------------------------------------------- */ herr_t -H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) +H5E__set_auto(H5E_stack_t *estack, const H5E_auto_op_t *op, void *client_data) { FUNC_ENTER_PACKAGE_NOERR @@ -626,11 +1381,10 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, - hid_t min_id, const char *fmt, ...) +H5E_printf_stack(const char *file, const char *func, unsigned line, hid_t maj_id, hid_t min_id, + const char *fmt, ...) { va_list ap; /* Varargs info */ - char *tmp = NULL; /* Buffer to place formatted description in */ bool va_started = false; /* Whether the variable argument list is open */ herr_t ret_value = SUCCEED; /* Return value */ @@ -644,9 +1398,8 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ - assert(cls_id > 0); - assert(maj_id > 0); - assert(min_id > 0); + assert(maj_id >= H5E_first_maj_id_g && maj_id <= H5E_last_maj_id_g); + assert(min_id >= H5E_first_min_id_g && min_id <= H5E_last_min_id_g); assert(fmt); /* Note that the variable-argument parsing for the format is identical in @@ -658,22 +1411,13 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin va_start(ap, fmt); va_started = true; - /* Use the vasprintf() routine, since it does what we're trying to do below */ - if (HDvasprintf(&tmp, fmt, ap) < 0) - HGOTO_DONE(FAIL); - /* Push the error on the stack */ - if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(NULL, false, file, func, line, H5E_ERR_CLS_g, maj_id, min_id, fmt, &ap) < 0) HGOTO_DONE(FAIL); done: if (va_started) va_end(ap); - /* Memory was allocated with HDvasprintf so it needs to be freed - * with free - */ - if (tmp) - free(tmp); FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ @@ -696,8 +1440,8 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin *------------------------------------------------------------------------- */ herr_t -H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, - hid_t min_id, const char *desc) +H5E__push_stack(H5E_stack_t *estack, bool app_entry, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, va_list *ap) { herr_t ret_value = SUCCEED; /* Return value */ @@ -723,9 +1467,10 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line /* * Push the error if there's room. Otherwise just forget it. */ - if (estack->nused < H5E_NSLOTS) { - if (H5E__set_stack_entry(&estack->slot[estack->nused], file, func, line, cls_id, maj_id, min_id, - desc) < 0) + if (estack->nused < H5E_MAX_ENTRIES) { + estack->entries[estack->nused].app_entry = app_entry; + if (H5E__set_stack_entry(&estack->entries[estack->nused].err, file, func, line, cls_id, maj_id, + min_id, fmt, ap) < 0) HGOTO_DONE(FAIL); estack->nused++; } /* end if */ @@ -734,6 +1479,63 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__push_stack() */ +/*------------------------------------------------------------------------- + * Function: H5E__copy_stack_entry + * + * Purpose: Copy a stack entry + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *src_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* + * WARNING: We cannot call HERROR() from within this function or else we + * could enter infinite recursion. Furthermore, we also cannot + * call any other HDF5 macro or function which might call + * HERROR(). HERROR() is called by HRETURN_ERROR() which could + * be called by FUNC_ENTER(). + */ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + assert(dst_entry); + assert(src_entry); + + /* Shallow copy all fields */ + *dst_entry = *src_entry; + + /* Deep copy application entries */ + if (dst_entry->app_entry) { + /* Note: don't waste time incrementing library internal error IDs */ + if (dst_entry->err.cls_id != H5E_ERR_CLS_g) + if (H5I_inc_ref(dst_entry->err.cls_id, false) < 0) + HGOTO_DONE(FAIL); + if (dst_entry->err.maj_num < H5E_first_maj_id_g || dst_entry->err.maj_num > H5E_last_maj_id_g) + if (H5I_inc_ref(dst_entry->err.maj_num, false) < 0) + HGOTO_DONE(FAIL); + if (dst_entry->err.min_num < H5E_first_min_id_g || dst_entry->err.min_num > H5E_last_min_id_g) + if (H5I_inc_ref(dst_entry->err.min_num, false) < 0) + HGOTO_DONE(FAIL); + /* The library's 'func' & 'file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + if (NULL == (dst_entry->err.file_name = strdup(src_entry->err.file_name))) + HGOTO_DONE(FAIL); + if (NULL == (dst_entry->err.func_name = strdup(src_entry->err.func_name))) + HGOTO_DONE(FAIL); + } + if (NULL == (dst_entry->err.desc = strdup(src_entry->err.desc))) + HGOTO_DONE(FAIL); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__copy_stack_entry() */ + /*------------------------------------------------------------------------- * Function: H5E__set_stack_entry * @@ -743,9 +1545,9 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func, unsigned line, hid_t cls_id, - hid_t maj_id, hid_t min_id, const char *desc) + hid_t maj_id, hid_t min_id, const char *fmt, va_list *ap) { herr_t ret_value = SUCCEED; /* Return value */ @@ -772,31 +1574,40 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func func = "Unknown_Function"; if (!file) file = "Unknown_File"; - if (!desc) - desc = "No description given"; + if (!fmt) + fmt = "No description given"; - /* Increment the IDs to indicate that they are used in this stack */ - /* Note: don't waste time incrementing library internal error IDs */ - if (cls_id != H5E_ERR_CLS_g) - if (H5I_inc_ref_noherr(cls_id, false) < 0) - HGOTO_DONE(FAIL); + /* Set the entry fields */ + /* NOTE: non-library IDs have already been incremented */ err_entry->cls_id = cls_id; - if (maj_id < H5E_first_maj_id_g || maj_id > H5E_last_maj_id_g) - if (H5I_inc_ref_noherr(maj_id, false) < 0) - HGOTO_DONE(FAIL); err_entry->maj_num = maj_id; - if (min_id < H5E_first_min_id_g || min_id > H5E_last_min_id_g) - if (H5I_inc_ref_noherr(min_id, false) < 0) - HGOTO_DONE(FAIL); err_entry->min_num = min_id; - /* The 'func' & 'file' strings are statically allocated (by the compiler) - * there's no need to duplicate them. + /* The 'func' & 'file' strings are either statically allocated (by the + * compiler), for internal error messages, or have already been duplicated, + * for application errors, so there's no need to duplicate them here. */ err_entry->func_name = func; err_entry->file_name = file; err_entry->line = line; - if (NULL == (err_entry->desc = strdup(desc))) + if (ap) { + char *desc = NULL; + + /* GCC complains about the 'fmt' parameter, but it's either from static + * strings in the library, which we know are OK, or from application + * error push calls, and the application should be sanity checking their + * strings. + */ + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + if (HDvasprintf(&desc, fmt, *ap) < 0) HGOTO_DONE(FAIL); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + + err_entry->desc = desc; + } + else { + if (NULL == (err_entry->desc = strdup(fmt))) + HGOTO_DONE(FAIL); + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -813,9 +1624,8 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func *------------------------------------------------------------------------- */ static herr_t -H5E__clear_entries(H5E_t *estack, size_t nentries) +H5E__clear_entries(H5E_stack_t *estack, size_t nentries) { - H5E_error2_t *error; /* Pointer to error stack entry to clear */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -827,29 +1637,34 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) /* Empty the error stack from the top down */ for (u = 0; nentries > 0; nentries--, u++) { - error = &(estack->slot[estack->nused - (u + 1)]); + H5E_entry_t *error; /* Pointer to error stack entry to clear */ + + error = &(estack->entries[estack->nused - (u + 1)]); /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ /* Note: don't decrement library internal error IDs, since they weren't incremented */ - if (error->min_num < H5E_first_min_id_g || error->min_num > H5E_last_min_id_g) - if (H5I_dec_ref(error->min_num) < 0) + if (error->err.min_num < H5E_first_min_id_g || error->err.min_num > H5E_last_min_id_g) + if (H5I_dec_ref(error->err.min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message"); - if (error->maj_num < H5E_first_maj_id_g || error->maj_num > H5E_last_maj_id_g) - if (H5I_dec_ref(error->maj_num) < 0) + if (error->err.maj_num < H5E_first_maj_id_g || error->err.maj_num > H5E_last_maj_id_g) + if (H5I_dec_ref(error->err.maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message"); - if (error->cls_id != H5E_ERR_CLS_g) - if (H5I_dec_ref(error->cls_id) < 0) + if (error->err.cls_id != H5E_ERR_CLS_g) + if (H5I_dec_ref(error->err.cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class"); /* Release strings */ - /* The 'func' & 'file' strings are statically allocated (by the compiler) - * and are not allocated, so there's no need to free them. + /* The library's 'func' & 'file' strings are statically allocated (by the + * compiler) and are not allocated, so there's no need to free them. */ - error->func_name = NULL; - error->file_name = NULL; - if (error->desc) - error->desc = (const char *)H5MM_xfree_const(error->desc); + if (error->app_entry) { + H5MM_xfree_const(error->err.file_name); + H5MM_xfree_const(error->err.func_name); + } + error->err.file_name = NULL; + error->err.func_name = NULL; + error->err.desc = (const char *)H5MM_xfree_const(error->err.desc); } /* Decrement number of errors on stack */ @@ -862,34 +1677,61 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) /*------------------------------------------------------------------------- * Function: H5E_clear_stack * - * Purpose: Private function to clear the error stack for the - * specified error stack. + * Purpose: Clear the default error stack * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5E_clear_stack(H5E_t *estack) +H5E_clear_stack(void) { + H5E_stack_t *estack; /* Error stack to clear */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Get 'default' error stack */ + if (NULL == (estack = H5E__get_my_stack())) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); + + /* Empty the error stack */ + if (H5E__clear_entries(estack, estack->nused) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_clear_stack() */ + +/*------------------------------------------------------------------------- + * Function: H5E__clear_stack + * + * Purpose: Clear the specified error stack + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5E__clear_stack(H5E_stack_t *estack) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + /* Check for 'default' error stack */ if (estack == NULL) if (NULL == (estack = H5E__get_my_stack())) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack"); /* Empty the error stack */ - assert(estack); if (estack->nused) if (H5E__clear_entries(estack, estack->nused) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack"); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E_clear_stack() */ +} /* end H5E__clear_stack() */ /*------------------------------------------------------------------------- * Function: H5E__pop @@ -902,7 +1744,7 @@ H5E_clear_stack(H5E_t *estack) *------------------------------------------------------------------------- */ herr_t -H5E__pop(H5E_t *estack, size_t count) +H5E__pop(H5E_stack_t *estack, size_t count) { herr_t ret_value = SUCCEED; /* Return value */ @@ -934,7 +1776,7 @@ H5E__pop(H5E_t *estack, size_t count) herr_t H5E_dump_api_stack(void) { - H5E_t *estack = H5E__get_my_stack(); + H5E_stack_t *estack = H5E__get_my_stack(); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR diff --git a/src/H5Emajdef.h b/src/H5Emajdef.h new file mode 100644 index 00000000000..b0a0c9ad193 --- /dev/null +++ b/src/H5Emajdef.h @@ -0,0 +1,65 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Generated automatically by bin/make_err -- do not edit */ +/* Add new errors to H5err.txt file */ + +#ifndef H5Emajdef_H +#define H5Emajdef_H + +/***********************************/ +/* Major error message definitions */ +/***********************************/ + +/* clang-format off */ +static const H5E_msg_t H5E_ARGS_msg_s = {false, "Invalid arguments to routine", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_ATTR_msg_s = {false, "Attribute", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BTREE_msg_s = {false, "B-Tree node", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CACHE_msg_s = {false, "Object cache", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CONTEXT_msg_s = {false, "API Context", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_DATASET_msg_s = {false, "Dataset", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_DATASPACE_msg_s = {false, "Dataspace", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_DATATYPE_msg_s = {false, "Datatype", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_EARRAY_msg_s = {false, "Extensible Array", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_EFL_msg_s = {false, "External file list", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_ERROR_msg_s = {false, "Error API", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_EVENTSET_msg_s = {false, "Event Set", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FARRAY_msg_s = {false, "Fixed Array", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FILE_msg_s = {false, "File accessibility", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FSPACE_msg_s = {false, "Free Space Manager", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FUNC_msg_s = {false, "Function entry/exit", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_HEAP_msg_s = {false, "Heap", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_ID_msg_s = {false, "Object ID", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_INTERNAL_msg_s = {false, "Internal error (too specific to document in detail)", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_IO_msg_s = {false, "Low-level I/O", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_LIB_msg_s = {false, "General library infrastructure", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_LINK_msg_s = {false, "Links", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_MAP_msg_s = {false, "Map", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NONE_MAJOR_msg_s = {false, "No error", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_OHDR_msg_s = {false, "Object header", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PAGEBUF_msg_s = {false, "Page Buffering", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PLINE_msg_s = {false, "Data filters", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PLIST_msg_s = {false, "Property lists", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PLUGIN_msg_s = {false, "Plugin for dynamically loaded library", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_REFERENCE_msg_s = {false, "References", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_RESOURCE_msg_s = {false, "Resource unavailable", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_RS_msg_s = {false, "Reference Counted Strings", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SLIST_msg_s = {false, "Skip Lists", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SOHM_msg_s = {false, "Shared Object Header Messages", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_STORAGE_msg_s = {false, "Data storage", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SYM_msg_s = {false, "Symbol table", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_TST_msg_s = {false, "Ternary Search Trees", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_VFL_msg_s = {false, "Virtual File Layer", H5E_MAJOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_VOL_msg_s = {false, "Virtual Object Layer", H5E_MAJOR, &H5E_err_cls_s}; +/* clang-format on */ + +#endif /* H5Emajdef_H */ diff --git a/src/H5Emindef.h b/src/H5Emindef.h new file mode 100644 index 00000000000..24418fc79a4 --- /dev/null +++ b/src/H5Emindef.h @@ -0,0 +1,212 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Generated automatically by bin/make_err -- do not edit */ +/* Add new errors to H5err.txt file */ + +#ifndef H5Emindef_H +#define H5Emindef_H + +/***********************************/ +/* Minor error message definitions */ +/***********************************/ + +/* clang-format off */ + +/* ARGS: Argument errors */ +static const H5E_msg_t H5E_BADRANGE_msg_s = {false, "Out of range", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BADTYPE_msg_s = {false, "Inappropriate type", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BADVALUE_msg_s = {false, "Bad value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_UNINITIALIZED_msg_s = {false, "Information is uinitialized", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_UNSUPPORTED_msg_s = {false, "Feature is unsupported", H5E_MINOR, &H5E_err_cls_s}; + +/* ASYNC: Asynchronous operation errors */ +static const H5E_msg_t H5E_CANTCANCEL_msg_s = {false, "Can't cancel operation", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTWAIT_msg_s = {false, "Can't wait on operation", H5E_MINOR, &H5E_err_cls_s}; + +/* BTREE: B-tree related errors */ +static const H5E_msg_t H5E_CANTDECODE_msg_s = {false, "Unable to decode value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTENCODE_msg_s = {false, "Unable to encode value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTFIND_msg_s = {false, "Unable to check for record", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTINSERT_msg_s = {false, "Unable to insert object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTLIST_msg_s = {false, "Unable to list node", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTMODIFY_msg_s = {false, "Unable to modify record", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTREDISTRIBUTE_msg_s = {false, "Unable to redistribute records", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTREMOVE_msg_s = {false, "Unable to remove object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSPLIT_msg_s = {false, "Unable to split node", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSWAP_msg_s = {false, "Unable to swap records", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_EXISTS_msg_s = {false, "Object already exists", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOTFOUND_msg_s = {false, "Object not found", H5E_MINOR, &H5E_err_cls_s}; + +/* CACHE: Cache related errors */ +static const H5E_msg_t H5E_CANTCLEAN_msg_s = {false, "Unable to mark metadata as clean", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCORK_msg_s = {false, "Unable to cork an object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTDEPEND_msg_s = {false, "Unable to create a flush dependency", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTDIRTY_msg_s = {false, "Unable to mark metadata as dirty", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTEXPUNGE_msg_s = {false, "Unable to expunge a metadata cache entry", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTFLUSH_msg_s = {false, "Unable to flush data from cache", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTINS_msg_s = {false, "Unable to insert metadata into cache", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTLOAD_msg_s = {false, "Unable to load metadata into cache", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTMARKCLEAN_msg_s = {false, "Unable to mark a pinned entry as clean", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTMARKDIRTY_msg_s = {false, "Unable to mark a pinned entry as dirty", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTMARKSERIALIZED_msg_s = {false, "Unable to mark an entry as serialized", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTMARKUNSERIALIZED_msg_s = {false, "Unable to mark an entry as unserialized", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTNOTIFY_msg_s = {false, "Unable to notify object about action", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTPIN_msg_s = {false, "Unable to pin cache entry", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTPROTECT_msg_s = {false, "Unable to protect metadata", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRESIZE_msg_s = {false, "Unable to resize a metadata cache entry", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSERIALIZE_msg_s = {false, "Unable to serialize data from cache", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTTAG_msg_s = {false, "Unable to tag metadata in the cache", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNCORK_msg_s = {false, "Unable to uncork an object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNDEPEND_msg_s = {false, "Unable to destroy a flush dependency", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNPIN_msg_s = {false, "Unable to un-pin cache entry", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNPROTECT_msg_s = {false, "Unable to unprotect metadata", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNSERIALIZE_msg_s = {false, "Unable to mark metadata as unserialized", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_LOGGING_msg_s = {false, "Failure in the cache logging framework", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOTCACHED_msg_s = {false, "Metadata not currently cached", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PROTECT_msg_s = {false, "Protected metadata error", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SYSTEM_msg_s = {false, "Internal error detected", H5E_MINOR, &H5E_err_cls_s}; + +/* DSPACE: Dataspace errors */ +static const H5E_msg_t H5E_BADSELECT_msg_s = {false, "Invalid selection", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTAPPEND_msg_s = {false, "Can't append object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCLIP_msg_s = {false, "Can't clip hyperslab region", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCOMPARE_msg_s = {false, "Can't compare objects", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCOUNT_msg_s = {false, "Can't count elements", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTNEXT_msg_s = {false, "Can't move to next iterator location", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSELECT_msg_s = {false, "Can't select hyperslab", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_INCONSISTENTSTATE_msg_s = {false, "Internal states are inconsistent", H5E_MINOR, &H5E_err_cls_s}; + +/* FILE: Generic low-level file I/O errors */ +static const H5E_msg_t H5E_CLOSEERROR_msg_s = {false, "Close failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FCNTL_msg_s = {false, "File control (fcntl) failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_OVERFLOW_msg_s = {false, "Address overflowed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_READERROR_msg_s = {false, "Read failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SEEKERROR_msg_s = {false, "Seek failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_WRITEERROR_msg_s = {false, "Write failed", H5E_MINOR, &H5E_err_cls_s}; + +/* FILEACC: File accessibility errors */ +static const H5E_msg_t H5E_BADFILE_msg_s = {false, "Bad file ID accessed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCLOSEFILE_msg_s = {false, "Unable to close file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCREATE_msg_s = {false, "Unable to create file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTDELETEFILE_msg_s = {false, "Unable to delete file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTLOCKFILE_msg_s = {false, "Unable to lock file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTOPENFILE_msg_s = {false, "Unable to open file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNLOCKFILE_msg_s = {false, "Unable to unlock file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FILEEXISTS_msg_s = {false, "File already exists", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_FILEOPEN_msg_s = {false, "File already open", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_MOUNT_msg_s = {false, "File mount error", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOTHDF5_msg_s = {false, "Not an HDF5 file", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_TRUNCATED_msg_s = {false, "File has been truncated", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_UNMOUNT_msg_s = {false, "File unmount error", H5E_MINOR, &H5E_err_cls_s}; + +/* FSPACE: Free space errors */ +static const H5E_msg_t H5E_CANTMERGE_msg_s = {false, "Can't merge objects", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTREVIVE_msg_s = {false, "Can't revive object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSHRINK_msg_s = {false, "Can't shrink container", H5E_MINOR, &H5E_err_cls_s}; + +/* FUNC: Function entry/exit interface errors */ +static const H5E_msg_t H5E_ALREADYINIT_msg_s = {false, "Object already initialized", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTINIT_msg_s = {false, "Unable to initialize object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRELEASE_msg_s = {false, "Unable to release object", H5E_MINOR, &H5E_err_cls_s}; + +/* GROUP: Group related errors */ +static const H5E_msg_t H5E_CANTCLOSEOBJ_msg_s = {false, "Can't close object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTOPENOBJ_msg_s = {false, "Can't open object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_COMPLEN_msg_s = {false, "Name component is too long", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_PATH_msg_s = {false, "Problem with path to object", H5E_MINOR, &H5E_err_cls_s}; + +/* HEAP: Heap errors */ +static const H5E_msg_t H5E_CANTATTACH_msg_s = {false, "Can't attach object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCOMPUTE_msg_s = {false, "Can't compute value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTEXTEND_msg_s = {false, "Can't extend heap's space", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTOPERATE_msg_s = {false, "Can't operate on object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRESTORE_msg_s = {false, "Can't restore condition", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUPDATE_msg_s = {false, "Can't update object", H5E_MINOR, &H5E_err_cls_s}; + +/* ID: Object ID related errors */ +static const H5E_msg_t H5E_BADGROUP_msg_s = {false, "Unable to find ID group information", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BADID_msg_s = {false, "Unable to find ID information (already closed?)", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTDEC_msg_s = {false, "Unable to decrement reference count", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTINC_msg_s = {false, "Unable to increment reference count", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTREGISTER_msg_s = {false, "Unable to register new ID", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOIDS_msg_s = {false, "Out of IDs for group", H5E_MINOR, &H5E_err_cls_s}; + +/* LINK: Link related errors */ +static const H5E_msg_t H5E_CANTMOVE_msg_s = {false, "Can't move object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSORT_msg_s = {false, "Can't sort objects", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NLINKS_msg_s = {false, "Too many soft links in path", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOTREGISTERED_msg_s = {false, "Link class not registered", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_TRAVERSE_msg_s = {false, "Link traversal failure", H5E_MINOR, &H5E_err_cls_s}; + +/* MAP: Map related errors */ +static const H5E_msg_t H5E_CANTPUT_msg_s = {false, "Can't put value", H5E_MINOR, &H5E_err_cls_s}; + +/* MPI: Parallel MPI errors */ +static const H5E_msg_t H5E_CANTGATHER_msg_s = {false, "Can't gather data", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRECV_msg_s = {false, "Can't receive data", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_MPI_msg_s = {false, "Some MPI function failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_MPIERRSTR_msg_s = {false, "MPI Error String", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NO_INDEPENDENT_msg_s = {false, "Can't perform independent IO", H5E_MINOR, &H5E_err_cls_s}; + +/* NONE: No error */ +static const H5E_msg_t H5E_NONE_MINOR_msg_s = {false, "No error", H5E_MINOR, &H5E_err_cls_s}; + +/* OHDR: Object header related errors */ +static const H5E_msg_t H5E_ALIGNMENT_msg_s = {false, "Alignment error", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BADITER_msg_s = {false, "Iteration failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_BADMESG_msg_s = {false, "Unrecognized message", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTDELETE_msg_s = {false, "Can't delete message", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTPACK_msg_s = {false, "Can't pack messages", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRENAME_msg_s = {false, "Unable to rename object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTRESET_msg_s = {false, "Can't reset object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_LINKCOUNT_msg_s = {false, "Bad object header link count", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_VERSION_msg_s = {false, "Wrong version number", H5E_MINOR, &H5E_err_cls_s}; + +/* PIPELINE: I/O pipeline errors */ +static const H5E_msg_t H5E_CALLBACK_msg_s = {false, "Callback failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANAPPLY_msg_s = {false, "Error from filter 'can apply' callback", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTFILTER_msg_s = {false, "Filter operation failed", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOENCODER_msg_s = {false, "Filter present but encoding disabled", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOFILTER_msg_s = {false, "Requested filter is not available", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SETLOCAL_msg_s = {false, "Error from filter 'set local' callback", H5E_MINOR, &H5E_err_cls_s}; + +/* PLIST: Property list errors */ +static const H5E_msg_t H5E_CANTGET_msg_s = {false, "Can't get value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTSET_msg_s = {false, "Can't set value", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_DUPCLASS_msg_s = {false, "Duplicate class name in parent class", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_SETDISALLOWED_msg_s = {false, "Disallowed operation", H5E_MINOR, &H5E_err_cls_s}; + +/* PLUGIN: Plugin errors */ +static const H5E_msg_t H5E_OPENERROR_msg_s = {false, "Can't open directory or file", H5E_MINOR, &H5E_err_cls_s}; + +/* RESOURCE: Resource errors */ +static const H5E_msg_t H5E_ALREADYEXISTS_msg_s = {false, "Object already exists", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTALLOC_msg_s = {false, "Can't allocate space", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCOPY_msg_s = {false, "Unable to copy object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTFREE_msg_s = {false, "Unable to free object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTGC_msg_s = {false, "Unable to garbage collect", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTGETSIZE_msg_s = {false, "Unable to compute size", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTLOCK_msg_s = {false, "Unable to lock object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTUNLOCK_msg_s = {false, "Unable to unlock object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_NOSPACE_msg_s = {false, "No space available for allocation", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_OBJOPEN_msg_s = {false, "Object is already open", H5E_MINOR, &H5E_err_cls_s}; + +/* SYSTEM: System level errors */ +static const H5E_msg_t H5E_SYSERRSTR_msg_s = {false, "System error message", H5E_MINOR, &H5E_err_cls_s}; + +/* TYPECONV: Datatype conversion errors */ +static const H5E_msg_t H5E_BADSIZE_msg_s = {false, "Bad size for object", H5E_MINOR, &H5E_err_cls_s}; +static const H5E_msg_t H5E_CANTCONVERT_msg_s = {false, "Can't convert datatypes", H5E_MINOR, &H5E_err_cls_s}; +/* clang-format on */ + +#endif /* H5Emindef_H */ diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 48373f4d974..797c3b2294f 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -34,8 +34,8 @@ /* Amount to indent each error */ #define H5E_INDENT 2 -/* Number of slots in an error stack */ -#define H5E_NSLOTS 32 +/* Number of entries in an error stack */ +#define H5E_MAX_ENTRIES 32 #ifdef H5_HAVE_THREADSAFE /* @@ -45,7 +45,7 @@ * be handled by the pthread library. * * In order for this macro to work, H5E__get_my_stack() must be preceded - * by "H5E_t *estack =". + * by "H5E_stack_t *estack =". */ #define H5E__get_my_stack() H5E__get_stack() #else /* H5_HAVE_THREADSAFE */ @@ -88,25 +88,33 @@ typedef struct { /* Error class */ typedef struct H5E_cls_t { - char *cls_name; /* Name of error class */ - char *lib_name; /* Name of library within class */ - char *lib_vers; /* Version of library */ + bool app_cls; /* Whether the class came from app */ + const char *cls_name; /* Name of error class */ + const char *lib_name; /* Name of library within class */ + const char *lib_vers; /* Version of library */ } H5E_cls_t; /* Major or minor message */ typedef struct H5E_msg_t { - char *msg; /* Message for error */ + bool app_msg; /* Whether the message came from app */ + const char *msg; /* Message for error */ H5E_type_t type; /* Type of error (major or minor) */ - H5E_cls_t *cls; /* Which error class this message belongs to */ + const H5E_cls_t *cls; /* Which error class this message belongs to */ } H5E_msg_t; +/* Error stack entry */ +typedef struct H5E_entry_t { + bool app_entry; /* Whether the entry came from app */ + H5E_error2_t err; /* Error entry */ +} H5E_entry_t; + /* Error stack */ -struct H5E_t { - size_t nused; /* Num slots currently used in stack */ - H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ +typedef struct H5E_stack_t { + size_t nused; /* Num entries currently on stack */ + H5E_entry_t entries[H5E_MAX_ENTRIES]; /* Array of error entries */ H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ void *auto_data; /* Callback data for 'automatic error reporting */ -}; +} H5E_stack_t; /*****************************/ /* Package Private Variables */ @@ -116,7 +124,7 @@ struct H5E_t { /* * The current error stack. */ -H5_DLLVAR H5E_t H5E_stack_g[1]; +H5_DLLVAR H5E_stack_t H5E_stack_g[1]; #endif /* First & last major and minor error codes registered by the library */ @@ -128,20 +136,28 @@ H5_DLLVAR hid_t H5E_last_min_id_g; /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5E__term_deprec_interface(void); #ifdef H5_HAVE_THREADSAFE -H5_DLL H5E_t *H5E__get_stack(void); +H5_DLL H5E_stack_t *H5E__get_stack(void); #endif /* H5_HAVE_THREADSAFE */ -H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, - hid_t maj_id, hid_t min_id, const char *desc); -H5_DLL herr_t H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc); +H5_DLL H5E_cls_t *H5E__register_class(const char *cls_name, const char *lib_name, const char *version); +H5_DLL ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); +H5_DLL H5E_msg_t *H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); -H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, bool bk_compat); -H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, +H5_DLL void H5E__set_default_auto(H5E_stack_t *stk); +H5_DLL H5E_stack_t *H5E__get_current_stack(void); +H5_DLL herr_t H5E__set_current_stack(H5E_stack_t *estack); +H5_DLL ssize_t H5E__get_num(const H5E_stack_t *err_stack); +H5_DLL herr_t H5E__push_stack(H5E_stack_t *estack, bool app_entry, const char *file, const char *func, + unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, + va_list *ap); +H5_DLL herr_t H5E__print(const H5E_stack_t *estack, FILE *stream, bool bk_compat); +H5_DLL herr_t H5E__print2(hid_t err_stack, FILE *stream); +H5_DLL herr_t H5E__walk(const H5E_stack_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, void *client_data); -H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data); -H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data); -H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count); +H5_DLL herr_t H5E__get_auto(const H5E_stack_t *estack, H5E_auto_op_t *op, void **client_data); +H5_DLL herr_t H5E__set_auto(H5E_stack_t *estack, const H5E_auto_op_t *op, void *client_data); +H5_DLL herr_t H5E__pop(H5E_stack_t *err_stack, size_t count); +H5_DLL herr_t H5E__append_stack(H5E_stack_t *dst_estack, const H5E_stack_t *src_stack); +H5_DLL herr_t H5E__clear_stack(H5E_stack_t *estack); #endif /* H5Epkg_H */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index fd86e96806b..3777805aeb9 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -21,9 +21,6 @@ /* Private headers needed by this file */ #include "H5private.h" -/* Typedef for error stack (defined in H5Epkg.h) */ -typedef struct H5E_t H5E_t; - /* * HERROR macro, used to facilitate error reporting between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The arguments are the major @@ -31,7 +28,7 @@ typedef struct H5E_t H5E_t; */ #define HERROR(maj_id, min_id, ...) \ do { \ - H5E_printf_stack(NULL, __FILE__, __func__, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__); \ + H5E_printf_stack(__FILE__, __func__, __LINE__, maj_id, min_id, __VA_ARGS__); \ } while (0) /* @@ -185,9 +182,9 @@ extern int H5E_mpi_error_str_len; /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); -H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, - hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); -H5_DLL herr_t H5E_clear_stack(H5E_t *estack); +H5_DLL herr_t H5E_printf_stack(const char *file, const char *func, unsigned line, hid_t maj_idx, + hid_t min_idx, const char *fmt, ...) H5_ATTR_FORMAT(printf, 6, 7); +H5_DLL herr_t H5E_clear_stack(void); H5_DLL herr_t H5E_dump_api_stack(void); #endif /* H5Eprivate_H */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 22efa901812..49fd484a4eb 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -779,7 +779,7 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad if (!file->memb[file->nmembs]) { if (0 == file->nmembs) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file"); - H5E_clear_stack(NULL); + H5E_clear_stack(); break; } file->nmembs++; @@ -1497,7 +1497,7 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) if (0 == current_member) HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete member file"); else - H5E_clear_stack(NULL); + H5E_clear_stack(); break; } current_member++; diff --git a/src/H5FDonion.c b/src/H5FDonion.c index 45a90de9165..f1b46d83ada 100644 --- a/src/H5FDonion.c +++ b/src/H5FDonion.c @@ -468,7 +468,7 @@ H5FD__onion_commit_new_revision_record(H5FD_onion_t *file) if ((true == file->is_open_rw) && (H5FD__onion_merge_revision_index_into_archival_index( file->rev_index, &file->curr_rev_record.archival_index) < 0)) - HGOTO_ERROR(H5E_VFL, H5E_INTERNAL, FAIL, "unable to update index to write"); + HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to update index to write"); if (NULL == (buf = H5MM_malloc(H5FD_ONION_ENCODED_SIZE_REVISION_RECORD + (size_t)rec->comment_size + (H5FD_ONION_ENCODED_SIZE_INDEX_ENTRY * rec->archival_index.n_entries)))) diff --git a/src/H5Fint.c b/src/H5Fint.c index 45ded824a7e..3c3c4cb8dd3 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -859,7 +859,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c char *ptr; /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Get last component of file_name */ H5_GET_LAST_DELIMITER(file_name, ptr) @@ -880,7 +880,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Adjust temporary file name if file not opened */ if (NULL == src_file) { /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Strip ":" */ strncpy(temp_file_name, &file_name[2], temp_file_name_len); @@ -928,11 +928,11 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Check for file not opened */ if (NULL == src_file) /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Leave if file was opened */ else break; - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ } /* end while */ @@ -955,7 +955,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Check for file not opened */ if (NULL == src_file) /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ /* Try searching from main file's "extpath": see description in H5F_open() & H5_build_extpath() */ @@ -976,7 +976,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Check for file not opened */ if (NULL == src_file) /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ } /* end if */ @@ -988,7 +988,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Check for file not opened */ if (NULL == src_file) /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ /* try the 'resolved' name for the virtual file */ @@ -1019,7 +1019,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Check for file not opened */ if (NULL == src_file) /* Reset the error stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); } /* end if */ /* Set return value (possibly NULL or valid H5F_t *) */ @@ -1893,7 +1893,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) */ if ((tent_flags == flags) || (lf == NULL)) { if (tent_flags != flags) { - H5E_clear_stack(NULL); + H5E_clear_stack(); tent_flags = flags; } diff --git a/src/H5Gint.c b/src/H5Gint.c index 34072df90e6..8630be1b444 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -439,7 +439,7 @@ H5G_open(const H5G_loc_t *loc) if ((shared_fo = (H5G_shared_t *)H5FO_opened(grp->oloc.file, grp->oloc.addr)) == NULL) { /* Clear any errors from H5FO_opened() */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Open the group object */ if (H5G__open_oid(grp) < 0) diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 6e9d29845a0..897debcb1bd 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -591,7 +591,7 @@ H5G__loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_ if (lnk) *exists = false; else - HGOTO_ERROR(H5E_SYM, H5E_INTERNAL, FAIL, "no object or link info?"); + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no object or link info?"); else *exists = true; diff --git a/src/H5Gnode.c b/src/H5Gnode.c index f211e74e041..cc45f39b1d6 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1428,7 +1428,7 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, had if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) { H5G_bt_common_t udata; /*data to pass through B-tree */ - H5E_clear_stack(NULL); /* discard that error */ + H5E_clear_stack(); /* discard that error */ udata.heap = heap; udata.block_size = H5HL_heap_get_size(heap); if (H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 1ebd13681b1..6c7e6db8824 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -999,7 +999,7 @@ H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab) /* Update the symbol table message and clear errors if necessary */ if (changed) { - H5E_clear_stack(NULL); + H5E_clear_stack(); if (H5O_msg_write(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME | H5O_UPDATE_FORCE, &stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to correct symbol table message"); } /* end if */ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 00732c3c987..d113b576b18 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -199,7 +199,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G /* Check if we just needed to know if the object exists */ if (target & H5G_TARGET_EXISTS) { /* Clear any errors from the stack */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Indicate that the object doesn't exist */ *obj_exists = false; diff --git a/src/H5Iint.c b/src/H5Iint.c index 1df3ae907a8..fe3b90c2454 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -1230,27 +1230,6 @@ H5I_dec_app_ref_always_close_async(hid_t id, void **token) FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_app_ref_always_close_async() */ -/*------------------------------------------------------------------------- - * Function: H5I_do_inc_ref - * - * Purpose: Helper function for H5I_inc_ref/H5I_inc_ref_noherr to - * actually increment the reference count for an object. - * - * Return: The new reference count (can't fail) - * - *------------------------------------------------------------------------- - */ -static inline int -H5I_do_inc_ref(H5I_id_info_t *info, bool app_ref) -{ - /* Adjust reference counts */ - ++(info->count); - if (app_ref) - ++(info->app_count); - - return (int)(app_ref ? info->app_count : info->count); -} - /*------------------------------------------------------------------------- * Function: H5I_inc_ref * @@ -1276,58 +1255,17 @@ H5I_inc_ref(hid_t id, bool app_ref) if (NULL == (info = H5I__find_id(id))) HGOTO_ERROR(H5E_ID, H5E_BADID, (-1), "can't locate ID"); - /* Set return value */ - ret_value = H5I_do_inc_ref(info, app_ref); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_inc_ref_noherr - * - * Purpose: Increment the reference count for an object. Exactly like - * H5I_inc_ref, except that it makes use of HGOTO_DONE on - * failure instead of HGOTO_ERROR. This function is - * specifically meant to be used in the H5E package, where we - * have to avoid calling any function or macro that may call - * HGOTO_ERROR and similar. Otherwise, we can cause a stack - * overflow that looks like (for example): - * - * H5E_printf_stack() - * H5E__push_stack() - * H5I_inc_ref() - * H5I__find_id() (FAIL) - * HGOTO_ERROR() - * H5E_printf_stack() - * ... - * - * Return: Success: The new reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_inc_ref_noherr(hid_t id, bool app_ref) -{ - H5I_id_info_t *info = NULL; /* Pointer to the ID info */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - /* Sanity check */ - assert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (info = H5I__find_id(id))) - HGOTO_DONE((-1)); + /* Adjust reference counts */ + ++(info->count); + if (app_ref) + ++(info->app_count); /* Set return value */ - ret_value = H5I_do_inc_ref(info, app_ref); + ret_value = (int)(app_ref ? info->app_count : info->count); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_ref_noherr() */ +} /* end H5I_inc_ref() */ /*------------------------------------------------------------------------- * Function: H5I_get_ref diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 83fdacc686f..75a5787b616 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -68,7 +68,6 @@ H5_DLL H5I_type_t H5I_get_type(hid_t id); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, bool app_ref); H5_DLL int H5I_get_ref(hid_t id, bool app_ref); H5_DLL int H5I_inc_ref(hid_t id, bool app_ref); -H5_DLL int H5I_inc_ref_noherr(hid_t id, bool app_ref); H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_async(hid_t id, void **token); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index d6002046269..6299b7583af 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1468,7 +1468,7 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*i if (H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc /*out*/) < 0) /* Ignore errors - i.e. suggestions not present in * destination file */ - H5E_clear_stack(NULL); + H5E_clear_stack(); else /* Check object and add to skip list if appropriate */ if (H5O__copy_search_comm_dt_check(&obj_oloc, &udata) < 0) { diff --git a/src/H5Oint.c b/src/H5Oint.c index e7fcf0cd270..e02ded4b87d 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -1601,7 +1601,7 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) /* Look up class for object header */ if (NULL == (obj_class = H5O__obj_class_real(oh))) { /* Clear error stack from "failed" class lookup */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Set type to "unknown" */ *obj_type = H5O_TYPE_UNKNOWN; diff --git a/src/H5SM.c b/src/H5SM.c index 5179a285ee9..18f8d23fe54 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -944,7 +944,7 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un * then this type of message isn't shareable */ if ((index_num = H5SM__get_index(my_table, type_id)) < 0) { - H5E_clear_stack(NULL); /*ignore error*/ + H5E_clear_stack(); /*ignore error*/ HGOTO_DONE(false); } /* end if */ @@ -1337,7 +1337,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def found = true; } /* end if */ else - H5E_clear_stack(NULL); /*ignore error*/ + H5E_clear_stack(); /*ignore error*/ } /* end else */ } /* end else */ diff --git a/src/H5T.c b/src/H5T.c index dc531f85a70..b8e568198f7 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -2727,14 +2727,14 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_con "unable to decrement reference count on temporary ID"); tmp_sid = tmp_did = H5I_INVALID_HID; tmp_stype = tmp_dtype = NULL; - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); continue; } /* end if */ } /* end if */ else if ((conv->u.lib_func)(old_path->src, old_path->dst, &cdata, &conv_ctx, 0, 0, 0, NULL, NULL) < 0) { - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); continue; } /* end if */ @@ -2776,7 +2776,7 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_con } /* We don't care about any failures during the freeing process */ - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); } /* end for */ } /* end else */ @@ -3891,7 +3891,7 @@ H5T_copy_reopen(H5T_t *old_dt) if (NULL == (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) { /* Clear any errors from H5FO_opened() */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Open named datatype again */ if (H5O_open(&old_dt->oloc) < 0) @@ -5298,7 +5298,7 @@ H5T__init_path_table(void) fprintf(H5DEBUG(T), "H5T: unable to initialize no-op conversion function (ignored)\n"); #endif /* Ignore any errors from the conversion function */ - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); } /* end if */ @@ -5431,7 +5431,7 @@ H5T__path_find_init_new_path(H5T_path_t *path, const H5T_t *src, const H5T_t *ds if (status < 0) { memset(&(path->cdata), 0, sizeof(H5T_cdata_t)); /* ignore the error */ - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); path_init_error = true; } @@ -5516,7 +5516,7 @@ H5T__path_free(H5T_path_t *path, H5T_conv_ctx_t *conv_ctx) if (status < 0) { /* Ignore any error from shutting down the path */ - if (H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack() < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to clear current error stack"); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index eed0e3b1dc4..e1b4e0d1a7a 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -1037,7 +1037,7 @@ H5T_open(const H5G_loc_t *loc) /* Check if datatype was already open */ if (NULL == (shared_fo = (H5T_shared_t *)H5FO_opened(loc->oloc->file, loc->oloc->addr))) { /* Clear any errors from H5FO_opened() */ - H5E_clear_stack(NULL); + H5E_clear_stack(); /* Open the datatype object */ if (NULL == (dt = H5T__open_oid(loc))) diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index f34954d1517..02622dab936 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -3806,7 +3806,7 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned * Otherwise, if no VOL connectors are available, throw * error from original file open failure. */ - H5E_clear_stack(NULL); + H5E_clear_stack(); if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, find_connector_ud.fapl_id, dxpl_id, req))) diff --git a/src/H5Z.c b/src/H5Z.c index a7c1d76c782..d995f0676c6 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -781,7 +781,7 @@ H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, hi if (NULL == (fclass = H5Z_find(pline->filter[u].id))) { /* Ignore errors from optional filters */ if (pline->filter[u].flags & H5Z_FLAG_OPTIONAL) - H5E_clear_stack(NULL); + H5E_clear_stack(); else HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located"); } /* end if */ @@ -1448,7 +1448,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*i *nbytes = *buf_size; failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack(); } else *nbytes = new_nbytes; @@ -1465,7 +1465,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*i if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered"); failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack(); continue; /* filter excluded */ } /* end if */ @@ -1501,7 +1501,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*i *nbytes = *buf_size; } failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack(); } else *nbytes = new_nbytes; diff --git a/src/H5private.h b/src/H5private.h index 148ac884072..0019febb441 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1280,7 +1280,7 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props); FUNC_ENTER_API_INIT(err); \ FUNC_ENTER_API_PUSH(err); \ /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ + H5E_clear_stack(); \ { /* diff --git a/src/H5public.h b/src/H5public.h index 7bd3665fb3b..8798e78dd72 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -88,6 +88,10 @@ * For pre-releases like \c snap0. Empty string for official releases. */ #define H5_VERS_SUBRELEASE "" +/** + * Short version string + */ +#define H5_VERS_STR "1.15.0" /** * Full version string */ diff --git a/src/Makefile.am b/src/Makefile.am index 5e081a38275..35ba9f6b42b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -183,9 +183,9 @@ settings_DATA=libhdf5.settings # Error header generation # -# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all -# depend on H5err.txt, but the perl script generates them all, so just -# list one here. +# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h, H5Emajdef.h, H5Emindef.h, +# and H5Epubgen.h all depend on H5err.txt, but the perl script generates them +# all, so just list one here. $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt perl $(top_srcdir)/bin/make_err $? From 06118adea50521826f1f76f620a04fefc0618311 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 21:56:09 +0000 Subject: [PATCH 2/8] Committing clang-format changes --- src/H5E.c | 22 +++++++++++----------- src/H5Edeprec.c | 4 ++-- src/H5Eint.c | 27 +++++++++++++-------------- src/H5Epkg.h | 10 +++++----- src/H5SM.c | 4 ++-- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index b6be0a53084..0eb256f4ad4 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -292,7 +292,7 @@ hid_t H5Ecreate_stack(void) { H5E_stack_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -326,7 +326,7 @@ hid_t H5Eget_current_stack(void) { H5E_stack_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5I_INVALID_HID) @@ -357,7 +357,7 @@ herr_t H5Eset_current_stack(hid_t err_stack) { H5E_stack_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -428,7 +428,7 @@ ssize_t H5Eget_num(hid_t error_stack_id) { H5E_stack_t *estack; /* Error stack to operate on */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR((-1)) @@ -468,7 +468,7 @@ herr_t H5Epop(hid_t err_stack, size_t count) { H5E_stack_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) @@ -523,11 +523,11 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid hid_t min_id, const char *fmt, ...) { H5E_stack_t *estack; /* Pointer to error stack to modify */ - va_list ap; /* Varargs info */ - bool va_started = false; /* Whether the variable argument list is open */ + va_list ap; /* Varargs info */ + bool va_started = false; /* Whether the variable argument list is open */ const char *tmp_file; /* Copy of the file name */ const char *tmp_func; /* Copy of the function name */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) @@ -593,7 +593,7 @@ herr_t H5Eclear2(hid_t err_stack) { H5E_stack_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) @@ -820,7 +820,7 @@ herr_t H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) { H5E_stack_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) @@ -863,7 +863,7 @@ herr_t H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_stack) { H5E_stack_t *dst_stack, *src_stack; /* Error stacks */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API(FAIL) diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index ed7b92828d7..06648000ae1 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -184,7 +184,7 @@ H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E { const char *tmp_file; /* Copy of the file name */ const char *tmp_func; /* Copy of the function name */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) @@ -254,7 +254,7 @@ herr_t H5Eprint1(FILE *stream) { H5E_stack_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) diff --git a/src/H5Eint.c b/src/H5Eint.c index 75a5a2f0bd8..47cabe8c7c4 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -849,7 +849,6 @@ H5E__set_default_auto(H5E_stack_t *stk) stk->auto_data = NULL; - FUNC_LEAVE_NOAPI_VOID } /* end H5E__set_default_auto() */ @@ -926,15 +925,15 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) { - H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE *stream; /* I/O stream to print output to */ + H5E_print_t *eprint = (H5E_print_t *)client_data; + FILE *stream; /* I/O stream to print output to */ const H5E_cls_t *cls_ptr; /* Pointer to error class */ - H5E_msg_t *maj_ptr; /* Pointer to major error info */ - H5E_msg_t *min_ptr; /* Pointer to minor error info */ - const char *maj_str = "No major description"; /* Major error description */ - const char *min_str = "No minor description"; /* Minor error description */ + H5E_msg_t *maj_ptr; /* Pointer to major error info */ + H5E_msg_t *min_ptr; /* Pointer to minor error info */ + const char *maj_str = "No major description"; /* Major error description */ + const char *min_str = "No minor description"; /* Minor error description */ bool have_desc = true; /* Flag to indicate whether the error has a "real" description */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -1579,7 +1578,7 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func /* Set the entry fields */ /* NOTE: non-library IDs have already been incremented */ - err_entry->cls_id = cls_id; + err_entry->cls_id = cls_id; err_entry->maj_num = maj_id; err_entry->min_num = min_id; /* The 'func' & 'file' strings are either statically allocated (by the @@ -1599,7 +1598,7 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func */ H5_GCC_CLANG_DIAG_OFF("format-nonliteral") if (HDvasprintf(&desc, fmt, *ap) < 0) - HGOTO_DONE(FAIL); + HGOTO_DONE(FAIL); H5_GCC_CLANG_DIAG_ON("format-nonliteral") err_entry->desc = desc; @@ -1626,8 +1625,8 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func static herr_t H5E__clear_entries(H5E_stack_t *estack, size_t nentries) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1687,7 +1686,7 @@ herr_t H5E_clear_stack(void) { H5E_stack_t *estack; /* Error stack to clear */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1777,7 +1776,7 @@ herr_t H5E_dump_api_stack(void) { H5E_stack_t *estack = H5E__get_my_stack(); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 797c3b2294f..2d950ca3d7b 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -98,7 +98,7 @@ typedef struct H5E_cls_t { typedef struct H5E_msg_t { bool app_msg; /* Whether the message came from app */ const char *msg; /* Message for error */ - H5E_type_t type; /* Type of error (major or minor) */ + H5E_type_t type; /* Type of error (major or minor) */ const H5E_cls_t *cls; /* Which error class this message belongs to */ } H5E_msg_t; @@ -112,8 +112,8 @@ typedef struct H5E_entry_t { typedef struct H5E_stack_t { size_t nused; /* Num entries currently on stack */ H5E_entry_t entries[H5E_MAX_ENTRIES]; /* Array of error entries */ - H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ - void *auto_data; /* Callback data for 'automatic error reporting */ + H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ + void *auto_data; /* Callback data for 'automatic error reporting */ } H5E_stack_t; /*****************************/ @@ -142,7 +142,7 @@ H5_DLL H5E_stack_t *H5E__get_stack(void); H5_DLL H5E_cls_t *H5E__register_class(const char *cls_name, const char *lib_name, const char *version); H5_DLL ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); H5_DLL H5E_msg_t *H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); -H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); +H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); H5_DLL void H5E__set_default_auto(H5E_stack_t *stk); H5_DLL H5E_stack_t *H5E__get_current_stack(void); H5_DLL herr_t H5E__set_current_stack(H5E_stack_t *estack); @@ -153,7 +153,7 @@ H5_DLL herr_t H5E__push_stack(H5E_stack_t *estack, bool app_entry, const c H5_DLL herr_t H5E__print(const H5E_stack_t *estack, FILE *stream, bool bk_compat); H5_DLL herr_t H5E__print2(hid_t err_stack, FILE *stream); H5_DLL herr_t H5E__walk(const H5E_stack_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, - void *client_data); + void *client_data); H5_DLL herr_t H5E__get_auto(const H5E_stack_t *estack, H5E_auto_op_t *op, void **client_data); H5_DLL herr_t H5E__set_auto(H5E_stack_t *estack, const H5E_auto_op_t *op, void *client_data); H5_DLL herr_t H5E__pop(H5E_stack_t *err_stack, size_t count); diff --git a/src/H5SM.c b/src/H5SM.c index 18f8d23fe54..94f2ea534fc 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1338,8 +1338,8 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def } /* end if */ else H5E_clear_stack(); /*ignore error*/ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ if (found) { /* If the message was found, it's shared in the heap (now). Set up a From a5dcea4fec1d89f55cd7ce289424ff938b3240d7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 2 May 2024 07:44:31 -0500 Subject: [PATCH 3/8] Remove generated H5E headers Signed-off-by: Quincey Koziol --- src/H5Emajdef.h | 65 --------------- src/H5Emindef.h | 212 ------------------------------------------------ 2 files changed, 277 deletions(-) delete mode 100644 src/H5Emajdef.h delete mode 100644 src/H5Emindef.h diff --git a/src/H5Emajdef.h b/src/H5Emajdef.h deleted file mode 100644 index b0a0c9ad193..00000000000 --- a/src/H5Emajdef.h +++ /dev/null @@ -1,65 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Generated automatically by bin/make_err -- do not edit */ -/* Add new errors to H5err.txt file */ - -#ifndef H5Emajdef_H -#define H5Emajdef_H - -/***********************************/ -/* Major error message definitions */ -/***********************************/ - -/* clang-format off */ -static const H5E_msg_t H5E_ARGS_msg_s = {false, "Invalid arguments to routine", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_ATTR_msg_s = {false, "Attribute", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BTREE_msg_s = {false, "B-Tree node", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CACHE_msg_s = {false, "Object cache", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CONTEXT_msg_s = {false, "API Context", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_DATASET_msg_s = {false, "Dataset", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_DATASPACE_msg_s = {false, "Dataspace", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_DATATYPE_msg_s = {false, "Datatype", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_EARRAY_msg_s = {false, "Extensible Array", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_EFL_msg_s = {false, "External file list", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_ERROR_msg_s = {false, "Error API", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_EVENTSET_msg_s = {false, "Event Set", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FARRAY_msg_s = {false, "Fixed Array", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FILE_msg_s = {false, "File accessibility", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FSPACE_msg_s = {false, "Free Space Manager", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FUNC_msg_s = {false, "Function entry/exit", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_HEAP_msg_s = {false, "Heap", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_ID_msg_s = {false, "Object ID", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_INTERNAL_msg_s = {false, "Internal error (too specific to document in detail)", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_IO_msg_s = {false, "Low-level I/O", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_LIB_msg_s = {false, "General library infrastructure", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_LINK_msg_s = {false, "Links", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_MAP_msg_s = {false, "Map", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NONE_MAJOR_msg_s = {false, "No error", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_OHDR_msg_s = {false, "Object header", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PAGEBUF_msg_s = {false, "Page Buffering", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PLINE_msg_s = {false, "Data filters", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PLIST_msg_s = {false, "Property lists", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PLUGIN_msg_s = {false, "Plugin for dynamically loaded library", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_REFERENCE_msg_s = {false, "References", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_RESOURCE_msg_s = {false, "Resource unavailable", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_RS_msg_s = {false, "Reference Counted Strings", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SLIST_msg_s = {false, "Skip Lists", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SOHM_msg_s = {false, "Shared Object Header Messages", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_STORAGE_msg_s = {false, "Data storage", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SYM_msg_s = {false, "Symbol table", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_TST_msg_s = {false, "Ternary Search Trees", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_VFL_msg_s = {false, "Virtual File Layer", H5E_MAJOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_VOL_msg_s = {false, "Virtual Object Layer", H5E_MAJOR, &H5E_err_cls_s}; -/* clang-format on */ - -#endif /* H5Emajdef_H */ diff --git a/src/H5Emindef.h b/src/H5Emindef.h deleted file mode 100644 index 24418fc79a4..00000000000 --- a/src/H5Emindef.h +++ /dev/null @@ -1,212 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Generated automatically by bin/make_err -- do not edit */ -/* Add new errors to H5err.txt file */ - -#ifndef H5Emindef_H -#define H5Emindef_H - -/***********************************/ -/* Minor error message definitions */ -/***********************************/ - -/* clang-format off */ - -/* ARGS: Argument errors */ -static const H5E_msg_t H5E_BADRANGE_msg_s = {false, "Out of range", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BADTYPE_msg_s = {false, "Inappropriate type", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BADVALUE_msg_s = {false, "Bad value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_UNINITIALIZED_msg_s = {false, "Information is uinitialized", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_UNSUPPORTED_msg_s = {false, "Feature is unsupported", H5E_MINOR, &H5E_err_cls_s}; - -/* ASYNC: Asynchronous operation errors */ -static const H5E_msg_t H5E_CANTCANCEL_msg_s = {false, "Can't cancel operation", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTWAIT_msg_s = {false, "Can't wait on operation", H5E_MINOR, &H5E_err_cls_s}; - -/* BTREE: B-tree related errors */ -static const H5E_msg_t H5E_CANTDECODE_msg_s = {false, "Unable to decode value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTENCODE_msg_s = {false, "Unable to encode value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTFIND_msg_s = {false, "Unable to check for record", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTINSERT_msg_s = {false, "Unable to insert object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTLIST_msg_s = {false, "Unable to list node", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTMODIFY_msg_s = {false, "Unable to modify record", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTREDISTRIBUTE_msg_s = {false, "Unable to redistribute records", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTREMOVE_msg_s = {false, "Unable to remove object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSPLIT_msg_s = {false, "Unable to split node", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSWAP_msg_s = {false, "Unable to swap records", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_EXISTS_msg_s = {false, "Object already exists", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOTFOUND_msg_s = {false, "Object not found", H5E_MINOR, &H5E_err_cls_s}; - -/* CACHE: Cache related errors */ -static const H5E_msg_t H5E_CANTCLEAN_msg_s = {false, "Unable to mark metadata as clean", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCORK_msg_s = {false, "Unable to cork an object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTDEPEND_msg_s = {false, "Unable to create a flush dependency", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTDIRTY_msg_s = {false, "Unable to mark metadata as dirty", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTEXPUNGE_msg_s = {false, "Unable to expunge a metadata cache entry", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTFLUSH_msg_s = {false, "Unable to flush data from cache", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTINS_msg_s = {false, "Unable to insert metadata into cache", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTLOAD_msg_s = {false, "Unable to load metadata into cache", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTMARKCLEAN_msg_s = {false, "Unable to mark a pinned entry as clean", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTMARKDIRTY_msg_s = {false, "Unable to mark a pinned entry as dirty", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTMARKSERIALIZED_msg_s = {false, "Unable to mark an entry as serialized", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTMARKUNSERIALIZED_msg_s = {false, "Unable to mark an entry as unserialized", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTNOTIFY_msg_s = {false, "Unable to notify object about action", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTPIN_msg_s = {false, "Unable to pin cache entry", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTPROTECT_msg_s = {false, "Unable to protect metadata", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRESIZE_msg_s = {false, "Unable to resize a metadata cache entry", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSERIALIZE_msg_s = {false, "Unable to serialize data from cache", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTTAG_msg_s = {false, "Unable to tag metadata in the cache", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNCORK_msg_s = {false, "Unable to uncork an object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNDEPEND_msg_s = {false, "Unable to destroy a flush dependency", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNPIN_msg_s = {false, "Unable to un-pin cache entry", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNPROTECT_msg_s = {false, "Unable to unprotect metadata", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNSERIALIZE_msg_s = {false, "Unable to mark metadata as unserialized", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_LOGGING_msg_s = {false, "Failure in the cache logging framework", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOTCACHED_msg_s = {false, "Metadata not currently cached", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PROTECT_msg_s = {false, "Protected metadata error", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SYSTEM_msg_s = {false, "Internal error detected", H5E_MINOR, &H5E_err_cls_s}; - -/* DSPACE: Dataspace errors */ -static const H5E_msg_t H5E_BADSELECT_msg_s = {false, "Invalid selection", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTAPPEND_msg_s = {false, "Can't append object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCLIP_msg_s = {false, "Can't clip hyperslab region", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCOMPARE_msg_s = {false, "Can't compare objects", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCOUNT_msg_s = {false, "Can't count elements", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTNEXT_msg_s = {false, "Can't move to next iterator location", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSELECT_msg_s = {false, "Can't select hyperslab", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_INCONSISTENTSTATE_msg_s = {false, "Internal states are inconsistent", H5E_MINOR, &H5E_err_cls_s}; - -/* FILE: Generic low-level file I/O errors */ -static const H5E_msg_t H5E_CLOSEERROR_msg_s = {false, "Close failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FCNTL_msg_s = {false, "File control (fcntl) failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_OVERFLOW_msg_s = {false, "Address overflowed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_READERROR_msg_s = {false, "Read failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SEEKERROR_msg_s = {false, "Seek failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_WRITEERROR_msg_s = {false, "Write failed", H5E_MINOR, &H5E_err_cls_s}; - -/* FILEACC: File accessibility errors */ -static const H5E_msg_t H5E_BADFILE_msg_s = {false, "Bad file ID accessed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCLOSEFILE_msg_s = {false, "Unable to close file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCREATE_msg_s = {false, "Unable to create file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTDELETEFILE_msg_s = {false, "Unable to delete file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTLOCKFILE_msg_s = {false, "Unable to lock file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTOPENFILE_msg_s = {false, "Unable to open file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNLOCKFILE_msg_s = {false, "Unable to unlock file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FILEEXISTS_msg_s = {false, "File already exists", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_FILEOPEN_msg_s = {false, "File already open", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_MOUNT_msg_s = {false, "File mount error", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOTHDF5_msg_s = {false, "Not an HDF5 file", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_TRUNCATED_msg_s = {false, "File has been truncated", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_UNMOUNT_msg_s = {false, "File unmount error", H5E_MINOR, &H5E_err_cls_s}; - -/* FSPACE: Free space errors */ -static const H5E_msg_t H5E_CANTMERGE_msg_s = {false, "Can't merge objects", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTREVIVE_msg_s = {false, "Can't revive object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSHRINK_msg_s = {false, "Can't shrink container", H5E_MINOR, &H5E_err_cls_s}; - -/* FUNC: Function entry/exit interface errors */ -static const H5E_msg_t H5E_ALREADYINIT_msg_s = {false, "Object already initialized", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTINIT_msg_s = {false, "Unable to initialize object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRELEASE_msg_s = {false, "Unable to release object", H5E_MINOR, &H5E_err_cls_s}; - -/* GROUP: Group related errors */ -static const H5E_msg_t H5E_CANTCLOSEOBJ_msg_s = {false, "Can't close object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTOPENOBJ_msg_s = {false, "Can't open object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_COMPLEN_msg_s = {false, "Name component is too long", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_PATH_msg_s = {false, "Problem with path to object", H5E_MINOR, &H5E_err_cls_s}; - -/* HEAP: Heap errors */ -static const H5E_msg_t H5E_CANTATTACH_msg_s = {false, "Can't attach object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCOMPUTE_msg_s = {false, "Can't compute value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTEXTEND_msg_s = {false, "Can't extend heap's space", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTOPERATE_msg_s = {false, "Can't operate on object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRESTORE_msg_s = {false, "Can't restore condition", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUPDATE_msg_s = {false, "Can't update object", H5E_MINOR, &H5E_err_cls_s}; - -/* ID: Object ID related errors */ -static const H5E_msg_t H5E_BADGROUP_msg_s = {false, "Unable to find ID group information", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BADID_msg_s = {false, "Unable to find ID information (already closed?)", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTDEC_msg_s = {false, "Unable to decrement reference count", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTINC_msg_s = {false, "Unable to increment reference count", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTREGISTER_msg_s = {false, "Unable to register new ID", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOIDS_msg_s = {false, "Out of IDs for group", H5E_MINOR, &H5E_err_cls_s}; - -/* LINK: Link related errors */ -static const H5E_msg_t H5E_CANTMOVE_msg_s = {false, "Can't move object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSORT_msg_s = {false, "Can't sort objects", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NLINKS_msg_s = {false, "Too many soft links in path", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOTREGISTERED_msg_s = {false, "Link class not registered", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_TRAVERSE_msg_s = {false, "Link traversal failure", H5E_MINOR, &H5E_err_cls_s}; - -/* MAP: Map related errors */ -static const H5E_msg_t H5E_CANTPUT_msg_s = {false, "Can't put value", H5E_MINOR, &H5E_err_cls_s}; - -/* MPI: Parallel MPI errors */ -static const H5E_msg_t H5E_CANTGATHER_msg_s = {false, "Can't gather data", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRECV_msg_s = {false, "Can't receive data", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_MPI_msg_s = {false, "Some MPI function failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_MPIERRSTR_msg_s = {false, "MPI Error String", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NO_INDEPENDENT_msg_s = {false, "Can't perform independent IO", H5E_MINOR, &H5E_err_cls_s}; - -/* NONE: No error */ -static const H5E_msg_t H5E_NONE_MINOR_msg_s = {false, "No error", H5E_MINOR, &H5E_err_cls_s}; - -/* OHDR: Object header related errors */ -static const H5E_msg_t H5E_ALIGNMENT_msg_s = {false, "Alignment error", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BADITER_msg_s = {false, "Iteration failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_BADMESG_msg_s = {false, "Unrecognized message", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTDELETE_msg_s = {false, "Can't delete message", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTPACK_msg_s = {false, "Can't pack messages", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRENAME_msg_s = {false, "Unable to rename object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTRESET_msg_s = {false, "Can't reset object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_LINKCOUNT_msg_s = {false, "Bad object header link count", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_VERSION_msg_s = {false, "Wrong version number", H5E_MINOR, &H5E_err_cls_s}; - -/* PIPELINE: I/O pipeline errors */ -static const H5E_msg_t H5E_CALLBACK_msg_s = {false, "Callback failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANAPPLY_msg_s = {false, "Error from filter 'can apply' callback", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTFILTER_msg_s = {false, "Filter operation failed", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOENCODER_msg_s = {false, "Filter present but encoding disabled", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOFILTER_msg_s = {false, "Requested filter is not available", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SETLOCAL_msg_s = {false, "Error from filter 'set local' callback", H5E_MINOR, &H5E_err_cls_s}; - -/* PLIST: Property list errors */ -static const H5E_msg_t H5E_CANTGET_msg_s = {false, "Can't get value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTSET_msg_s = {false, "Can't set value", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_DUPCLASS_msg_s = {false, "Duplicate class name in parent class", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_SETDISALLOWED_msg_s = {false, "Disallowed operation", H5E_MINOR, &H5E_err_cls_s}; - -/* PLUGIN: Plugin errors */ -static const H5E_msg_t H5E_OPENERROR_msg_s = {false, "Can't open directory or file", H5E_MINOR, &H5E_err_cls_s}; - -/* RESOURCE: Resource errors */ -static const H5E_msg_t H5E_ALREADYEXISTS_msg_s = {false, "Object already exists", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTALLOC_msg_s = {false, "Can't allocate space", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCOPY_msg_s = {false, "Unable to copy object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTFREE_msg_s = {false, "Unable to free object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTGC_msg_s = {false, "Unable to garbage collect", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTGETSIZE_msg_s = {false, "Unable to compute size", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTLOCK_msg_s = {false, "Unable to lock object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTUNLOCK_msg_s = {false, "Unable to unlock object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_NOSPACE_msg_s = {false, "No space available for allocation", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_OBJOPEN_msg_s = {false, "Object is already open", H5E_MINOR, &H5E_err_cls_s}; - -/* SYSTEM: System level errors */ -static const H5E_msg_t H5E_SYSERRSTR_msg_s = {false, "System error message", H5E_MINOR, &H5E_err_cls_s}; - -/* TYPECONV: Datatype conversion errors */ -static const H5E_msg_t H5E_BADSIZE_msg_s = {false, "Bad size for object", H5E_MINOR, &H5E_err_cls_s}; -static const H5E_msg_t H5E_CANTCONVERT_msg_s = {false, "Can't convert datatypes", H5E_MINOR, &H5E_err_cls_s}; -/* clang-format on */ - -#endif /* H5Emindef_H */ From ebd805191e04d536779c7063e75ee5ab722e7871 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 7 May 2024 17:03:53 -0500 Subject: [PATCH 4/8] Add new generated error headers to .gitignore Signed-off-by: Quincey Koziol --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d2fc4c79651..757ae0fd3ca 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,9 @@ m4/ltversion.m4 m4/lt~obsolete.m4 src/H5Edefin.h src/H5Einit.h +src/H5E.h +src/H5Emajdef.h +src/H5Emindef.h src/H5Epubgen.h src/H5Eterm.h src/H5config.h.in From 2d380a336cdea8adce3ac216ba8f860ff625815d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 7 May 2024 17:04:49 -0500 Subject: [PATCH 5/8] Update H5E__copy_stack_entry() to reflect its actual requirements Signed-off-by: Quincey Koziol --- src/H5Eint.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/H5Eint.c b/src/H5Eint.c index 47cabe8c7c4..3c7dcf0360e 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -1492,14 +1492,7 @@ H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *src_entry) { herr_t ret_value = SUCCEED; /* Return value */ - /* - * WARNING: We cannot call HERROR() from within this function or else we - * could enter infinite recursion. Furthermore, we also cannot - * call any other HDF5 macro or function which might call - * HERROR(). HERROR() is called by HRETURN_ERROR() which could - * be called by FUNC_ENTER(). - */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_PACKAGE /* Sanity check */ assert(dst_entry); @@ -1513,23 +1506,23 @@ H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *src_entry) /* Note: don't waste time incrementing library internal error IDs */ if (dst_entry->err.cls_id != H5E_ERR_CLS_g) if (H5I_inc_ref(dst_entry->err.cls_id, false) < 0) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class"); if (dst_entry->err.maj_num < H5E_first_maj_id_g || dst_entry->err.maj_num > H5E_last_maj_id_g) if (H5I_inc_ref(dst_entry->err.maj_num, false) < 0) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error message"); if (dst_entry->err.min_num < H5E_first_min_id_g || dst_entry->err.min_num > H5E_last_min_id_g) if (H5I_inc_ref(dst_entry->err.min_num, false) < 0) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error message"); /* The library's 'func' & 'file' strings are statically allocated (by the compiler) * there's no need to duplicate them. */ if (NULL == (dst_entry->err.file_name = strdup(src_entry->err.file_name))) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate file name"); if (NULL == (dst_entry->err.func_name = strdup(src_entry->err.func_name))) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate function name"); } if (NULL == (dst_entry->err.desc = strdup(src_entry->err.desc))) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate error description"); done: FUNC_LEAVE_NOAPI(ret_value) From a0bd0264db1c49b88f50999d7723603e48b28bb4 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 22:28:31 +0000 Subject: [PATCH 6/8] Committing clang-format changes --- src/H5Eint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5Eint.c b/src/H5Eint.c index 3c7dcf0360e..00b6efbe33d 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -1517,12 +1517,12 @@ H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *src_entry) * there's no need to duplicate them. */ if (NULL == (dst_entry->err.file_name = strdup(src_entry->err.file_name))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate file name"); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate file name"); if (NULL == (dst_entry->err.func_name = strdup(src_entry->err.func_name))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate function name"); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate function name"); } if (NULL == (dst_entry->err.desc = strdup(src_entry->err.desc))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate error description"); + HGOTO_ERROR(H5E_ERROR, H5E_CANTCOPY, FAIL, "unable to duplicate error description"); done: FUNC_LEAVE_NOAPI(ret_value) From 1521c9039d430de73ff96c752bad7c48620c1e2e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 8 May 2024 12:18:13 -0500 Subject: [PATCH 7/8] Correct typo Signed-off-by: Quincey Koziol --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 757ae0fd3ca..d6b8b714dcb 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ m4/ltversion.m4 m4/lt~obsolete.m4 src/H5Edefin.h src/H5Einit.h -src/H5E.h src/H5Emajdef.h src/H5Emindef.h src/H5Epubgen.h From 752523a872330de12fe92ad36b9525fd93824db9 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 8 May 2024 12:18:51 -0500 Subject: [PATCH 8/8] Remove unused variable Signed-off-by: Quincey Koziol --- bin/make_err | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bin/make_err b/bin/make_err index c83ed4d2450..58722a4fd82 100755 --- a/bin/make_err +++ b/bin/make_err @@ -304,7 +304,6 @@ sub create_init ($) { my $sect_desc; # Description of section my $first_major = 0; # Whether the first major error code was saved my $first_minor = 0; # Whether the first minor error code was saved - my $num_msg; # Number of messages # Rename previous file # rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; @@ -319,7 +318,6 @@ sub create_init ($) { print_startprotect(*HEADER, $file); # Iterate over all the major errors - $num_msg = 0; print HEADER "\n/*********************/\n"; print HEADER "/* Major error codes */\n"; print HEADER "/*********************/\n\n"; @@ -333,16 +331,14 @@ sub create_init ($) { print HEADER " "x(0*$indent),"assert(H5E_first_maj_id_g==H5I_INVALID_HID);\n"; print HEADER " "x(0*$indent),"H5E_first_maj_id_g = ${name}_g;\n\n"; $first_major = 1; - } + } $last_name = $name; - $num_msg++; } print HEADER " "x(0*$indent),"\n/* Remember last major error code ID */\n"; print HEADER " "x(0*$indent),"assert(H5E_last_maj_id_g==H5I_INVALID_HID);\n"; print HEADER " "x(0*$indent),"H5E_last_maj_id_g = ${last_name}_g;\n\n"; # Iterate over all the minor error sections - $num_msg = 0; print HEADER "\n/*********************/\n"; print HEADER "/* Minor error codes */\n"; print HEADER "/*********************/\n\n"; @@ -363,7 +359,6 @@ sub create_init ($) { $first_minor = 1; } $last_name = $name; - $num_msg++; } } print HEADER " "x(0*$indent),"\n/* Remember last minor error code ID */\n";