mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
cd71eb525c
error occurs after an "exit:" label. Corrected a dozen Coverity errors (mainly allocation issues, along with a few other things): 711711, 711802, 711803, 711905, 970825, 996123, 996124, 1025787, 1047274, 1130013, 1130014, 1139538 Refactored internal fill-value code to correctly handle string types, and especially to allow NULL pointers and null strings (ie. "") to be distinguished. The code now avoids partially aliasing the two together (which only happened on the 'write' side of things and wasn't reflected on the 'read' side, adding to the previous confusion). Probably still weak on handling fill-values of variable-length and compound datatypes. Refactored the recursive metadata reads a bit more, to process HDF5 named datatypes and datasets immediately, avoiding chewing up memory for those types of objects, etc. Finished uncommenting and updating the nc_test4/tst_fills2.c code (as I'm proceeding alphabetically through the nc_test4 code files).
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
/* Copyright 2010, University Corporation for Atmospheric Research. See
|
|
COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
This file is part of netcdf-4, a netCDF-like interface for HDF5, or
|
|
a HDF5 backend for netCDF, depending on your point of view.
|
|
|
|
This file contains macros and prototyes relating to logging.
|
|
|
|
$Id: nc_logging.h,v 1.1 2010/06/01 15:34:49 ed Exp $
|
|
*/
|
|
|
|
#ifndef _NCLOGGING_
|
|
#define _NCLOGGING_
|
|
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
|
|
#ifdef LOGGING
|
|
|
|
/* To log something... */
|
|
void nc_log(int severity, const char *fmt, ...);
|
|
void nc_log_hdf5(void);
|
|
|
|
#define LOG(e) nc_log e
|
|
|
|
/* To log based on error code, and set retval. */
|
|
#define BAIL2(e) \
|
|
do { \
|
|
retval = e; \
|
|
LOG((0, "file %s, line %d.\n%s", __FILE__, __LINE__, nc_strerror(e))); \
|
|
nc_log_hdf5(); \
|
|
} while (0)
|
|
|
|
/* To set retval and jump to exit, without logging error message. */
|
|
#define BAIL_QUIET(e) \
|
|
do { \
|
|
retval = e; \
|
|
goto exit; \
|
|
} while (0)
|
|
|
|
#else /* LOGGING */
|
|
|
|
/* These definitions will be used unless LOGGING is defined. */
|
|
|
|
#define LOG(e)
|
|
|
|
#define BAIL2(e) \
|
|
do { \
|
|
retval = e; \
|
|
} while (0)
|
|
|
|
#define BAIL_QUIET BAIL
|
|
|
|
#define nc_set_log_level(e)
|
|
|
|
#endif /* LOGGING */
|
|
|
|
/* To log an error message (if 'LOGGING' is defined), set retval, and jump to exit. */
|
|
#define BAIL(e) \
|
|
do { \
|
|
BAIL2(e); \
|
|
goto exit; \
|
|
} while (0)
|
|
|
|
#endif /* _NCLOGGING_ */
|
|
|