Coverage Report

Created: 2026-09-04 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5Osdspace.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
#include "H5Omodule.h" /* This source code file is part of the H5O module */
14
#define H5S_FRIEND     /*prevent warning from including H5Spkg.h */
15
16
#include "H5private.h"   /* Generic Functions     */
17
#include "H5Dprivate.h"  /* Datasets        */
18
#include "H5Eprivate.h"  /* Error handling        */
19
#include "H5FLprivate.h" /* Free lists                           */
20
#include "H5Opkg.h"      /* Object headers        */
21
#include "H5Spkg.h"      /* Dataspaces        */
22
23
/* PRIVATE PROTOTYPES */
24
static void  *H5O__sdspace_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags,
25
                                  size_t p_size, const uint8_t *p);
26
static herr_t H5O__sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg);
27
static void  *H5O__sdspace_copy(const void *_mesg, void *_dest);
28
static size_t H5O__sdspace_size(const H5F_t *f, const void *_mesg);
29
static herr_t H5O__sdspace_reset(void *_mesg);
30
static herr_t H5O__sdspace_free(void *_mesg);
31
static herr_t H5O__sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src, bool *deleted,
32
                                         const H5O_copy_t *cpy_info, void *_udata);
33
static herr_t H5O__sdspace_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth);
34
35
/* Set up & include shared message "interface" info */
36
0
#define H5O_SHARED_TYPE        H5O_MSG_SDSPACE
37
#define H5O_SHARED_DECODE      H5O__sdspace_shared_decode
38
0
#define H5O_SHARED_DECODE_REAL H5O__sdspace_decode
39
#define H5O_SHARED_ENCODE      H5O__sdspace_shared_encode
40
0
#define H5O_SHARED_ENCODE_REAL H5O__sdspace_encode
41
#define H5O_SHARED_SIZE        H5O__sdspace_shared_size
42
0
#define H5O_SHARED_SIZE_REAL   H5O__sdspace_size
43
#define H5O_SHARED_DELETE      H5O__sdspace_shared_delete
44
#undef H5O_SHARED_DELETE_REAL
45
#define H5O_SHARED_LINK H5O__sdspace_shared_link
46
#undef H5O_SHARED_LINK_REAL
47
#define H5O_SHARED_COPY_FILE H5O__sdspace_shared_copy_file
48
#undef H5O_SHARED_COPY_FILE_REAL
49
#define H5O_SHARED_POST_COPY_FILE H5O__sdspace_shared_post_copy_file
50
#undef H5O_SHARED_POST_COPY_FILE_REAL
51
#undef H5O_SHARED_POST_COPY_FILE_UPD
52
#define H5O_SHARED_DEBUG      H5O__sdspace_shared_debug
53
0
#define H5O_SHARED_DEBUG_REAL H5O__sdspace_debug
54
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
55
56
/* This message derives from H5O message class */
57
const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
58
    H5O_SDSPACE_ID,                            /* message id number         */
59
    "dataspace",                               /* message name for debugging      */
60
    sizeof(H5S_extent_t),                      /* native message size         */
61
    H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */
62
    H5O__sdspace_shared_decode,                /* decode message      */
63
    H5O__sdspace_shared_encode,                /* encode message      */
64
    H5O__sdspace_copy,                         /* copy the native value   */
65
    H5O__sdspace_shared_size,                  /* size of symbol table entry        */
66
    H5O__sdspace_reset,                        /* default reset method          */
67
    H5O__sdspace_free,                         /* free method       */
68
    H5O__sdspace_shared_delete,                /* file delete method            */
69
    H5O__sdspace_shared_link,                  /* link method             */
70
    NULL,                                      /* set share method            */
71
    NULL,                                      /*can share method           */
72
    H5O__sdspace_pre_copy_file,                /* pre copy native value to file        */
73
    H5O__sdspace_shared_copy_file,             /* copy native value to file          */
74
    H5O__sdspace_shared_post_copy_file,        /* post copy native value to file*/
75
    NULL,                                      /* get creation index            */
76
    NULL,                                      /* set creation index            */
77
    H5O__sdspace_shared_debug                  /* debug the message         */
