Coverage Report

Created: 2026-11-22 11:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5Tvisit.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*
14
 * Module Info: This module contains most of the "core" functionality of
15
 *      the H5T interface, including the API initialization code, etc.
16
 *      Many routines that are infrequently used, or are specialized for
17
 *      one particular datatype class are in another module.
18
 */
19
20
/*-------------------------------------------------------------------------
21
 *
22
 * Created:   H5Tvisit.c
23
 *
24
 * Purpose:   Visit all the components of a datatype
25
 *
26
 *-------------------------------------------------------------------------
27
 */
28
29
/****************/
30
/* Module Setup */
31
/****************/
32
33
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
34
35
/***********/
36
/* Headers */
37
/***********/
38
#include "H5private.h"  /* Generic Functions      */
39
#include "H5Eprivate.h" /* Error handling       */
40
#include "H5Tpkg.h"     /* Datatypes              */
41
42
/****************/
43
/* Local Macros */
44
/****************/
45
46
/******************/
47
/* Local Typedefs */
48
/******************/
49
50
/********************/
51
/* Package Typedefs */
52
/********************/
53
54
/********************/
55
/* Local Prototypes */
56
/********************/
57
58
/*********************/
59
/* Package Variables */
60
/*********************/
61
62
/*****************************/
63
/* Library Private Variables */
64
/*****************************/
65
66
/*******************/
67
/* Local Variables */
68
/*******************/
69
70
/*-------------------------------------------------------------------------
71
 * Function:    H5T__visit
72
 *
73
 * Purpose:     Visit a datatype and all it's members and/or parents, making
74
 *              a callback for each.
75
 *
76
 * Return:  Non-negative on success/Negative on failure
77
 *
78
 *-------------------------------------------------------------------------
79
 */
80
herr_t
81
H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value)
82
0
{
83
0
    bool   is_composite;        /* Flag indicating current datatype is composite */
84
0
    herr_t ret_value = SUCCEED; /* Return value */
85
86
0
    FUNC_ENTER_PACKAGE
87
88
    /* Sanity check */
89
0
    assert(dt);
90
0
    assert(op);
91
92
    /* Check for composite datatype */
93
0
    is_composite = H5T_IS_COMPOSITE(dt->shared->type);
94
95
    /* If the callback is to be made on the datatype first, do that */
96
0
    if (is_composite && (visit_flags & H5T_VISIT_COMPOSITE_FIRST))
97
0
        if (op(dt, op_value) < 0)
98
0
            HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed");
99
100
    /* Make callback for each member/child, if requested */
101
0
    switch (dt->shared->type) {
102
0
        case H5T_COMPOUND: {
103
0
            unsigned u; /* Local index variable */
104
105
            /* Visit each member of the compound datatype */
106
0
            for (u = 0; u < dt->shared->u.compnd.nmembs; u++)
107
0
                if (H5T__visit(dt->shared->u.compnd.memb[u].type, visit_flags, op, op_value) < 0)
108
0
                    HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit member datatype");
109
0
        } /* end case */
110
0
        break;
111
112
0
        case H5T_ARRAY:
113
0
        case H5T_VLEN:
114
0
        case H5T_ENUM:
115
0
        case H5T_COMPLEX:
116
            /* Visit parent type */
117
0
            if (H5T__visit(dt->shared->parent, visit_flags, op, op_value) < 0)
118
0
                HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit parent datatype");
119
0
            break;
120
121
0
        case H5T_NO_CLASS:
122
0
        case H5T_NCLASSES:
123
            /* Not real values */
124
0
            HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class");
125
0
            break;
126
127
0
        case H5T_INTEGER:
128
0
        case H5T_FLOAT:
129
0
        case H5T_TIME:
130
0
        case H5T_STRING:
131
0
        case H5T_BITFIELD:
132
0
        case H5T_OPAQUE:
133
0
        case H5T_REFERENCE:
134
0
        default:
135
            /* Visit "simple" datatypes here */
136
0
            if (visit_flags & H5T_VISIT_SIMPLE)
137
0
                if (op(dt, op_value) < 0)
138
0
                    HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed");
139
0
            break;
140
0
    } /* end switch */
141
142
    /* If the callback is to be made on the datatype last, do that */
143
0
    if (is_composite && (visit_flags & H5T_VISIT_COMPOSITE_LAST))
144
0
        if (op(dt, op_value) < 0)
145
0
            HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed");
146
147
0
done:
148
0
    FUNC_LEAVE_NOAPI(ret_value)
149
0
} /* end H5T__visit() */