78
}};
79
80
/* Declare external the free list for H5S_extent_t's */
81
H5FL_EXTERN(H5S_extent_t);
82
83
/* Declare external the free list for hsize_t arrays */
84
H5FL_ARR_EXTERN(hsize_t);
85
86
/*--------------------------------------------------------------------------
87
 NAME
88
    H5O__sdspace_decode
89
 PURPOSE
90
    Decode a simple dimensionality message and return a pointer to a memory
91
        struct with the decoded information
92
 USAGE
93
    void *H5O__sdspace_decode(f, mesg_flags, p)
94
        H5F_t *f;         IN: pointer to the HDF5 file struct
95
        unsigned mesg_flags;    IN: Message flags to influence decoding
96
        const uint8 *p;   IN: the raw information buffer
97
 RETURNS
98
    Pointer to the new message in native order on success, NULL on failure
99
 DESCRIPTION
100
        This function decodes the "raw" disk form of a simple dimensionality
101
    message into a struct in memory native format.  The struct is allocated
102
    within this function using malloc() and is returned to the caller.
103
--------------------------------------------------------------------------*/
104
static void *
105
H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
106
                    unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p)
107
0
{
108
0
    const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */
109
0
    H5S_extent_t  *sdim  = NULL;           /* New extent dimensionality structure */
110
0
    unsigned       flags, version;
111
0
    unsigned       i;
112
0
    void          *ret_value = NULL; /* Return value */
113
114
0
    FUNC_ENTER_PACKAGE
115
116
0
    assert(f);
117
0
    assert(p);
118
119
0
    if (NULL == (sdim = H5FL_CALLOC(H5S_extent_t)))
120
0
        HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "dataspace structure allocation failed");
121
0
    sdim->type = H5S_NO_CLASS;
122
123
    /* Check version */
124
0
    if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end))
125
0
        HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
126
0
    version = *p++;
127
128
0
    if (version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2)
129
0
        HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "wrong version number in dataspace message");
130
0
    sdim->version = version;
131
132
    /* Get rank */
133
0
    if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end))
134
0
        HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
135
0
    sdim->rank = *p++;
136
137
0
    if (sdim->rank > H5S_MAX_RANK)
138
0
        HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "simple dataspace dimensionality is too large");
139
140
    /* Get dataspace flags for later */
141
0
    if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end))
142
0
        HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
143
0
    flags = *p++;
144
145
    /* Get or determine the type of the extent */
146
0
    if (version >= H5O_SDSPACE_VERSION_2) {
147
0
        if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end))
148
0
            HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
149
0
        sdim->type = (H5S_class_t)*p++;
150
151
0
        if (sdim->type != H5S_SIMPLE && sdim->rank > 0)
152
0
            HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid rank for scalar or NULL dataspace");
153
0
    }
154
0
    else {
155
        /* Set the dataspace type to be simple or scalar as appropriate
156
         * (version 1 does not allow H5S_NULL)
157
         */
158
0
        if (sdim->rank > 0)
159
0
            sdim->type = H5S_SIMPLE;
160
0
        else
161
0
            sdim->type = H5S_SCALAR;
162
163
        /* Increment past reserved byte */
164
0
        if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end))
165
0
            HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
166
0
        p++;
167
0
    }
168
169
    /* Version 1 has 4 reserved bytes */
170
0
    if (version == H5O_SDSPACE_VERSION_1) {
171
0
        if (H5_IS_BUFFER_OVERFLOW(p, 4, p_end))
172
0
            HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
173
0
        p += 4;
174
0
    }
175
176
    /* Decode dimension sizes */
177
0
    if (sdim->rank > 0) {
178
        /* Check that we have space to decode sdim->rank values */
179
0
        if (H5_IS_BUFFER_OVERFLOW(p, (H5F_sizeof_size(f) * sdim->rank), p_end))
180
0
            HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
181
182
        /* Sizes */
183
0
        if (NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
184
0
            HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed");
185
0
        for (i = 0; i < sdim->rank; i++)
186
0
            H5F_DECODE_LENGTH(f, p, sdim->size[i]);
187
188
0
        if (flags & H5S_VALID_MAX) {
189
            /* Check that we have space to decode sdim->rank values */
190
0
            if (H5_IS_BUFFER_OVERFLOW(p, (H5F_sizeof_size(f) * sdim->rank), p_end))
191
0
                HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");
192
193
            /* Max sizes */
194
0
            if (NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank)))
195
0
                HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed");
196
0
            for (i = 0; i < sdim->rank; i++) {
197
0
                H5F_DECODE_LENGTH(f, p, sdim->max[i]);
198
0
                if (sdim->size[i] > sdim->max[i])
199
0
                    HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL,
200
0
                                "dataspace dim %u size of %llu is greater than maxdim size of %llu", i,
201
0
                                (unsigned long long)sdim->size[i], (unsigned long long)sdim->max[i]);
202
0
            }
203
0
        }
204
205
        /* NOTE: The version 1 permutation indexes were never implemented so
206
         *       there is nothing to decode.
207
         */
208
0
    }
209
210
    /* Compute the number of elements in the extent */
211
0
    if (sdim->type == H5S_NULL)
212
0
        sdim->nelem = 0;
213
0
    else {
214
0
        for (i = 0, sdim->nelem = 1; i < sdim->rank; i++)
215
0
            sdim->nelem *= sdim->size[i];
216
0
    }
217
218
    /* Set return value */
219
0
    ret_value = (void *)sdim;
220
221
0
done:
222
0
    if (!ret_value && sdim) {
223
0
        H5S__extent_release(sdim);
224
0
        H5FL_FREE(H5S_extent_t, sdim);
225
0
    }
226
227
0
    FUNC_LEAVE_NOAPI(ret_value)
228
0
} /* end H5O__sdspace_decode() */
229
230
/*--------------------------------------------------------------------------
231
 NAME
232
    H5O__sdspace_encode
233
 PURPOSE
234
    Encode a simple dimensionality message
235
 USAGE
236
    herr_t H5O__sdspace_encode(f, raw_size, p, mesg)
237
        H5F_t *f;         IN: pointer to the HDF5 file struct
238
        size_t raw_size;  IN: size of the raw information buffer
239
        const uint8 *p;   IN: the raw information buffer
240
        const void *mesg; IN: Pointer to the extent dimensionality struct
241
 RETURNS
242
    Non-negative on success/Negative on failure
243
 DESCRIPTION
244
        This function encodes the native memory form of the simple
245
    dimensionality message in the "raw" disk form.
246
247
--------------------------------------------------------------------------*/
248
static herr_t
249
H5O__sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg)
250
0
{
251
0
    const H5S_extent_t *sdim  = (const H5S_extent_t *)_mesg;
252
0
    unsigned            flags = 0;
253
0
    unsigned            u; /* Local counting variable */
254
255
0
    FUNC_ENTER_PACKAGE_NOERR
256
257
    /* check args */
258
0
    assert(f);
259
0
    assert(p);
260
0
    assert(sdim);
261
262
    /* Version */
263
0
    assert(sdim->version > 0);
264
0
    assert(sdim->type != H5S_NULL || sdim->version >= H5O_SDSPACE_VERSION_2);
265
0
    *p++ = (uint8_t)sdim->version;
266
267
    /* Rank */
268
0
    *p++ = (uint8_t)sdim->rank;
269
270
    /* Flags */
271
0
    if (sdim->max)
272
0
        flags |= H5S_VALID_MAX;
273
0
    *p++ = (uint8_t)flags;
274
275
    /* Dataspace type */
276
0
    if (sdim->version > H5O_SDSPACE_VERSION_1)
277
0
        *p++ = (uint8_t)sdim->type;
278
0
    else {
279
0
        *p++ = 0; /*reserved*/
280
0
        *p++ = 0; /*reserved*/
281
0
        *p++ = 0; /*reserved*/
282
0
        *p++ = 0; /*reserved*/
283
0
        *p++ = 0; /*reserved*/
284
0
    }             /* end else */
285
286
    /* Encode dataspace dimensions for simple dataspaces */
287
0
    if (H5S_SIMPLE == sdim->type) {
288
        /* Encode current & maximum dimensions */
289
0
        if (sdim->rank > 0) {
290
0
            for (u = 0; u < sdim->rank; u++)
291
0
                H5F_ENCODE_LENGTH(f, p, sdim->size[u]);
292
0
            if (flags & H5S_VALID_MAX)
293
0
                for (u = 0; u < sdim->rank; u++)
294
0
                    H5F_ENCODE_LENGTH(f, p, sdim->max[u]);
295
0
        } /* end if */
296
0
    }     /* end if */
297
298
0
    FUNC_LEAVE_NOAPI(SUCCEED)
299
0
} /* end H5O__sdspace_encode() */
300
301
/*--------------------------------------------------------------------------
302
 NAME
303
    H5O__sdspace_copy
304
 PURPOSE
305
    Copies a message from MESG to DEST, allocating DEST if necessary.
306
 USAGE
307
    void *H5O__sdspace_copy(_mesg, _dest)
308
        const void *_mesg;  IN: Pointer to the source extent dimensionality struct
309
        const void *_dest;  IN: Pointer to the destination extent dimensionality struct
310
 RETURNS
311
    Pointer to DEST on success, NULL on failure
312
 DESCRIPTION
313
        This function copies a native (memory) simple dimensionality message,
314
    allocating the destination structure if necessary.
315
--------------------------------------------------------------------------*/
316
static void *
317
H5O__sdspace_copy(const void *_mesg, void *_dest)
318
0
{
319
0
    const H5S_extent_t *mesg      = (const H5S_extent_t *)_mesg;
320
0
    H5S_extent_t       *dest      = (H5S_extent_t *)_dest;
321
0
    void               *ret_value = NULL; /* Return value */
322
323
0
    FUNC_ENTER_PACKAGE
324
325
    /* check args */
326
0
    assert(mesg);
327
0
    if (!dest && NULL == (dest = H5FL_CALLOC(H5S_extent_t)))
328
0
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
329
330
    /* Copy extent information */
331
0
    if (H5S__extent_copy_real(dest, mesg, true) < 0)
332
0
        HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent");
333
334
    /* Set return value */
335
0
    ret_value = dest;
336
337
0
done:
338
0
    if (NULL == ret_value)
339
0
        if (dest && NULL == _dest)
340
0
            dest = H5FL_FREE(H5S_extent_t, dest);
341
342
0
    FUNC_LEAVE_NOAPI(ret_value)
343
0
} /* end H5O__sdspace_copy() */
344
345
/*--------------------------------------------------------------------------
346
 NAME
347
    H5O__sdspace_size
348
 PURPOSE
349
    Return the raw message size in bytes
350
 USAGE
351
    void *H5O__sdspace_size(f, mesg)
352
        H5F_t *f;   IN: pointer to the HDF5 file struct
353
        const void *mesg; IN: Pointer to the source extent dimensionality struct
354
 RETURNS
355
    Size of message on success, zero on failure
356
 DESCRIPTION
357
        This function returns the size of the raw simple dimensionality message on
358
    success.  (Not counting the message type or size fields, only the data
359
    portion of the message).  It doesn't take into account alignment.
360
361
--------------------------------------------------------------------------*/
362
static size_t
363
H5O__sdspace_size(const H5F_t *f, const void *_mesg)
364
0
{
365
0
    const H5S_extent_t *space     = (const H5S_extent_t *)_mesg;
366
0
    size_t              ret_value = 0; /* Return value */
367
368
0
    FUNC_ENTER_PACKAGE_NOERR
369
370
    /* Basic information for all dataspace messages */
371
0
    ret_value = (size_t)(1 +                                                  /* Version */
372
0
                         1 +                                                  /* Rank */
373
0
                         1 +                                                  /* Flags */
374
0
                         1 +                                                  /* Dataspace type/reserved */
375
0
                         ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4)); /* Eliminated/reserved */
376
377
    /* Add in the dimension sizes */
378
0
    ret_value += space->rank * H5F_SIZEOF_SIZE(f);
379
380
    /* Add in the space for the maximum dimensions, if they are present */
381
0
    ret_value += space->max ? (space->rank * H5F_SIZEOF_SIZE(f)) : 0;
382
383
0
    FUNC_LEAVE_NOAPI(ret_value)
384
0
} /* end H5O__sdspace_size() */
385
386
/*-------------------------------------------------------------------------
387
 * Function:  H5O__sdspace_reset
388
 *
389
 * Purpose: Frees the inside of a dataspace message and resets it to some
390
 *    initial value.
391
 *
392
 * Return:  Non-negative on success/Negative on failure
393
 *
394
 *-------------------------------------------------------------------------
395
 */
396
static herr_t
397
H5O__sdspace_reset(void *_mesg)
398
0
{
399
0
    H5S_extent_t *mesg = (H5S_extent_t *)_mesg;
400
401
0
    FUNC_ENTER_PACKAGE_NOERR
402
403
0
    H5S__extent_release(mesg);
404
405
0
    FUNC_LEAVE_NOAPI(SUCCEED)
406
0
} /* end H5O__sdspace_reset() */
407
408
/*-------------------------------------------------------------------------
409
 * Function:  H5O__sdsdpace_free
410
 *
411
 * Purpose: Frees the message
412
 *
413
 * Return:  Non-negative on success/Negative on failure
414
 *
415
 *-------------------------------------------------------------------------
416
 */
417
static herr_t
418
H5O__sdspace_free(void *mesg)
419
0
{
420
0
    FUNC_ENTER_PACKAGE_NOERR
421
422
0
    assert(mesg);
423
424
0
    mesg = H5FL_FREE(H5S_extent_t, mesg);
425
426
0
    FUNC_LEAVE_NOAPI(SUCCEED)
427
0
} /* end H5O__sdspace_free() */
428
429
/*-------------------------------------------------------------------------
430
 * Function:    H5O__sdspace_pre_copy_file
431
 *
432
 * Purpose:     Perform any necessary actions before copying message between
433
 *              files
434
 *
435
 * Return:      Success:        Non-negative
436
 *
437
 *              Failure:        Negative
438
 *
439
 *-------------------------------------------------------------------------
440
 */
441
static herr_t
442
H5O__sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, bool H5_ATTR_UNUSED *deleted,
443
                           const H5O_copy_t *cpy_info, void *_udata)
444
0
{
445
0
    const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */
446
0
    H5D_copy_file_ud_t *udata            = (H5D_copy_file_ud_t *)_udata;   /* Dataset copying user data */
447
0
    herr_t              ret_value        = SUCCEED;                        /* Return value */
448
449
0
    FUNC_ENTER_PACKAGE
450
451
    /* check args */
452
0
    assert(file_src);
453
0
    assert(src_space_extent);
454
0
    assert(cpy_info);
455
0
    assert(cpy_info->file_dst);
456
457
    /* Check to ensure that the version of the message to be copied does not exceed
458
       the message version allowed by the destination file's high bound */
459
0
    if (src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
460
0
        HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "dataspace message version out of bounds");
461
462
    /* If the user data is non-NULL, assume we are copying a dataset
463
     * and make a copy of the dataspace extent for later in the object copying
464
     * process.  (We currently only need to make a copy of the dataspace extent
465
     * if the layout is an early version, but that information isn't
466
     * available here, so we just make a copy of it in all cases)
467
     */
468
0
    if (udata) {
469
        /* Allocate copy of dataspace extent */
470
0
        if (NULL == (udata->src_space_extent = H5FL_CALLOC(H5S_extent_t)))
471
0
            HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed");
472
473
        /* Create a copy of the dataspace extent */
474
0
        if (H5S__extent_copy_real(udata->src_space_extent, src_space_extent, true) < 0)
475
0
            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent");
476
0
    } /* end if */
477
478
0
done:
479
0
    FUNC_LEAVE_NOAPI(ret_value)
480
0
} /* end H5O_dspace_pre_copy_file() */
481
482
/*--------------------------------------------------------------------------
483
 NAME
484
    H5O__sdspace_debug
485
 PURPOSE
486
    Prints debugging information for a simple dimensionality message
487
 USAGE
488
    void *H5O__sdspace_debug(f, mesg, stream, indent, fwidth)
489
        H5F_t *f;         IN: pointer to the HDF5 file struct
490
        const void *mesg; IN: Pointer to the source extent dimensionality struct
491
        FILE *stream;   IN: Pointer to the stream for output data
492
        int indent;   IN: Amount to indent information by
493
        int fwidth;   IN: Field width (?)
494
 RETURNS
495
    Non-negative on success/Negative on failure
496
 DESCRIPTION
497
        This function prints debugging output to the stream passed as a
498
    parameter.
499
--------------------------------------------------------------------------*/
500
static herr_t
501
H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth)
502
0
{
503
0
    const H5S_extent_t *sdim = (const H5S_extent_t *)mesg;
504
505
0
    FUNC_ENTER_PACKAGE_NOERR
506
507
    /* check args */
508
0
    assert(f);
509
0
    assert(sdim);
510
0
    assert(stream);
511
0
    assert(indent >= 0);
512
0
    assert(fwidth >= 0);
513
514
0
    fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Rank:", (unsigned long)(sdim->rank));
515
516
0
    if (sdim->rank > 0) {
517
0
        unsigned u; /* local counting variable */
518
519
0
        fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
520
0
        for (u = 0; u < sdim->rank; u++)
521
0
            fprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", sdim->size[u]);
522
0
        fprintf(stream, "}\n");
523
524
0
        fprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
525
0
        if (sdim->max) {
526
0
            fprintf(stream, "{");
527
0
            for (u = 0; u < sdim->rank; u++) {
528
0
                if (H5S_UNLIMITED == sdim->max[u])
529
0
                    fprintf(stream, "%sUNLIM", u ? ", " : "");
530
0
                else
531
0
                    fprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", sdim->max[u]);
532
0
            } /* end for */
533
0
            fprintf(stream, "}\n");
534
0
        } /* end if */
535
0
        else
536
0
            fprintf(stream, "CONSTANT\n");
537
0
    } /* end if */
538
539
0
    FUNC_LEAVE_NOAPI(SUCCEED)
540
0
} /* end H5O__sdspace_debug() */