free_NC_attr:
   29|   173k|{
   30|       |
   31|   173k|	if(attrp == NULL)
  ------------------
  |  Branch (31:5): [True: 0, False: 173k]
  ------------------
   32|      0|		return;
   33|   173k|	free_NC_string(attrp->name);
   34|   173k|	free(attrp);
   35|   173k|}
new_x_NC_attr:
   79|   173k|{
   80|   173k|	NC_attr *attrp;
   81|   173k|	const size_t xsz = ncx_len_NC_attrV(type, nelems);
   82|   173k|	size_t sz = M_RNDUP(sizeof(NC_attr));
  ------------------
  |  |   19|   173k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   173k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   173k|	* (unit))
  |  |  ------------------
  ------------------
   83|       |
   84|   173k|	assert(!(xsz == 0 && nelems != 0));
  ------------------
  |  Branch (84:2): [True: 0, False: 173k]
  |  Branch (84:2): [True: 0, False: 0]
  |  Branch (84:2): [True: 171k, False: 2.20k]
  |  Branch (84:2): [True: 0, False: 171k]
  ------------------
   85|       |
   86|   173k|	if(sz > SIZE_MAX -xsz)
  ------------------
  |  Branch (86:5): [True: 3, False: 173k]
  ------------------
   87|      3|		return NULL;
   88|       |
   89|   173k|	sz += xsz;
   90|       |
   91|   173k|	attrp = (NC_attr *) malloc(sz);
   92|   173k|	if(attrp == NULL )
  ------------------
  |  Branch (92:5): [True: 3, False: 173k]
  ------------------
   93|      3|		return NULL;
   94|       |
   95|   173k|	attrp->xsz = xsz;
   96|       |
   97|   173k|	attrp->name = strp;
   98|   173k|	attrp->type = type;
   99|   173k|	attrp->nelems = nelems;
  100|   173k|	if(xsz != 0)
  ------------------
  |  Branch (100:5): [True: 2.19k, False: 171k]
  ------------------
  101|  2.19k|		attrp->xvalue = (char *)attrp + M_RNDUP(sizeof(NC_attr));
  ------------------
  |  |   19|  2.19k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|  2.19k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|  2.19k|	* (unit))
  |  |  ------------------
  ------------------
  102|   171k|	else
  103|   171k|		attrp->xvalue = NULL;
  104|       |
  105|   173k|	return(attrp);
  106|   173k|}
free_NC_attrarrayV0:
  165|    214|{
  166|    214|	assert(ncap != NULL);
  ------------------
  |  Branch (166:2): [True: 0, False: 214]
  |  Branch (166:2): [True: 214, False: 0]
  ------------------
  167|       |
  168|    214|	if(ncap->nelems == 0)
  ------------------
  |  Branch (168:5): [True: 16, False: 198]
  ------------------
  169|     16|		return;
  170|       |
  171|    214|	assert(ncap->value != NULL);
  ------------------
  |  Branch (171:2): [True: 0, False: 198]
  |  Branch (171:2): [True: 198, False: 0]
  ------------------
  172|       |
  173|    198|	{
  174|    198|		NC_attr **app = ncap->value;
  175|    198|		NC_attr *const *const end = &app[ncap->nelems];
  176|   174k|		for( /*NADA*/; app < end; app++)
  ------------------
  |  Branch (176:18): [True: 173k, False: 198]
  ------------------
  177|   173k|		{
  178|   173k|			free_NC_attr(*app);
  179|       |			*app = NULL;
  180|   173k|		}
  181|    198|	}
  182|    198|	ncap->nelems = 0;
  183|    198|}
free_NC_attrarrayV:
  193|   153k|{
  194|   153k|	assert(ncap != NULL);
  ------------------
  |  Branch (194:2): [True: 0, False: 153k]
  |  Branch (194:2): [True: 153k, False: 0]
  ------------------
  195|       |
  196|   153k|	if(ncap->nalloc == 0)
  ------------------
  |  Branch (196:5): [True: 152k, False: 214]
  ------------------
  197|   152k|		return;
  198|       |
  199|   153k|	assert(ncap->value != NULL);
  ------------------
  |  Branch (199:2): [True: 0, False: 214]
  |  Branch (199:2): [True: 214, False: 0]
  ------------------
  200|       |
  201|    214|	free_NC_attrarrayV0(ncap);
  202|       |
  203|    214|	free(ncap->value);
  204|       |	ncap->value = NULL;
  205|    214|	ncap->nalloc = 0;
  206|    214|}
attr.c:ncx_len_NC_attrV:
   44|   173k|{
   45|   173k|	switch(type) {
   46|    791|	case NC_BYTE:
  ------------------
  |  |   35|    791|#define NC_BYTE         1       /**< signed 1 byte integer */
  ------------------
  |  Branch (46:2): [True: 791, False: 173k]
  ------------------
   47|  1.52k|	case NC_CHAR:
  ------------------
  |  |   36|  1.52k|#define NC_CHAR         2       /**< ISO/ASCII character */
  ------------------
  |  Branch (47:2): [True: 736, False: 173k]
  ------------------
   48|  1.52k|		return ncx_len_char(nelems);
  ------------------
  |  |  136|  1.52k|	_RNDUP((nelems), X_ALIGN)
  |  |  ------------------
  |  |  |  |   14|  1.52k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|  1.52k|	* (unit))
  |  |  ------------------
  ------------------
   49|     80|	case NC_SHORT:
  ------------------
  |  |   37|     80|#define NC_SHORT        3       /**< signed 2 byte integer */
  ------------------
  |  Branch (49:2): [True: 80, False: 173k]
  ------------------
   50|     80|		return ncx_len_short(nelems);
  ------------------
  |  |  139|     80|	(((nelems) + (nelems)%2)  * X_SIZEOF_SHORT)
  |  |  ------------------
  |  |  |  |   64|     80|#define X_SIZEOF_SHORT		2
  |  |  ------------------
  ------------------
   51|    166|	case NC_INT:
  ------------------
  |  |   38|    166|#define NC_INT          4       /**< signed 4 byte integer */
  ------------------
  |  Branch (51:2): [True: 166, False: 173k]
  ------------------
   52|    166|		return ncx_len_int(nelems);
  ------------------
  |  |  142|    166|	((nelems) * X_SIZEOF_INT)
  |  |  ------------------
  |  |  |  |   65|    166|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
   53|  5.38k|	case NC_FLOAT:
  ------------------
  |  |   40|  5.38k|#define NC_FLOAT        5       /**< single precision floating point number */
  ------------------
  |  Branch (53:2): [True: 5.38k, False: 168k]
  ------------------
   54|  5.38k|		return ncx_len_float(nelems);
  ------------------
  |  |  148|  5.38k|	((nelems) * X_SIZEOF_FLOAT)
  |  |  ------------------
  |  |  |  |   69|  5.38k|#define X_SIZEOF_FLOAT		4
  |  |  ------------------
  ------------------
   55|      7|	case NC_DOUBLE:
  ------------------
  |  |   41|      7|#define NC_DOUBLE       6       /**< double precision floating point number */
  ------------------
  |  Branch (55:2): [True: 7, False: 173k]
  ------------------
   56|      7|		return ncx_len_double(nelems);
  ------------------
  |  |  151|      7|	((nelems) * X_SIZEOF_DOUBLE)
  |  |  ------------------
  |  |  |  |   70|      7|#define X_SIZEOF_DOUBLE		8
  |  |  ------------------
  ------------------
   57|  18.6k|	case NC_UBYTE:
  ------------------
  |  |   42|  18.6k|#define NC_UBYTE        7       /**< unsigned 1 byte int */
  ------------------
  |  Branch (57:2): [True: 18.6k, False: 155k]
  ------------------
   58|  18.6k|		return ncx_len_ubyte(nelems);
  ------------------
  |  |  154|  18.6k|	_RNDUP((nelems), X_ALIGN)
  |  |  ------------------
  |  |  |  |   14|  18.6k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|  18.6k|	* (unit))
  |  |  ------------------
  ------------------
   59|   147k|	case NC_USHORT:
  ------------------
  |  |   43|   147k|#define NC_USHORT       8       /**< unsigned 2-byte int */
  ------------------
  |  Branch (59:2): [True: 147k, False: 26.8k]
  ------------------
   60|   147k|		return ncx_len_ushort(nelems);
  ------------------
  |  |  157|   147k|	(((nelems) + (nelems)%2)  * X_SIZEOF_USHORT)
  |  |  ------------------
  |  |  |  |   74|   147k|#define X_SIZEOF_USHORT		2
  |  |  ------------------
  ------------------
   61|    646|	case NC_UINT:
  ------------------
  |  |   44|    646|#define NC_UINT         9       /**< unsigned 4-byte int */
  ------------------
  |  Branch (61:2): [True: 646, False: 173k]
  ------------------
   62|    646|		return ncx_len_uint(nelems);
  ------------------
  |  |  160|    646|	((nelems) * X_SIZEOF_UINT)
  |  |  ------------------
  |  |  |  |   75|    646|#define X_SIZEOF_UINT		4
  |  |  ------------------
  ------------------
   63|      7|	case NC_INT64:
  ------------------
  |  |   45|      7|#define NC_INT64        10      /**< signed 8-byte int */
  ------------------
  |  Branch (63:2): [True: 7, False: 173k]
  ------------------
   64|      7|		return ncx_len_int64(nelems);
  ------------------
  |  |  163|      7|	((nelems) * X_SIZEOF_INT64)
  |  |  ------------------
  |  |  |  |   78|      7|#define X_SIZEOF_INT64		8
  |  |  ------------------
  ------------------
   65|    383|	case NC_UINT64:
  ------------------
  |  |   46|    383|#define NC_UINT64       11      /**< unsigned 8-byte int */
  ------------------
  |  Branch (65:2): [True: 383, False: 173k]
  ------------------
   66|    383|		return ncx_len_uint64(nelems);
  ------------------
  |  |  166|    383|	((nelems) * X_SIZEOF_UINT64)
  |  |  ------------------
  |  |  |  |   79|    383|#define X_SIZEOF_UINT64		8
  |  |  ------------------
  ------------------
   67|      0|	default:
  ------------------
  |  Branch (67:2): [True: 0, False: 173k]
  ------------------
   68|      0|	        assert("ncx_len_NC_attr bad type" == 0);
  ------------------
  |  Branch (68:10): [Folded, False: 0]
  |  Branch (68:10): [Folded, False: 0]
  ------------------
   69|   173k|	}
   70|      0|	return 0;
   71|   173k|}

ncx_get_size_t:
 5279|  1.58M|{
 5280|       |	/* similar to get_ix_int */
 5281|  1.58M|	const uchar *cp = (const uchar *) *xpp;
 5282|       |
 5283|  1.58M|	*ulp  = (unsigned)(*cp++) << 24;
 5284|  1.58M|	*ulp |= (*cp++ << 16);
 5285|  1.58M|	*ulp |= (*cp++ << 8);
 5286|  1.58M|	*ulp |= *cp;
 5287|       |
 5288|  1.58M|	*xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
  ------------------
  |  |   89|  1.58M|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|  1.58M|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
 5289|  1.58M|	return NC_NOERR;
  ------------------
  |  |  417|  1.58M|#define NC_NOERR        0          /**< No Error */
  ------------------
 5290|  1.58M|}
ncx_get_off_t:
 5342|   152k|{
 5343|       |	/* similar to get_ix_int() */
 5344|   152k|	const uchar *cp = (const uchar *) *xpp;
 5345|   152k|	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
  ------------------
  |  Branch (5345:2): [True: 152k, False: 0]
  |  Branch (5345:2): [True: 0, False: 0]
  |  Branch (5345:2): [True: 373, False: 152k]
  |  Branch (5345:2): [True: 152k, False: 0]
  ------------------
 5346|       |
 5347|   152k| 	if (sizeof_off_t == 4) {
  ------------------
  |  Branch (5347:7): [True: 373, False: 152k]
  ------------------
 5348|    373|		*lp =  (off_t)(*cp++ << 24);
 5349|    373|		*lp |= (off_t)(*cp++ << 16);
 5350|    373|		*lp |= (off_t)(*cp++ <<  8);
 5351|    373|		*lp |= (off_t)*cp;
 5352|   152k|	} else {
 5353|       |#if SIZEOF_OFF_T == 4
 5354|       |/* Read a 64-bit offset on a system with only a 32-bit offset */
 5355|       |/* If the offset overflows, set an error code and return */
 5356|       |		*lp =  ((off_t)(*cp++) << 24);
 5357|       |		*lp |= ((off_t)(*cp++) << 16);
 5358|       |		*lp |= ((off_t)(*cp++) <<  8);
 5359|       |		*lp |= ((off_t)(*cp++));
 5360|       |/*
 5361|       | * lp now contains the upper 32-bits of the 64-bit offset.  if lp is
 5362|       | * not zero, then the dataset is larger than can be represented
 5363|       | * on this system.  Set an error code and return.
 5364|       | */
 5365|       |		if (*lp != 0) {
 5366|       |		  return NC_ERANGE;
 5367|       |		}
 5368|       |
 5369|       |		*lp  = ((off_t)(*cp++) << 24);
 5370|       |		*lp |= ((off_t)(*cp++) << 16);
 5371|       |		*lp |= ((off_t)(*cp++) <<  8);
 5372|       |		*lp |=  (off_t)*cp;
 5373|       |
 5374|       |		if (*lp < 0) {
 5375|       |		  /*
 5376|       |		   * If this fails, then the offset is >2^31, but less
 5377|       |		   * than 2^32 which is not allowed, but is not caught
 5378|       |		   * by the previous check
 5379|       |		   */
 5380|       |		  return NC_ERANGE;
 5381|       |		}
 5382|       |#else
 5383|   152k|		*lp =  ((off_t)(*cp++) << 56);
 5384|   152k|		*lp |= ((off_t)(*cp++) << 48);
 5385|   152k|		*lp |= ((off_t)(*cp++) << 40);
 5386|   152k|		*lp |= ((off_t)(*cp++) << 32);
 5387|   152k|		*lp |= ((off_t)(*cp++) << 24);
 5388|   152k|		*lp |= ((off_t)(*cp++) << 16);
 5389|   152k|		*lp |= ((off_t)(*cp++) <<  8);
 5390|   152k|		*lp |=  (off_t)*cp;
 5391|   152k|#endif
 5392|   152k|	}
 5393|   152k|	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
 5394|   152k|	return NC_NOERR;
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
 5395|   152k|}
ncx_get_uint32:
 5400|   479k|{
 5401|       |#ifdef WORDS_BIGENDIAN
 5402|       |    /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
 5403|       |     * some system, such as HPUX */
 5404|       |    (void) memcpy(ip, *xpp, SIZEOF_UINT);
 5405|       |#else
 5406|   479k|    const uchar *cp = (const uchar *) *xpp;
 5407|       |
 5408|   479k|    *ip = (uint)(*cp++ << 24);
 5409|   479k|    *ip = (uint)(*ip | (uint)(*cp++ << 16));
 5410|   479k|    *ip = (uint)(*ip | (uint)(*cp++ <<  8));
 5411|   479k|    *ip = (uint)(*ip | *cp);
 5412|   479k|#endif
 5413|       |    /* advance *xpp 4 bytes */
 5414|   479k|    *xpp = (void *)((const char *)(*xpp) + 4);
 5415|       |
 5416|   479k|    return NC_NOERR;
  ------------------
  |  |  417|   479k|#define NC_NOERR        0          /**< No Error */
  ------------------
 5417|   479k|}
ncx_get_uint64:
 5422|   235k|{
 5423|       |#ifdef WORDS_BIGENDIAN
 5424|       |    /* use memcpy instead of assignment to avoid BUS_ADRALN alignment error on
 5425|       |     * some system, such as HPUX */
 5426|       |    (void) memcpy(ullp, *xpp, SIZEOF_UINT64);
 5427|       |#else
 5428|   235k|    const uchar *cp = (const uchar *) *xpp;
 5429|       |
 5430|       |    /* below is the same as calling swap8b(ullp, *xpp) */
 5431|   235k|    *ullp = (unsigned long long)(*cp++) << 56;
 5432|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 48);
 5433|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 40);
 5434|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 32);
 5435|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 24);
 5436|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) << 16);
 5437|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp++) <<  8);
 5438|   235k|    *ullp = (unsigned long long)(*ullp | (unsigned long long)(*cp));
 5439|   235k|#endif
 5440|       |    /* advance *xpp 8 bytes */
 5441|   235k|    *xpp = (void *)((const char *)(*xpp) + 8);
 5442|       |
 5443|   235k|    return NC_NOERR;
  ------------------
  |  |  417|   235k|#define NC_NOERR        0          /**< No Error */
  ------------------
 5444|   235k|}
ncx_getn_schar_schar:
 5511|    257|{
 5512|    257|		(void) memcpy(tp, *xpp, (size_t)nelems);
 5513|    257|	*xpp = (void *)((char *)(*xpp) + nelems);
 5514|    257|	return NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
 5515|       |
 5516|    257|}
ncx_getn_int_int:
11653|   147k|{
11654|       |#ifdef WORDS_BIGENDIAN
11655|       |	(void) memcpy(tp, *xpp, (size_t)nelems * SIZEOF_INT);
11656|       |# else
11657|   147k|	swapn4b(tp, *xpp, nelems);
11658|   147k|# endif
11659|   147k|	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
  ------------------
  |  |   65|   147k|#define X_SIZEOF_INT		4	/* xdr_int */
  ------------------
11660|   147k|	return NC_NOERR;
  ------------------
  |  |  417|   147k|#define NC_NOERR        0          /**< No Error */
  ------------------
11661|   147k|}
ncx_getn_longlong_int:
17975|  5.39k|{
17976|       |#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
17977|       |
17978|       | /* basic algorithm is:
17979|       |  *   - ensure sane alignment of input data
17980|       |  *   - copy (conversion happens automatically) input data
17981|       |  *     to output
17982|       |  *   - update xpp to point at next unconverted input, and tp to point
17983|       |  *     at next location for converted output
17984|       |  */
17985|       |  long i, j, ni;
17986|       |  int64 tmp[LOOPCNT];        /* in case input is misaligned */
17987|       |  int64 *xp;
17988|       |  int nrange = 0;         /* number of range errors */
17989|       |  int realign = 0;        /* "do we need to fix input data alignment?" */
17990|       |  long cxp = (long) *((char**)xpp);
17991|       |
17992|       |  realign = (cxp & 7) % SIZEOF_INT64;
17993|       |  /* sjl: manually stripmine so we can limit amount of
17994|       |   * vector work space reserved to LOOPCNT elements. Also
17995|       |   * makes vectorisation easy */
17996|       |  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
17997|       |    ni=Min(nelems-j,LOOPCNT);
17998|       |    if (realign) {
17999|       |      memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
18000|       |      xp = tmp;
18001|       |    } else {
18002|       |      xp = (int64 *) *xpp;
18003|       |    }
18004|       |   /* copy the next block */
18005|       |#pragma cdir loopcnt=LOOPCNT
18006|       |#pragma cdir shortloop
18007|       |    for (i=0; i<ni; i++) {
18008|       |      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
18009|       |     /* test for range errors (not always needed but do it anyway) */
18010|       |     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
18011|       |     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
18012|       |      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
18013|       |    }
18014|       |   /* update xpp and tp */
18015|       |    if (realign) xp = (int64 *) *xpp;
18016|       |    xp += ni;
18017|       |    tp += ni;
18018|       |    *xpp = (void*)xp;
18019|       |  }
18020|       |  return nrange == 0 ? NC_NOERR : NC_ERANGE;
18021|       |
18022|       |#else   /* not SX */
18023|  5.39k|	const char *xp = (const char *) *xpp;
18024|  5.39k|	int status = NC_NOERR;
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
18025|       |
18026|  5.61k|	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
  ------------------
  |  |   78|    217|#define X_SIZEOF_INT64		8
  ------------------
  |  Branch (18026:9): [True: 217, False: 5.39k]
  ------------------
18027|    217|	{
18028|    217|		const int lstatus = ncx_get_longlong_int(xp, tp);
18029|    217|		if (status == NC_NOERR) /* report the first encountered error */
  ------------------
  |  |  417|    217|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (18029:7): [True: 217, False: 0]
  ------------------
18030|    217|			status = lstatus;
18031|    217|	}
18032|       |
18033|  5.39k|	*xpp = (const void *)xp;
18034|  5.39k|	return status;
18035|  5.39k|#endif
18036|  5.39k|}
ncx_pad_getn_text:
20817|   759k|{
20818|   759k|	size_t rndup = nelems % X_ALIGN;
  ------------------
  |  |  133|   759k|#define X_ALIGN			4	/* a.k.a. BYTES_PER_XDR_UNIT */
  ------------------
20819|       |
20820|   759k|	if (rndup)
  ------------------
  |  Branch (20820:6): [True: 9.35k, False: 749k]
  ------------------
20821|  9.35k|		rndup = X_ALIGN - rndup;
  ------------------
  |  |  133|  9.35k|#define X_ALIGN			4	/* a.k.a. BYTES_PER_XDR_UNIT */
  ------------------
20822|       |
20823|   759k|	(void) memcpy(tp, *xpp, (size_t)nelems);
20824|   759k|	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
20825|       |
20826|   759k|	return NC_NOERR;
  ------------------
  |  |  417|   759k|#define NC_NOERR        0          /**< No Error */
  ------------------
20827|       |
20828|   759k|}
ncx.c:swapn4b:
  256|   147k|{
  257|   147k|    size_t i;
  258|   147k|    char *op = (char*) dst;
  259|   147k|    char *ip = (char*) src;
  260|   147k|    uint32_t tmp;
  261|   237k|    for (i=0; i<nn; i++) {
  ------------------
  |  Branch (261:15): [True: 89.7k, False: 147k]
  ------------------
  262|       |        /* memcpy is used to handle the case of unaligned memory */
  263|  89.7k|        memcpy(&tmp, ip, sizeof(tmp));
  264|  89.7k|        tmp = SWAP4(tmp);
  ------------------
  |  |  206|  89.7k|#define SWAP4(a) ( ((a) << 24) | \
  |  |  207|  89.7k|                  (((a) <<  8) & 0x00ff0000) | \
  |  |  208|  89.7k|                  (((a) >>  8) & 0x0000ff00) | \
  |  |  209|  89.7k|                  (((a) >> 24) & 0x000000ff) )
  ------------------
  265|  89.7k|        memcpy(op, &tmp, sizeof(tmp));
  266|  89.7k|        ip += sizeof(uint32_t);
  267|  89.7k|        op += sizeof(uint32_t);
  268|  89.7k|    }
  269|   147k|}
ncx.c:get_ix_int64:
 4051|    217|{
 4052|    217|    const uchar *cp = (const uchar *) xp;
 4053|       |
 4054|    217|    *ip  = (ix_int64)((uint64_t)(*cp++) << 56);
 4055|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) << 48);
 4056|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) << 40);
 4057|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) << 32);
 4058|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) << 24);
 4059|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) << 16);
 4060|    217|    *ip |= (ix_int64)((uint64_t)(*cp++) <<  8);
 4061|    217|    *ip |= (ix_int64)*cp;
 4062|    217|}
ncx.c:ncx_get_longlong_int:
 4160|    217|{
 4161|    217|    int err=NC_NOERR;
  ------------------
  |  |  417|    217|#define NC_NOERR        0          /**< No Error */
  ------------------
 4162|       |#if SIZEOF_IX_INT64 == SIZEOF_INT && IX_INT64_MAX == INT_MAX
 4163|       |    get_ix_int64(xp, (ix_int64 *)ip);
 4164|       |#else
 4165|    217|    ix_int64 xx = 0;
 4166|    217|    get_ix_int64(xp, &xx);
 4167|       |
 4168|    217|#if IX_INT64_MAX > INT_MAX
 4169|    217|    if (xx > INT_MAX || xx < INT_MIN) {
  ------------------
  |  Branch (4169:9): [True: 0, False: 217]
  |  Branch (4169:25): [True: 0, False: 217]
  ------------------
 4170|      0|#ifdef ERANGE_FILL
 4171|      0|        *ip = NC_FILL_INT;
  ------------------
  |  |   70|      0|#define NC_FILL_INT     (-2147483647)
  ------------------
 4172|      0|        return NC_ERANGE;
  ------------------
  |  |  496|      0|#define NC_ERANGE       (-60)
  ------------------
 4173|       |#else
 4174|       |        err = NC_ERANGE;
 4175|       |#endif
 4176|      0|    }
 4177|    217|#endif
 4178|       |
 4179|       |
 4180|    217|    *ip = (int) xx;
 4181|    217|#endif
 4182|    217|    return err;
 4183|    217|}

LLVMFuzzerTestOneInput:
   10|    287|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   11|    287|    int ncid;
   12|    287|    if (nc_open_mem("/tmp/fuzz.nc", 0, Size, (void *) Data, &ncid) == NC_NOERR) {
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (12:9): [True: 16, False: 271]
  ------------------
   13|     16|        nc_close(ncid);
   14|     16|    }
   15|    287|    return 0;
   16|    287|}

ncaux_plugin_path_parsen:
  982|      1|{
  983|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  984|      1|    size_t i;
  985|      1|    char* path = NULL;
  986|      1|    char* p;
  987|      1|    size_t count;
  988|      1|    char seps[2] = "\0\0"; /* will contain all allowable separators */
  989|       |
  990|      1|    if(dirs == NULL) {stat = NC_EINVAL; goto done;}
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (990:8): [True: 0, False: 1]
  ------------------
  991|       |
  992|      1|    if(pathlen == 0 || pathlist0 == NULL) {dirs->ndirs = 0; goto done;}
  ------------------
  |  Branch (992:8): [True: 0, False: 1]
  |  Branch (992:24): [True: 0, False: 1]
  ------------------
  993|       |
  994|       |    /* If a separator is specified, use it, otherwise search for ';' or ':' */
  995|      1|    seps[0] = sep;
  996|      1|    if(sep == 0) {
  ------------------
  |  Branch (996:8): [True: 1, False: 0]
  ------------------
  997|      1|	if(NCgetlocalpathkind() == NCPD_WIN
  ------------------
  |  |  242|      2|#define NCPD_WIN 4
  ------------------
  |  Branch (997:5): [True: 0, False: 1]
  ------------------
  998|      1|	    || NCgetlocalpathkind() == NCPD_MSYS)
  ------------------
  |  |  240|      1|#define NCPD_MSYS 2
  ------------------
  |  Branch (998:9): [True: 0, False: 1]
  ------------------
  999|      0|	   seps[0] = ';';
 1000|      1|	else
 1001|      1|	    seps[0] = ':';
 1002|      1|    }
 1003|      1|    if((path = malloc(pathlen+1+1))==NULL) {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (1003:8): [True: 0, False: 1]
  ------------------
 1004|      1|    memcpy(path,pathlist0,pathlen);
 1005|      1|    path[pathlen] = '\0'; path[pathlen+1] = '\0';  /* double null term */
 1006|       |
 1007|     54|    for(count=0,p=path;*p;p++) {
  ------------------
  |  Branch (1007:24): [True: 53, False: 1]
  ------------------
 1008|     53|	if(strchr(seps,*p) == NULL)
  ------------------
  |  Branch (1008:5): [True: 52, False: 1]
  ------------------
 1009|     52|	    continue; /* non-separator */
 1010|      1|	else {
 1011|      1|	    *p = '\0';
 1012|      1| 	    count++;
 1013|      1|	}
 1014|     53|    }
 1015|      1|    count++; /* count last piece */
 1016|       |
 1017|       |    /* Save and allocate */
 1018|      1|    dirs->ndirs = count;
 1019|      1|    if(dirs->dirs == NULL) {
  ------------------
  |  Branch (1019:8): [True: 1, False: 0]
  ------------------
 1020|      1|	if((dirs->dirs = (char**)calloc(count,sizeof(char*)))==NULL)
  ------------------
  |  Branch (1020:5): [True: 0, False: 1]
  ------------------
 1021|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
 1022|      1|    }
 1023|       |
 1024|       |    /* capture the parsed pieces */
 1025|      3|    for(p=path,i=0;i<count;i++) {
  ------------------
  |  Branch (1025:20): [True: 2, False: 1]
  ------------------
 1026|      2|	size_t len = strlen(p);
 1027|      2|	dirs->dirs[i] = strdup(p);
 1028|      2|        p = p+len+1; /* point to next piece */
 1029|      2|    }
 1030|       |
 1031|      1|done:
 1032|       |    nullfree(path);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 1033|      1|    return stat;
 1034|      1|}
ncaux_plugin_path_parse:
 1046|      1|{
 1047|       |    return ncaux_plugin_path_parsen(nulllen(pathlist0),pathlist0,sep,dirs);
  ------------------
  |  |  151|      1|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1048|      1|}
ncaux_plugin_path_clear:
 1098|      1|{
 1099|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
 1100|      1|    size_t i;
 1101|      1|    if(dirs == NULL || dirs->ndirs == 0 || dirs->dirs == NULL) goto done;
  ------------------
  |  Branch (1101:8): [True: 0, False: 1]
  |  Branch (1101:24): [True: 0, False: 1]
  |  Branch (1101:44): [True: 0, False: 1]
  ------------------
 1102|      3|    for(i=0;i<dirs->ndirs;i++) {
  ------------------
  |  Branch (1102:13): [True: 2, False: 1]
  ------------------
 1103|      2|	if(dirs->dirs[i] != NULL) free(dirs->dirs[i]);
  ------------------
  |  Branch (1103:5): [True: 2, False: 0]
  ------------------
 1104|      2|	dirs->dirs[i] = NULL;
 1105|      2|    }
 1106|      1|    free(dirs->dirs);
 1107|      1|    dirs->dirs = NULL;
 1108|      1|    dirs->ndirs = 0;
 1109|      1|done:
 1110|      1|    return stat;
 1111|      1|}

NC_crc64:
  221|    624|{
  222|       |    /* Is this machine big vs little endian? */
  223|    624|    if(littleendian < 0) {
  ------------------
  |  Branch (223:8): [True: 1, False: 623]
  ------------------
  224|      1|	unsigned char* p = (void*)&littleendian;
  225|      1|	littleendian = 1;
  226|      1|	if(*p == 0) littleendian = 0; /* big endian */
  ------------------
  |  Branch (226:5): [True: 0, False: 1]
  ------------------
  227|      1|    }
  228|       |
  229|    624|    return littleendian ? crc64_little(crc, buf, (size_t)len) :
  ------------------
  |  Branch (229:12): [True: 624, False: 0]
  ------------------
  230|    624|                          crc64_big(crc, buf, (size_t)len);
  231|    624|}
dcrc64.c:crc64_little:
  150|    624|{
  151|    624|    unsigned char *next = buf;
  152|       |
  153|    624|    ONCE(crc64_little_init);
  ------------------
  |  |  134|    624|    do { \
  |  |  135|    624|        static volatile int once = 1; \
  |  |  136|    624|        if (once) { \
  |  |  ------------------
  |  |  |  Branch (136:13): [True: 1, False: 623]
  |  |  ------------------
  |  |  137|      1|            if (once++ == 1) { \
  |  |  ------------------
  |  |  |  Branch (137:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  138|      1|                init(); \
  |  |  139|      1|                once = 0; \
  |  |  140|      1|            } \
  |  |  141|      1|            else \
  |  |  142|      1|                while (once) \
  |  |  ------------------
  |  |  |  Branch (142:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  143|      0|                    ; \
  |  |  144|      1|        } \
  |  |  145|    624|    } while (0)
  |  |  ------------------
  |  |  |  Branch (145:14): [Folded, False: 624]
  |  |  ------------------
  ------------------
  154|    624|    crc = ~crc;
  155|    624|    while (len && ((uintptr_t)next & 7) != 0) {
  ------------------
  |  Branch (155:12): [True: 624, False: 0]
  |  Branch (155:19): [True: 0, False: 624]
  ------------------
  156|      0|        crc = crc64_little_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
  157|      0|        len--;
  158|      0|    }
  159|  27.3k|    while (len >= 8) {
  ------------------
  |  Branch (159:12): [True: 26.7k, False: 624]
  ------------------
  160|  26.7k|        crc ^= *(uint64 *)next;
  161|  26.7k|        crc = crc64_little_table[7][crc & 0xff] ^
  162|  26.7k|              crc64_little_table[6][(crc >> 8) & 0xff] ^
  163|  26.7k|              crc64_little_table[5][(crc >> 16) & 0xff] ^
  164|  26.7k|              crc64_little_table[4][(crc >> 24) & 0xff] ^
  165|  26.7k|              crc64_little_table[3][(crc >> 32) & 0xff] ^
  166|  26.7k|              crc64_little_table[2][(crc >> 40) & 0xff] ^
  167|  26.7k|              crc64_little_table[1][(crc >> 48) & 0xff] ^
  168|  26.7k|              crc64_little_table[0][crc >> 56];
  169|  26.7k|        next += 8;
  170|  26.7k|        len -= 8;
  171|  26.7k|    }
  172|  1.10k|    while (len) {
  ------------------
  |  Branch (172:12): [True: 484, False: 624]
  ------------------
  173|    484|        crc = crc64_little_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
  174|    484|        len--;
  175|    484|    }
  176|    624|    return ~crc;
  177|    624|}
dcrc64.c:crc64_little_init:
   95|      1|{
   96|      1|    crc64_init(crc64_little_table);
   97|      1|}
dcrc64.c:crc64_init:
   70|      1|{
   71|      1|    unsigned n, k;
   72|      1|    uint64 crc;
   73|       |
   74|       |    /* generate CRC-64's for all single byte sequences */
   75|    257|    for (n = 0; n < 256; n++) {
  ------------------
  |  Branch (75:17): [True: 256, False: 1]
  ------------------
   76|    256|        crc = n;
   77|  2.30k|        for (k = 0; k < 8; k++)
  ------------------
  |  Branch (77:21): [True: 2.04k, False: 256]
  ------------------
   78|  2.04k|            crc = crc & 1 ? POLY ^ (crc >> 1) : crc >> 1;
  ------------------
  |  |   58|  1.02k|#define POLY UINT64_C(0xc96c5795d7870f42)
  ------------------
  |  Branch (78:19): [True: 1.02k, False: 1.02k]
  ------------------
   79|    256|        table[0][n] = crc;
   80|    256|    }
   81|       |
   82|       |    /* generate CRC-64's for those followed by 1 to 7 zeros */
   83|    257|    for (n = 0; n < 256; n++) {
  ------------------
  |  Branch (83:17): [True: 256, False: 1]
  ------------------
   84|    256|        crc = table[0][n];
   85|  2.04k|        for (k = 1; k < 8; k++) {
  ------------------
  |  Branch (85:21): [True: 1.79k, False: 256]
  ------------------
   86|  1.79k|            crc = table[0][crc & 0xff] ^ (crc >> 8);
   87|  1.79k|            table[k][n] = crc;
   88|  1.79k|        }
   89|    256|    }
   90|      1|}

NCDISPATCH_initialize:
   51|      1|{
   52|      1|    int status = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   53|      1|    int i;
   54|      1|    NCglobalstate* globalstate = NULL;
   55|       |
   56|  1.02k|    for(i=0;i<NC_MAX_VAR_DIMS;i++) {
  ------------------
  |  |  331|  1.02k|#define NC_MAX_VAR_DIMS 1024 /**< max per variable dimensions */
  ------------------
  |  Branch (56:13): [True: 1.02k, False: 1]
  ------------------
   57|  1.02k|        NC_coord_zero[i] = 0;
   58|  1.02k|        NC_coord_one[i]  = 1;
   59|  1.02k|        NC_stride_one[i] = 1;
   60|  1.02k|    }
   61|       |
   62|      1|    globalstate = NC_getglobalstate(); /* will allocate and clear */
   63|       |
   64|       |    /* Capture temp dir*/
   65|      1|    {
   66|      1|	char* tempdir = NULL;
   67|       |#if defined _WIN32 || defined __MSYS__ || defined __CYGWIN__
   68|       |        tempdir = getenv("TEMP");
   69|       |#else
   70|      1|	tempdir = "/tmp";
   71|      1|#endif
   72|      1|        if(tempdir == NULL) {
  ------------------
  |  Branch (72:12): [True: 0, False: 1]
  ------------------
   73|      0|	    fprintf(stderr,"Cannot find a temp dir; using ./\n");
   74|      0|	    tempdir = ".";
   75|      0|	}
   76|      1|	globalstate->tempdir= strdup(tempdir);
   77|      1|    }
   78|       |
   79|       |    /* Capture $HOME */
   80|      1|    {
   81|       |#if defined(_WIN32) && !defined(__MINGW32__)
   82|       |        char* home = getenv("USERPROFILE");
   83|       |#else
   84|      1|        char* home = getenv("HOME");
   85|      1|#endif
   86|      1|        if(home == NULL) {
  ------------------
  |  Branch (86:12): [True: 0, False: 1]
  ------------------
   87|       |	    /* use cwd */
   88|      0|	    home = malloc(MAXPATH+1);
  ------------------
  |  |   35|      0|#define MAXPATH 1024
  ------------------
   89|      0|	    NCgetcwd(home,MAXPATH);
  ------------------
  |  |  216|      0|#define NCgetcwd(buf,len) getcwd(buf,len)
  ------------------
   90|      0|        } else
   91|      1|	    home = strdup(home); /* make it always free'able */
   92|      1|	assert(home != NULL);
  ------------------
  |  Branch (92:2): [True: 0, False: 1]
  |  Branch (92:2): [True: 1, False: 0]
  ------------------
   93|      1|        NCpathcanonical(home,&globalstate->home);
   94|      1|	nullfree(home);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
   95|      1|    }
   96|       | 
   97|       |    /* Capture $CWD */
   98|      1|    {
   99|      1|        char cwdbuf[4096];
  100|       |
  101|      1|        cwdbuf[0] = '\0';
  102|      1|	(void)NCgetcwd(cwdbuf,sizeof(cwdbuf));
  ------------------
  |  |  216|      1|#define NCgetcwd(buf,len) getcwd(buf,len)
  ------------------
  103|       |
  104|      1|        if(strlen(cwdbuf) == 0) {
  ------------------
  |  Branch (104:12): [True: 0, False: 1]
  ------------------
  105|       |	    /* use tempdir */
  106|      0|	    strcpy(cwdbuf, globalstate->tempdir);
  107|      0|	}
  108|      1|        globalstate->cwd = strdup(cwdbuf);
  109|      1|    }
  110|       |
  111|      1|    ncloginit();
  112|       |
  113|       |    /* Now load RC Files */
  114|      1|    ncrc_initialize();
  115|       |
  116|       |    /* Compute type alignments */
  117|      1|    NC_compute_alignments();
  118|       |
  119|       |#if defined(NETCDF_ENABLE_BYTERANGE) || defined(NETCDF_ENABLE_DAP) || defined(NETCDF_ENABLE_DAP4)
  120|       |    /* Initialize curl if it is being used */
  121|       |    {
  122|       |        CURLcode cstat = curl_global_init(CURL_GLOBAL_ALL);
  123|       |	if(cstat != CURLE_OK)
  124|       |	    status = NC_ECURL;
  125|       |    }
  126|       |#endif
  127|       |
  128|      1|    return status;
  129|      1|}
NCDISPATCH_finalize:
  133|      1|{
  134|      1|    int status = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  135|       |#if defined(NETCDF_ENABLE_BYTERANGE) || defined(NETCDF_ENABLE_DAP) || defined(NETCDF_ENABLE_DAP4)
  136|       |    curl_global_cleanup();
  137|       |#endif
  138|       |#if defined(NETCDF_ENABLE_DAP4)
  139|       |   ncxml_finalize();
  140|       |#endif
  141|      1|    NC_freeglobalstate(); /* should be one of the last things done */
  142|      1|    return status;
  143|      1|}

nc_open_mem:
  811|    287|{
  812|    287|    NC_memio meminfo;
  813|       |
  814|       |    /* Sanity checks */
  815|    287|    if(memory == NULL || size < MAGIC_NUMBER_LEN || path == NULL)
  ------------------
  |  |   38|    574|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
  |  Branch (815:8): [True: 0, False: 287]
  |  Branch (815:26): [True: 0, False: 287]
  |  Branch (815:53): [True: 0, False: 287]
  ------------------
  816|      0|        return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  817|    287|    if(omode & (NC_WRITE|NC_MMAP))
  ------------------
  |  |  136|    287|#define NC_WRITE         0x0001 /**< Set read-write access for nc_open(). */
  ------------------
                  if(omode & (NC_WRITE|NC_MMAP))
  ------------------
  |  |  141|    287|#define NC_MMAP          0x0010  /**< \deprecated Use diskless file with mmap. Mode flag for nc_open() or nc_create()*/
  ------------------
  |  Branch (817:8): [True: 0, False: 287]
  ------------------
  818|      0|        return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  819|    287|    omode |= (NC_INMEMORY); /* Note: NC_INMEMORY and NC_DISKLESS are mutually exclusive*/
  ------------------
  |  |  189|    287|#define NC_INMEMORY      0x8000  /**< Read from memory. Mode flag for nc_open() or nc_create() */
  ------------------
  820|    287|    meminfo.size = size;
  821|    287|    meminfo.memory = memory;
  822|    287|    meminfo.flags = NC_MEMIO_LOCKED;
  ------------------
  |  |   26|    287|#define NC_MEMIO_LOCKED 1    /* Do not try to realloc or free provided memory */
  ------------------
  823|       |    return NC_open(path, omode, 0, NULL, 0, &meminfo, ncidp);
  824|    287|}
nc_close:
 1335|     16|{
 1336|     16|    NC* ncp;
 1337|     16|    int stat = NC_check_id(ncid, &ncp);
 1338|     16|    if(stat != NC_NOERR) return stat;
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1338:8): [True: 0, False: 16]
  ------------------
 1339|       |
 1340|     16|    stat = ncp->dispatch->close(ncid,NULL);
 1341|       |    /* Remove from the nc list */
 1342|     16|    if (!stat)
  ------------------
  |  Branch (1342:9): [True: 16, False: 0]
  ------------------
 1343|     16|    {
 1344|     16|        del_from_NCList(ncp);
 1345|     16|        free_NC(ncp);
 1346|     16|    }
 1347|     16|    return stat;
 1348|     16|}
NC_open:
 2029|    287|{
 2030|    287|    int stat = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
 2031|    287|    NC* ncp = NULL;
 2032|    287|    const NC_Dispatch* dispatcher = NULL;
 2033|    287|    int inmemory = 0;
 2034|    287|    int diskless = 0;
 2035|    287|    int use_mmap = 0;
 2036|    287|    char* path = NULL;
 2037|    287|    NCmodel model;
 2038|    287|    char* newpath = NULL;
 2039|       |
 2040|    287|    TRACE(nc_open);
 2041|    287|    if(!NC_initialized) {
  ------------------
  |  Branch (2041:8): [True: 1, False: 286]
  ------------------
 2042|      1|        stat = nc_initialize();
 2043|      1|        if(stat) goto done;
  ------------------
  |  Branch (2043:12): [True: 0, False: 1]
  ------------------
 2044|      1|    }
 2045|       |
 2046|       |    /* Check inputs. */
 2047|    287|    if (!path0)
  ------------------
  |  Branch (2047:9): [True: 0, False: 287]
  ------------------
 2048|      0|        {stat = NC_EINVAL; goto done;}
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 2049|       |
 2050|       |    /* Capture the inmemory related flags */
 2051|    287|    use_mmap = ((omode & NC_MMAP) == NC_MMAP);
  ------------------
  |  |  141|    287|#define NC_MMAP          0x0010  /**< \deprecated Use diskless file with mmap. Mode flag for nc_open() or nc_create()*/
  ------------------
                  use_mmap = ((omode & NC_MMAP) == NC_MMAP);
  ------------------
  |  |  141|    287|#define NC_MMAP          0x0010  /**< \deprecated Use diskless file with mmap. Mode flag for nc_open() or nc_create()*/
  ------------------
 2052|    287|    diskless = ((omode & NC_DISKLESS) == NC_DISKLESS);
  ------------------
  |  |  140|    287|#define NC_DISKLESS      0x0008  /**< Use diskless file. Mode flag for nc_open() or nc_create(). */
  ------------------
                  diskless = ((omode & NC_DISKLESS) == NC_DISKLESS);
  ------------------
  |  |  140|    287|#define NC_DISKLESS      0x0008  /**< Use diskless file. Mode flag for nc_open() or nc_create(). */
  ------------------
 2053|    287|    inmemory = ((omode & NC_INMEMORY) == NC_INMEMORY);
  ------------------
  |  |  189|    287|#define NC_INMEMORY      0x8000  /**< Read from memory. Mode flag for nc_open() or nc_create() */
  ------------------
                  inmemory = ((omode & NC_INMEMORY) == NC_INMEMORY);
  ------------------
  |  |  189|    287|#define NC_INMEMORY      0x8000  /**< Read from memory. Mode flag for nc_open() or nc_create() */
  ------------------
 2054|       |
 2055|       |    /* NC_INMEMORY and NC_DISKLESS and NC_MMAP are all mutually exclusive */
 2056|    287|    if(diskless && inmemory) {stat = NC_EDISKLESS; goto done;}
  ------------------
  |  |  558|      0|#define NC_EDISKLESS     (-129)    /**< Error in using diskless  access. */
  ------------------
  |  Branch (2056:8): [True: 0, False: 287]
  |  Branch (2056:20): [True: 0, False: 0]
  ------------------
 2057|    287|    if(diskless && use_mmap) {stat = NC_EDISKLESS; goto done;}
  ------------------
  |  |  558|      0|#define NC_EDISKLESS     (-129)    /**< Error in using diskless  access. */
  ------------------
  |  Branch (2057:8): [True: 0, False: 287]
  |  Branch (2057:20): [True: 0, False: 0]
  ------------------
 2058|    287|    if(inmemory && use_mmap) {stat = NC_EINMEMORY; goto done;}
  ------------------
  |  |  565|      0|#define NC_EINMEMORY     (-135)    /**< In-memory file error */
  ------------------
  |  Branch (2058:8): [True: 287, False: 0]
  |  Branch (2058:20): [True: 0, False: 287]
  ------------------
 2059|       |
 2060|       |    /* mmap is not allowed for netcdf-4 */
 2061|    287|    if(use_mmap && (omode & NC_NETCDF4)) {stat = NC_EINVAL; goto done;}
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
                  if(use_mmap && (omode & NC_NETCDF4)) {stat = NC_EINVAL; goto done;}
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (2061:8): [True: 0, False: 287]
  |  Branch (2061:20): [True: 0, False: 0]
  ------------------
 2062|       |
 2063|       |    /* Attempt to do file path conversion: note that this will do
 2064|       |       nothing if path is a 'file:...' url, so it will need to be
 2065|       |       repeated in protocol code (e.g. libdap2, libdap4, etc).
 2066|       |    */
 2067|       |
 2068|    287|    {
 2069|       |        /* Skip past any leading whitespace in path */
 2070|    287|        const char* p;
 2071|    287|        for(p=(const char*)path0;*p;p++) {if(*p < 0 || *p > ' ') break;}
  ------------------
  |  Branch (2071:34): [True: 287, False: 0]
  |  Branch (2071:46): [True: 0, False: 287]
  |  Branch (2071:56): [True: 287, False: 0]
  ------------------
 2072|    287|        path = nulldup(p);
  ------------------
  |  |  147|    287|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 287]
  |  |  ------------------
  ------------------
 2073|    287|    }
 2074|       |
 2075|    287|    memset(&model,0,sizeof(model));
 2076|       |    /* Infer model implementation and format, possibly by reading the file */
 2077|    287|    if((stat = NC_infermodel(path,&omode,0,useparallel,parameters,&model,&newpath)))
  ------------------
  |  Branch (2077:8): [True: 28, False: 259]
  ------------------
 2078|     28|        goto done;
 2079|    259|    if(newpath) {
  ------------------
  |  Branch (2079:8): [True: 0, False: 259]
  ------------------
 2080|      0|        nullfree(path);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2081|      0|        path = newpath;
 2082|      0|	newpath = NULL;
 2083|      0|    }
 2084|       |
 2085|       |    /* Still no implementation, give up */
 2086|    259|    if(model.impl == 0) {
  ------------------
  |  Branch (2086:8): [True: 0, False: 259]
  ------------------
 2087|       |#ifdef DEBUG
 2088|       |        fprintf(stderr,"implementation == 0\n");
 2089|       |#endif
 2090|      0|        {stat = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 2091|      0|    }
 2092|       |
 2093|       |    /* Suppress unsupported formats */
 2094|       |#if 0
 2095|       |    /* (should be more compact, table-driven, way to do this) */
 2096|       |    {
 2097|       |	int hdf5built = 0;
 2098|       |	int hdf4built = 0;
 2099|       |	int cdf5built = 0;
 2100|       |	int udf0built = 0;
 2101|       |	int udf1built = 0;
 2102|       |	int nczarrbuilt = 0;
 2103|       |#ifdef USE_NETCDF4
 2104|       |        hdf5built = 1;
 2105|       |#endif
 2106|       |#ifdef USE_HDF4
 2107|       |        hdf4built = 1;
 2108|       |#endif
 2109|       |#ifdef NETCDF_ENABLE_CDF5
 2110|       |        cdf5built = 1;
 2111|       |#endif
 2112|       |#ifdef NETCDF_ENABLE_NCZARR
 2113|       |	nczarrbuilt = 1;
 2114|       |#endif
 2115|       |        /* Check which UDF formats are built (i.e., have been registered).
 2116|       |         * A UDF format is considered "built" if its dispatch table is non-NULL. */
 2117|       |        int udfbuilt[NC_MAX_UDF_FORMATS] = {0};
 2118|       |        for(int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
 2119|       |            if(UDF_dispatch_tables[i] != NULL)
 2120|       |                udfbuilt[i] = 1;
 2121|       |        }
 2122|       |
 2123|       |        if(!hdf5built && model.impl == NC_FORMATX_NC4)
 2124|       |        {stat = NC_ENOTBUILT; goto done;}
 2125|       |        if(!hdf4built && model.impl == NC_FORMATX_NC_HDF4)
 2126|       |        {stat = NC_ENOTBUILT; goto done;}
 2127|       |        if(!cdf5built && model.impl == NC_FORMATX_NC3 && model.format == NC_FORMAT_CDF5)
 2128|       |        {stat = NC_ENOTBUILT; goto done;}
 2129|       |	if(!nczarrbuilt && model.impl == NC_FORMATX_NCZARR)
 2130|       |        {stat = NC_ENOTBUILT; goto done;}
 2131|       |        /* Check all UDF formats - ensure the requested format has been registered */
 2132|       |        for(int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
 2133|       |            /* Convert array index to format constant (handles gap: UDF0=8, UDF1=9, UDF2=11...) */
 2134|       |            int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
 2135|       |            if(!udfbuilt[i] && model.impl == formatx)
 2136|       |                {stat = NC_ENOTBUILT; goto done;}
 2137|       |        }
 2138|       |    }
 2139|       |#else
 2140|    259|    {
 2141|    259|	unsigned built = 0 /* leave off the trailing semicolon so we can build constant */
 2142|    259|		| (1<<NC_FORMATX_NC3) /* NC3 always supported */
  ------------------
  |  |  246|    259|#define NC_FORMATX_NC3       (1)
  ------------------
 2143|       |#ifdef USE_HDF5
 2144|       |		| (1<<NC_FORMATX_NC_HDF5)
 2145|       |#endif
 2146|       |#ifdef USE_HDF4
 2147|       |		| (1<<NC_FORMATX_NC_HDF4)
 2148|       |#endif
 2149|    259|#ifdef NETCDF_ENABLE_NCZARR
 2150|    259|		| (1<<NC_FORMATX_NCZARR)
  ------------------
  |  |  262|    259|#define NC_FORMATX_NCZARR    (10) /**< Added in version 4.8.0 */
  ------------------
 2151|    259|#endif
 2152|       |#ifdef NETCDF_ENABLE_DAP
 2153|       |		| (1<<NC_FORMATX_DAP2)
 2154|       |#endif
 2155|       |#ifdef NETCDF_ENABLE_DAP4
 2156|       |		| (1<<NC_FORMATX_DAP4)
 2157|       |#endif
 2158|       |#ifdef USE_PNETCDF
 2159|       |		| (1<<NC_FORMATX_PNETCDF)
 2160|       |#endif
 2161|    259|		; /* end of the built flags */
 2162|       |        /* Add UDF formats to built flags - set bit for each registered UDF format.
 2163|       |         * Use unsigned literal (1U) to avoid integer overflow for higher bit positions. */
 2164|  2.84k|        for(int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
  ------------------
  |  |  199|  2.84k|#define NC_MAX_UDF_FORMATS 10
  ------------------
  |  Branch (2164:24): [True: 2.59k, False: 259]
  ------------------
 2165|  2.59k|            if(UDF_dispatch_tables[i] != NULL) {
  ------------------
  |  Branch (2165:16): [True: 0, False: 2.59k]
  ------------------
 2166|       |                /* Convert array index to format constant */
 2167|      0|                int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  259|      0|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
                              int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  265|      0|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
  |  Branch (2167:31): [True: 0, False: 0]
  ------------------
 2168|      0|                built |= (1U << formatx);
 2169|      0|            }
 2170|  2.59k|        }
 2171|       |	/* Verify the requested format is available */
 2172|    259|	if((built & (1U << model.impl)) == 0)
  ------------------
  |  Branch (2172:5): [True: 2, False: 257]
  ------------------
 2173|      2|            {stat = NC_ENOTBUILT; goto done;}
  ------------------
  |  |  557|      2|#define NC_ENOTBUILT     (-128)    /**< Attempt to use feature that was not turned on when netCDF was built. */
  ------------------
 2174|       |#ifndef NETCDF_ENABLE_CDF5
 2175|       |	/* Special case because there is no separate CDF5 dispatcher */
 2176|       |        if(model.impl == NC_FORMATX_NC3 && (omode & NC_64BIT_DATA))
 2177|       |            {stat = NC_ENOTBUILT; goto done;}
 2178|       |#endif
 2179|    259|    }
 2180|    257|#endif
 2181|       |    /* Figure out what dispatcher to use */
 2182|    257|    if (!dispatcher) {
  ------------------
  |  Branch (2182:9): [True: 257, False: 0]
  ------------------
 2183|    257|        switch (model.impl) {
 2184|       |#ifdef NETCDF_ENABLE_DAP
 2185|       |        case NC_FORMATX_DAP2:
 2186|       |            dispatcher = NCD2_dispatch_table;
 2187|       |            break;
 2188|       |#endif
 2189|       |#ifdef NETCDF_ENABLE_DAP4
 2190|       |        case NC_FORMATX_DAP4:
 2191|       |            dispatcher = NCD4_dispatch_table;
 2192|       |            break;
 2193|       |#endif
 2194|      0|#ifdef NETCDF_ENABLE_NCZARR
 2195|      0|	case NC_FORMATX_NCZARR:
  ------------------
  |  |  262|      0|#define NC_FORMATX_NCZARR    (10) /**< Added in version 4.8.0 */
  ------------------
  |  Branch (2195:2): [True: 0, False: 257]
  ------------------
 2196|      0|	    dispatcher = NCZ_dispatch_table;
 2197|      0|	    break;
 2198|      0|#endif
 2199|       |#ifdef USE_PNETCDF
 2200|       |        case NC_FORMATX_PNETCDF:
 2201|       |            dispatcher = NCP_dispatch_table;
 2202|       |            break;
 2203|       |#endif
 2204|       |#ifdef USE_HDF5
 2205|       |        case NC_FORMATX_NC4:
 2206|       |            dispatcher = HDF5_dispatch_table;
 2207|       |            break;
 2208|       |#endif
 2209|       |#ifdef USE_HDF4
 2210|       |        case NC_FORMATX_NC_HDF4:
 2211|       |            dispatcher = HDF4_dispatch_table;
 2212|       |            break;
 2213|       |#endif
 2214|      0|#ifdef USE_NETCDF4
 2215|      0|        case NC_FORMATX_UDF0:
  ------------------
  |  |  259|      0|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
  |  Branch (2215:9): [True: 0, False: 257]
  ------------------
 2216|      0|        case NC_FORMATX_UDF1:
  ------------------
  |  |  260|      0|#define NC_FORMATX_UDF1      (9)  /**< User-defined format 1 */
  ------------------
  |  Branch (2216:9): [True: 0, False: 257]
  ------------------
 2217|      0|        case NC_FORMATX_UDF2:
  ------------------
  |  |  265|      0|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
  |  Branch (2217:9): [True: 0, False: 257]
  ------------------
 2218|      0|        case NC_FORMATX_UDF3:
  ------------------
  |  |  266|      0|#define NC_FORMATX_UDF3      (12) /**< User-defined format 3 */
  ------------------
  |  Branch (2218:9): [True: 0, False: 257]
  ------------------
 2219|      0|        case NC_FORMATX_UDF4:
  ------------------
  |  |  267|      0|#define NC_FORMATX_UDF4      (13) /**< User-defined format 4 */
  ------------------
  |  Branch (2219:9): [True: 0, False: 257]
  ------------------
 2220|      0|        case NC_FORMATX_UDF5:
  ------------------
  |  |  268|      0|#define NC_FORMATX_UDF5      (14) /**< User-defined format 5 */
  ------------------
  |  Branch (2220:9): [True: 0, False: 257]
  ------------------
 2221|      0|        case NC_FORMATX_UDF6:
  ------------------
  |  |  269|      0|#define NC_FORMATX_UDF6      (15) /**< User-defined format 6 */
  ------------------
  |  Branch (2221:9): [True: 0, False: 257]
  ------------------
 2222|      0|        case NC_FORMATX_UDF7:
  ------------------
  |  |  270|      0|#define NC_FORMATX_UDF7      (16) /**< User-defined format 7 */
  ------------------
  |  Branch (2222:9): [True: 0, False: 257]
  ------------------
 2223|      0|        case NC_FORMATX_UDF8:
  ------------------
  |  |  271|      0|#define NC_FORMATX_UDF8      (17) /**< User-defined format 8 */
  ------------------
  |  Branch (2223:9): [True: 0, False: 257]
  ------------------
 2224|      0|        case NC_FORMATX_UDF9:
  ------------------
  |  |  272|      0|#define NC_FORMATX_UDF9      (18) /**< User-defined format 9 */
  ------------------
  |  Branch (2224:9): [True: 0, False: 257]
  ------------------
 2225|      0|            {
 2226|       |                /* Convert format constant to array index and validate */
 2227|      0|                int udf_index = udf_formatx_to_index(model.impl);
 2228|      0|                if (udf_index < 0 || udf_index >= NC_MAX_UDF_FORMATS) {
  ------------------
  |  |  199|      0|#define NC_MAX_UDF_FORMATS 10
  ------------------
  |  Branch (2228:21): [True: 0, False: 0]
  |  Branch (2228:38): [True: 0, False: 0]
  ------------------
 2229|      0|                    stat = NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 2230|      0|                    goto done;
 2231|      0|                }
 2232|       |                /* Get the dispatch table for this UDF slot */
 2233|      0|                dispatcher = UDF_dispatch_tables[udf_index];
 2234|       |                /* Ensure the UDF format has been registered via nc_def_user_format() */
 2235|      0|                if (!dispatcher) {
  ------------------
  |  Branch (2235:21): [True: 0, False: 0]
  ------------------
 2236|      0|                    stat = NC_ENOTBUILT;
  ------------------
  |  |  557|      0|#define NC_ENOTBUILT     (-128)    /**< Attempt to use feature that was not turned on when netCDF was built. */
  ------------------
 2237|      0|                    goto done;
 2238|      0|                }
 2239|      0|            }
 2240|      0|            break;
 2241|      0|#endif /* USE_NETCDF4 */
 2242|    257|        case NC_FORMATX_NC3:
  ------------------
  |  |  246|    257|#define NC_FORMATX_NC3       (1)
  ------------------
  |  Branch (2242:9): [True: 257, False: 0]
  ------------------
 2243|    257|            dispatcher = NC3_dispatch_table;
 2244|    257|            break;
 2245|      0|        default:
  ------------------
  |  Branch (2245:9): [True: 0, False: 257]
  ------------------
 2246|      0|            stat = NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 2247|      0|	    goto done;
 2248|    257|        }
 2249|    257|    }
 2250|       |
 2251|       |
 2252|       |    /* If we can't figure out what dispatch table to use, give up. */
 2253|    257|    if (!dispatcher) {stat = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
  |  Branch (2253:9): [True: 0, False: 257]
  ------------------
 2254|       |
 2255|       |    /* Create the NC* instance and insert its dispatcher */
 2256|    257|    if((stat = new_NC(dispatcher,path,omode,&ncp))) goto done;
  ------------------
  |  Branch (2256:8): [True: 0, False: 257]
  ------------------
 2257|       |
 2258|       |    /* Add to list of known open files. This assigns an ext_ncid. */
 2259|    257|    add_to_NCList(ncp);
 2260|       |
 2261|       |    /* Assume open will fill in remaining ncp fields */
 2262|    257|    stat = dispatcher->open(ncp->path, omode, basepe, chunksizehintp,
 2263|    257|                            parameters, dispatcher, ncp->ext_ncid);
 2264|    257|    if(stat == NC_NOERR) {
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (2264:8): [True: 16, False: 241]
  ------------------
 2265|     16|        if(ncidp) *ncidp = ncp->ext_ncid;
  ------------------
  |  Branch (2265:12): [True: 16, False: 0]
  ------------------
 2266|    241|    } else {
 2267|    241|        del_from_NCList(ncp);
 2268|    241|        free_NC(ncp);
 2269|    241|    }
 2270|       |
 2271|    287|done:
 2272|    287|    nullfree(path);
  ------------------
  |  |  155|    287|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 287, False: 0]
  |  |  ------------------
  ------------------
 2273|       |    nullfree(newpath);
  ------------------
  |  |  155|    287|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 287]
  |  |  ------------------
  ------------------
 2274|    287|    return stat;
 2275|    257|}
nc__pseudofd:
 2293|    257|{
 2294|    257|    if(pseudofd == 0)  {
  ------------------
  |  Branch (2294:8): [True: 1, False: 256]
  ------------------
 2295|      1|#ifdef HAVE_GETRLIMIT
 2296|      1|        int maxfd = 32767; /* default */
 2297|      1|        struct rlimit rl;
 2298|      1|        if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
  ------------------
  |  Branch (2298:12): [True: 1, False: 0]
  ------------------
 2299|      1|            if(rl.rlim_max != RLIM_INFINITY)
  ------------------
  |  Branch (2299:16): [True: 1, False: 0]
  ------------------
 2300|      1|                maxfd = (int)rl.rlim_max;
 2301|      1|            if(rl.rlim_cur != RLIM_INFINITY)
  ------------------
  |  Branch (2301:16): [True: 1, False: 0]
  ------------------
 2302|      1|                maxfd = (int)rl.rlim_cur;
 2303|      1|        }
 2304|      1|        pseudofd = maxfd+1;
 2305|      1|#endif
 2306|      1|    }
 2307|    257|    return pseudofd++;
 2308|    257|}

NC_getglobalstate:
   72|     71|{
   73|     71|    if(nc_globalstate == NULL)
  ------------------
  |  Branch (73:8): [True: 1, False: 70]
  ------------------
   74|      1|        NC_createglobalstate();
   75|     71|    return nc_globalstate;
   76|     71|}
NC_freeglobalstate:
   80|      1|{
   81|      1|    NCglobalstate* gs = nc_globalstate;
   82|      1|    if(gs != NULL) {
  ------------------
  |  Branch (82:8): [True: 1, False: 0]
  ------------------
   83|      1|        nullfree(gs->tempdir);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
   84|      1|        nullfree(gs->home);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
   85|      1|        nullfree(gs->cwd);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
   86|      1|	memset(&gs->chunkcache,0,sizeof(struct ChunkCache));
   87|      1|	NC_clearawsparams(&gs->aws);
   88|      1|        if(gs->rcinfo) {
  ------------------
  |  Branch (88:12): [True: 1, False: 0]
  ------------------
   89|      1|	    NC_rcclear(gs->rcinfo);
   90|      1|	    free(gs->rcinfo);
   91|      1|	}
   92|      1|	nclistfree(gs->pluginpaths);
   93|      1|	free(gs);
   94|       |	nc_globalstate = NULL;
   95|      1|    }
   96|      1|}
NC_clearawsparams:
  102|      1|{
  103|      1|    nullfree(aws->default_region);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  104|      1|    nullfree(aws->config_file);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  105|      1|    nullfree(aws->profile);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  106|      1|    nullfree(aws->access_key_id);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  107|       |    nullfree(aws->secret_access_key);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  108|      1|    memset(aws,0,sizeof(struct GlobalAWS));
  109|      1|}
dglobal.c:NC_createglobalstate:
   37|      1|{
   38|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   39|      1|    const char* tmp = NULL;
   40|       |    
   41|      1|    if(nc_globalstate == NULL) {
  ------------------
  |  Branch (41:8): [True: 1, False: 0]
  ------------------
   42|      1|        nc_globalstate = calloc(1,sizeof(NCglobalstate));
   43|      1|	if(nc_globalstate == NULL) {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (43:5): [True: 0, False: 1]
  ------------------
   44|       |	/* Initialize struct pointers */
   45|      1|	if((nc_globalstate->rcinfo = calloc(1,sizeof(struct NCRCinfo)))==NULL)
  ------------------
  |  Branch (45:5): [True: 0, False: 1]
  ------------------
   46|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
   47|      1|	if((nc_globalstate->rcinfo->entries = nclistnew())==NULL)
  ------------------
  |  Branch (47:5): [True: 0, False: 1]
  ------------------
   48|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
   49|      1|	if((nc_globalstate->rcinfo->s3profiles = nclistnew())==NULL)
  ------------------
  |  Branch (49:5): [True: 0, False: 1]
  ------------------
   50|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
   51|      1|	memset(&nc_globalstate->chunkcache,0,sizeof(struct ChunkCache));
   52|      1|    }
   53|       |
   54|       |    /* Get environment variables */
   55|      1|    if(getenv(NCRCENVIGNORE) != NULL)
  ------------------
  |  |   22|      1|#define NCRCENVIGNORE "NCRCENV_IGNORE"
  ------------------
  |  Branch (55:8): [True: 0, False: 1]
  ------------------
   56|      0|        nc_globalstate->rcinfo->ignore = 1;
   57|      1|    tmp = getenv(NCRCENVRC);
  ------------------
  |  |   23|      1|#define NCRCENVRC "NCRCENV_RC"
  ------------------
   58|      1|    if(tmp != NULL && strlen(tmp) > 0)
  ------------------
  |  Branch (58:8): [True: 0, False: 1]
  |  Branch (58:23): [True: 0, False: 0]
  ------------------
   59|      0|        nc_globalstate->rcinfo->rcfile = strdup(tmp);
   60|       |    /* Initialize chunk cache defaults */
   61|      1|    nc_globalstate->chunkcache.size = DEFAULT_CHUNK_CACHE_SIZE;		    /**< Default chunk cache size. */
  ------------------
  |  |  101|      1|#define DEFAULT_CHUNK_CACHE_SIZE 67108864U
  ------------------
   62|      1|    nc_globalstate->chunkcache.nelems = DEFAULT_CHUNKS_IN_CACHE;	    /**< Default chunk cache number of elements. */
  ------------------
  |  |  104|      1|#define DEFAULT_CHUNKS_IN_CACHE 1000
  ------------------
   63|      1|    nc_globalstate->chunkcache.preemption = DEFAULT_CHUNK_CACHE_PREEMPTION; /**< Default chunk cache preemption. */
  ------------------
  |  |   98|      1|#define DEFAULT_CHUNK_CACHE_PREEMPTION 0.75
  ------------------
   64|       |    
   65|      1|done:
   66|      1|    return stat;
   67|      1|}

NC_infermodel:
  877|    287|{
  878|    287|    size_t i;
  879|    287|    int stat = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  880|    287|    NCURI* uri = NULL;
  881|    287|    int omode = *omodep;
  882|    287|    NClist* fraglenv = nclistnew();
  883|    287|    NClist* modeargs = nclistnew();
  884|    287|    char* sfrag = NULL;
  885|    287|    const char* modeval = NULL;
  886|    287|    char* abspath = NULL;
  887|    287|    NClist* tmp = NULL;
  888|       |
  889|       |    /* Phase 1:
  890|       |       1. convert special protocols to http|https
  891|       |       2. begin collecting fragments
  892|       |    */
  893|    287|    if((stat = processuri(path, &uri, fraglenv))) goto done;
  ------------------
  |  Branch (893:8): [True: 0, False: 287]
  ------------------
  894|       |
  895|    287|    if(uri != NULL) {
  ------------------
  |  Branch (895:8): [True: 0, False: 287]
  ------------------
  896|       |#ifdef DEBUG
  897|       |	printlist(fraglenv,"processuri");
  898|       |#endif
  899|       |
  900|       |        /* Phase 2: Expand macros and add to fraglenv */
  901|      0|	nclistfreeall(tmp);
  902|      0|	tmp = nclistnew();
  903|      0|        if((stat = processmacros(fraglenv,tmp))) goto done;
  ------------------
  |  Branch (903:12): [True: 0, False: 0]
  ------------------
  904|      0|	nclistfreeall(fraglenv);
  905|      0|	fraglenv = tmp; tmp = NULL;
  906|       |#ifdef DEBUG
  907|       |	printlist(fraglenv,"processmacros");
  908|       |#endif
  909|       |	/* Cleanup the fragment list */
  910|      0|	nclistfreeall(tmp);
  911|      0|	tmp = nclistnew();
  912|      0|        if((stat = cleanfragments(fraglenv,tmp))) goto done;
  ------------------
  |  Branch (912:12): [True: 0, False: 0]
  ------------------
  913|      0|	nclistfreeall(fraglenv);
  914|      0|	fraglenv = tmp; tmp = NULL;
  915|       |
  916|       |        /* Phase 2a: Expand mode inferences and add to fraglenv */
  917|      0|        if((stat = processinferences(fraglenv))) goto done;
  ------------------
  |  Branch (917:12): [True: 0, False: 0]
  ------------------
  918|       |#ifdef DEBUG
  919|       |	printlist(fraglenv,"processinferences");
  920|       |#endif
  921|       |
  922|       |        /* Phase 3: coalesce duplicate fragment keys and remove duplicate values */
  923|      0|	nclistfreeall(tmp);
  924|      0|	tmp = nclistnew();
  925|      0|        if((stat = cleanfragments(fraglenv,tmp))) goto done;
  ------------------
  |  Branch (925:12): [True: 0, False: 0]
  ------------------
  926|      0|	nclistfreeall(fraglenv);
  927|      0|	fraglenv = tmp; tmp = NULL;
  928|       |#ifdef DEBUG
  929|       |	printlist(fraglenv,"cleanfragments");
  930|       |#endif
  931|       |
  932|       |        /* Phase 4: Rebuild the url fragment and rebuilt the url */
  933|      0|        sfrag = envvlist2string(fraglenv,"&");
  934|      0|        nclistfreeall(fraglenv); fraglenv = NULL;
  935|       |#ifdef DEBUG
  936|       |	fprintf(stderr,"frag final: %s\n",sfrag);
  937|       |#endif
  938|      0|        ncurisetfragments(uri,sfrag);
  939|      0|        nullfree(sfrag); sfrag = NULL;
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  940|       |
  941|       |#ifdef NETCDF_ENABLE_S3
  942|       |	/* If s3, then rebuild the url */
  943|       |	if(NC_iss3(uri,NULL)) {
  944|       |	    NCURI* newuri = NULL;
  945|       |	    if((stat = NC_s3urlrebuild(uri,NULL,&newuri))) goto done;
  946|       |	    ncurifree(uri);
  947|       |	    uri = newuri;
  948|       |	} else
  949|       |#endif
  950|      0|	if(strcmp(uri->protocol,"file")==0) {
  ------------------
  |  Branch (950:5): [True: 0, False: 0]
  ------------------
  951|       |            /* convert path to absolute */
  952|      0|	    char* canon = NULL;
  953|      0|	    abspath = NCpathabsolute(uri->path);
  954|      0|	    if((stat = NCpathcanonical(abspath,&canon))) goto done;
  ------------------
  |  Branch (954:9): [True: 0, False: 0]
  ------------------
  955|      0|	    nullfree(abspath);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  956|      0|	    abspath = canon; canon = NULL;
  957|      0|	    if((stat = ncurisetpath(uri,abspath))) goto done;
  ------------------
  |  Branch (957:9): [True: 0, False: 0]
  ------------------
  958|      0|	}
  959|       |	
  960|       |	/* rebuild the path */
  961|      0|        if(newpathp) {
  ------------------
  |  Branch (961:12): [True: 0, False: 0]
  ------------------
  962|      0|            *newpathp = ncuribuild(uri,NULL,NULL,NCURIALL);
  ------------------
  |  |   23|      0|#define NCURIALL	    (NCURIBASE|NCURIQUERY|NCURIFRAG) /* for rebuilding after changes */
  |  |  ------------------
  |  |  |  |   21|      0|#define NCURIBASE	    (NCURIPWD|NCURIPATH)
  |  |  |  |  ------------------
  |  |  |  |  |  |   15|      0|#define NCURIPWD	    2
  |  |  |  |  ------------------
  |  |  |  |               #define NCURIBASE	    (NCURIPWD|NCURIPATH)
  |  |  |  |  ------------------
  |  |  |  |  |  |   14|      0|#define NCURIPATH	    1
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define NCURIALL	    (NCURIBASE|NCURIQUERY|NCURIFRAG) /* for rebuilding after changes */
  |  |  ------------------
  |  |  |  |   16|      0|#define NCURIQUERY	    4
  |  |  ------------------
  |  |               #define NCURIALL	    (NCURIBASE|NCURIQUERY|NCURIFRAG) /* for rebuilding after changes */
  |  |  ------------------
  |  |  |  |   17|      0|#define NCURIFRAG	    8
  |  |  ------------------
  ------------------
  963|       |#ifdef DEBUG
  964|       |	    fprintf(stderr,"newpath=|%s|\n",*newpathp); fflush(stderr);
  965|       |#endif    
  966|      0|	}
  967|       |
  968|       |        /* Phase 5: Process the mode key to see if we can tell the formatx */
  969|      0|        modeval = ncurifragmentlookup(uri,"mode");
  970|      0|        if(modeval != NULL) {
  ------------------
  |  Branch (970:12): [True: 0, False: 0]
  ------------------
  971|      0|	    if((stat = parseonchar(modeval,',',modeargs))) goto done;
  ------------------
  |  Branch (971:9): [True: 0, False: 0]
  ------------------
  972|      0|            for(i=0;i<nclistlength(modeargs);i++) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (972:21): [True: 0, False: 0]
  ------------------
  973|      0|        	const char* arg = nclistget(modeargs,i);
  974|      0|        	if((stat=processmodearg(arg,model))) goto done;
  ------------------
  |  Branch (974:13): [True: 0, False: 0]
  ------------------
  975|      0|            }
  976|      0|	}
  977|       |
  978|       |        /* Phase 6: Process the non-mode keys to see if we can tell the formatx */
  979|      0|	if(!modelcomplete(model)) {
  ------------------
  |  |   83|      0|#define modelcomplete(model) ((model)->impl != 0)
  ------------------
  |  Branch (979:5): [True: 0, False: 0]
  ------------------
  980|      0|	    size_t i;
  981|      0|	    NClist* p = (NClist*)ncurifragmentparams(uri); /* envv format */
  982|      0|	    for(i=0;i<nclistlength(p);i+=2) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (982:14): [True: 0, False: 0]
  ------------------
  983|      0|		const char* key = nclistget(p,0);
  984|      0|		const char* value = nclistget(p,1);
  985|      0|		if((stat=processfragmentkeys(key,value,model))) goto done;
  ------------------
  |  Branch (985:6): [True: 0, False: 0]
  ------------------
  986|      0|	    }
  987|      0|	}
  988|       |
  989|       |        /* Phase 7: Special cases: if this is a URL and model.impl is still not defined */
  990|       |        /* Phase7a: Default is DAP2 */
  991|      0|        if(!modelcomplete(model)) {
  ------------------
  |  |   83|      0|#define modelcomplete(model) ((model)->impl != 0)
  ------------------
  |  Branch (991:12): [True: 0, False: 0]
  ------------------
  992|      0|	    model->impl = NC_FORMATX_DAP2;
  ------------------
  |  |  251|      0|#define NC_FORMATX_DAP2      (5)
  ------------------
  993|      0|	    model->format = NC_FORMAT_NC3;
  ------------------
  |  |  281|      0|#define NC_FORMAT_NC3       NC_FORMATX_NC3 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC3 */
  |  |  ------------------
  |  |  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  |  |  ------------------
  ------------------
  994|      0|        }
  995|       |
  996|    287|    } else {/* Not URL */
  997|    287|	if(newpathp) *newpathp = NULL;
  ------------------
  |  Branch (997:5): [True: 287, False: 0]
  ------------------
  998|    287|    }
  999|       |
 1000|       |    /* Phase 8: mode inference from mode flags */
 1001|       |    /* The modeargs did not give us a model (probably not a URL).
 1002|       |       So look at the combination of mode flags and the useparallel flag */
 1003|    287|    if(!modelcomplete(model)) {
  ------------------
  |  |   83|    287|#define modelcomplete(model) ((model)->impl != 0)
  ------------------
  |  Branch (1003:8): [True: 287, False: 0]
  ------------------
 1004|    287|        if((stat = NC_omodeinfer(useparallel,omode,model))) goto done;
  ------------------
  |  Branch (1004:12): [True: 0, False: 287]
  ------------------
 1005|    287|    }
 1006|       |
 1007|       |    /* Phase 9: Special case for file stored in DAOS container */
 1008|    287|    if(isdaoscontainer(path) == NC_NOERR) {
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1008:8): [True: 0, False: 287]
  ------------------
 1009|       |        /* This is a DAOS container, so immediately assume it is HDF5. */
 1010|      0|        model->impl = NC_FORMATX_NC_HDF5;
  ------------------
  |  |  247|      0|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  ------------------
 1011|      0|        model->format = NC_FORMAT_NETCDF4;
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
 1012|    287|    } else {
 1013|       |        /* Phase 10: Infer from file content, if possible;
 1014|       |           this has highest precedence, so it may override
 1015|       |           previous decisions. Note that we do this last
 1016|       |           because we need previously determined model info
 1017|       |           to guess if this file is readable.
 1018|       |        */
 1019|    287|        if(!iscreate && isreadable(uri,model)) {
  ------------------
  |  Branch (1019:12): [True: 287, False: 0]
  |  Branch (1019:25): [True: 287, False: 0]
  ------------------
 1020|       |	     /* Ok, we need to try to read the file */
 1021|    287|            if((stat = check_file_type(path, omode, useparallel, params, model, uri))) goto done;
  ------------------
  |  Branch (1021:16): [True: 28, False: 259]
  ------------------
 1022|    287|        }
 1023|    287|    }
 1024|       |
 1025|       |    /* Need a decision */
 1026|    259|    if(!modelcomplete(model))
  ------------------
  |  |   83|    259|#define modelcomplete(model) ((model)->impl != 0)
  ------------------
  |  Branch (1026:8): [True: 0, False: 259]
  ------------------
 1027|      0|	{stat = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1028|       |
 1029|       |    /* Force flag consistency */
 1030|    259|    switch (model->impl) {
 1031|      2|    case NC_FORMATX_NC4:
  ------------------
  |  |  248|      2|#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
  |  |  ------------------
  |  |  |  |  247|      2|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  |  |  ------------------
  ------------------
  |  Branch (1031:5): [True: 2, False: 257]
  ------------------
 1032|      2|    case NC_FORMATX_NC_HDF4:
  ------------------
  |  |  249|      2|#define NC_FORMATX_NC_HDF4   (3) /**< netCDF-4 subset of HDF4 */
  ------------------
  |  Branch (1032:5): [True: 0, False: 259]
  ------------------
 1033|      2|    case NC_FORMATX_DAP4:
  ------------------
  |  |  252|      2|#define NC_FORMATX_DAP4      (6)
  ------------------
  |  Branch (1033:5): [True: 0, False: 259]
  ------------------
 1034|      2|    case NC_FORMATX_NCZARR:
  ------------------
  |  |  262|      2|#define NC_FORMATX_NCZARR    (10) /**< Added in version 4.8.0 */
  ------------------
  |  Branch (1034:5): [True: 0, False: 259]
  ------------------
 1035|      2|	omode |= NC_NETCDF4;
  ------------------
  |  |  179|      2|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
 1036|      2|	if(model->format == NC_FORMAT_NETCDF4_CLASSIC)
  ------------------
  |  |  217|      2|#define NC_FORMAT_NETCDF4_CLASSIC (4)
  ------------------
  |  Branch (1036:5): [True: 0, False: 2]
  ------------------
 1037|      0|	    omode |= NC_CLASSIC_MODEL;
  ------------------
  |  |  166|      0|#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
  ------------------
 1038|      2|	break;
 1039|    257|    case NC_FORMATX_NC3:
  ------------------
  |  |  246|    257|#define NC_FORMATX_NC3       (1)
  ------------------
  |  Branch (1039:5): [True: 257, False: 2]
  ------------------
 1040|    257|	omode &= ~NC_NETCDF4; /* must be netcdf-3 (CDF-1, CDF-2, CDF-5) */
  ------------------
  |  |  179|    257|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
 1041|    257|	if(model->format == NC_FORMAT_64BIT_OFFSET) omode |= NC_64BIT_OFFSET;
  ------------------
  |  |  214|    257|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
              	if(model->format == NC_FORMAT_64BIT_OFFSET) omode |= NC_64BIT_OFFSET;
  ------------------
  |  |  167|     93|#define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
  ------------------
  |  Branch (1041:5): [True: 93, False: 164]
  ------------------
 1042|    164|	else if(model->format == NC_FORMAT_64BIT_DATA) omode |= NC_64BIT_DATA;
  ------------------
  |  |  218|    164|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
              	else if(model->format == NC_FORMAT_64BIT_DATA) omode |= NC_64BIT_DATA;
  ------------------
  |  |  143|     84|#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
  ------------------
  |  Branch (1042:10): [True: 84, False: 80]
  ------------------
 1043|    257|	break;
 1044|      0|    case NC_FORMATX_PNETCDF:
  ------------------
  |  |  250|      0|#define NC_FORMATX_PNETCDF   (4)
  ------------------
  |  Branch (1044:5): [True: 0, False: 259]
  ------------------
 1045|      0|	omode &= ~NC_NETCDF4; /* must be netcdf-3 (CDF-1, CDF-2, CDF-5) */
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
 1046|      0|	if(model->format == NC_FORMAT_64BIT_OFFSET) omode |= NC_64BIT_OFFSET;
  ------------------
  |  |  214|      0|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
              	if(model->format == NC_FORMAT_64BIT_OFFSET) omode |= NC_64BIT_OFFSET;
  ------------------
  |  |  167|      0|#define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
  ------------------
  |  Branch (1046:5): [True: 0, False: 0]
  ------------------
 1047|      0|	else if(model->format == NC_FORMAT_64BIT_DATA) omode |= NC_64BIT_DATA;
  ------------------
  |  |  218|      0|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
              	else if(model->format == NC_FORMAT_64BIT_DATA) omode |= NC_64BIT_DATA;
  ------------------
  |  |  143|      0|#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
  ------------------
  |  Branch (1047:10): [True: 0, False: 0]
  ------------------
 1048|      0|	break;
 1049|      0|    case NC_FORMATX_DAP2:
  ------------------
  |  |  251|      0|#define NC_FORMATX_DAP2      (5)
  ------------------
  |  Branch (1049:5): [True: 0, False: 259]
  ------------------
 1050|      0|	omode &= ~(NC_NETCDF4|NC_64BIT_OFFSET|NC_64BIT_DATA|NC_CLASSIC_MODEL);
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
              	omode &= ~(NC_NETCDF4|NC_64BIT_OFFSET|NC_64BIT_DATA|NC_CLASSIC_MODEL);
  ------------------
  |  |  167|      0|#define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
  ------------------
              	omode &= ~(NC_NETCDF4|NC_64BIT_OFFSET|NC_64BIT_DATA|NC_CLASSIC_MODEL);
  ------------------
  |  |  143|      0|#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
  ------------------
              	omode &= ~(NC_NETCDF4|NC_64BIT_OFFSET|NC_64BIT_DATA|NC_CLASSIC_MODEL);
  ------------------
  |  |  166|      0|#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
  ------------------
 1051|      0|	break;
 1052|      0|    case NC_FORMATX_UDF0:
  ------------------
  |  |  259|      0|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
  |  Branch (1052:5): [True: 0, False: 259]
  ------------------
 1053|      0|    case NC_FORMATX_UDF1:
  ------------------
  |  |  260|      0|#define NC_FORMATX_UDF1      (9)  /**< User-defined format 1 */
  ------------------
  |  Branch (1053:5): [True: 0, False: 259]
  ------------------
 1054|      0|    case NC_FORMATX_UDF2:
  ------------------
  |  |  265|      0|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
  |  Branch (1054:5): [True: 0, False: 259]
  ------------------
 1055|      0|    case NC_FORMATX_UDF3:
  ------------------
  |  |  266|      0|#define NC_FORMATX_UDF3      (12) /**< User-defined format 3 */
  ------------------
  |  Branch (1055:5): [True: 0, False: 259]
  ------------------
 1056|      0|    case NC_FORMATX_UDF4:
  ------------------
  |  |  267|      0|#define NC_FORMATX_UDF4      (13) /**< User-defined format 4 */
  ------------------
  |  Branch (1056:5): [True: 0, False: 259]
  ------------------
 1057|      0|    case NC_FORMATX_UDF5:
  ------------------
  |  |  268|      0|#define NC_FORMATX_UDF5      (14) /**< User-defined format 5 */
  ------------------
  |  Branch (1057:5): [True: 0, False: 259]
  ------------------
 1058|      0|    case NC_FORMATX_UDF6:
  ------------------
  |  |  269|      0|#define NC_FORMATX_UDF6      (15) /**< User-defined format 6 */
  ------------------
  |  Branch (1058:5): [True: 0, False: 259]
  ------------------
 1059|      0|    case NC_FORMATX_UDF7:
  ------------------
  |  |  270|      0|#define NC_FORMATX_UDF7      (16) /**< User-defined format 7 */
  ------------------
  |  Branch (1059:5): [True: 0, False: 259]
  ------------------
 1060|      0|    case NC_FORMATX_UDF8:
  ------------------
  |  |  271|      0|#define NC_FORMATX_UDF8      (17) /**< User-defined format 8 */
  ------------------
  |  Branch (1060:5): [True: 0, False: 259]
  ------------------
 1061|      0|    case NC_FORMATX_UDF9:
  ------------------
  |  |  272|      0|#define NC_FORMATX_UDF9      (18) /**< User-defined format 9 */
  ------------------
  |  Branch (1061:5): [True: 0, False: 259]
  ------------------
 1062|      0|        if(model->format == NC_FORMAT_64BIT_OFFSET) 
  ------------------
  |  |  214|      0|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
  |  Branch (1062:12): [True: 0, False: 0]
  ------------------
 1063|      0|            omode |= NC_64BIT_OFFSET;
  ------------------
  |  |  167|      0|#define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
  ------------------
 1064|      0|        else if(model->format == NC_FORMAT_64BIT_DATA)
  ------------------
  |  |  218|      0|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
  |  Branch (1064:17): [True: 0, False: 0]
  ------------------
 1065|      0|            omode |= NC_64BIT_DATA;
  ------------------
  |  |  143|      0|#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
  ------------------
 1066|      0|        else if(model->format == NC_FORMAT_NETCDF4)  
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
  |  Branch (1066:17): [True: 0, False: 0]
  ------------------
 1067|      0|            omode |= NC_NETCDF4;
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
 1068|      0|        else if(model->format == NC_FORMAT_NETCDF4_CLASSIC)  
  ------------------
  |  |  217|      0|#define NC_FORMAT_NETCDF4_CLASSIC (4)
  ------------------
  |  Branch (1068:17): [True: 0, False: 0]
  ------------------
 1069|      0|            omode |= NC_NETCDF4|NC_CLASSIC_MODEL;
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
                          omode |= NC_NETCDF4|NC_CLASSIC_MODEL;
  ------------------
  |  |  166|      0|#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
  ------------------
 1070|      0|        break;
 1071|      0|    default:
  ------------------
  |  Branch (1071:5): [True: 0, False: 259]
  ------------------
 1072|      0|	{stat = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1073|    259|    }
 1074|       |
 1075|    287|done:
 1076|    287|    nullfree(sfrag);
  ------------------
  |  |  155|    287|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 287]
  |  |  ------------------
  ------------------
 1077|    287|    nullfree(abspath);
  ------------------
  |  |  155|    287|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 287]
  |  |  ------------------
  ------------------
 1078|    287|    ncurifree(uri);
 1079|    287|    nclistfreeall(modeargs);
 1080|    287|    nclistfreeall(fraglenv);
 1081|    287|    nclistfreeall(tmp);
 1082|    287|    *omodep = omode; /* in/out */
 1083|    287|    return check(stat);
  ------------------
  |  |  106|    287|#define check(err) (err)
  ------------------
 1084|    259|}
dinfermodel.c:processuri:
  263|    287|{
  264|    287|    int stat = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  265|    287|    int found = 0;
  266|    287|    NClist* tmp = NULL;
  267|    287|    struct NCPROTOCOLLIST* protolist;
  268|    287|    NCURI* uri = NULL;
  269|    287|    size_t pathlen = strlen(path);
  270|    287|    char* str = NULL;
  271|    287|    const NClist* ufrags;
  272|    287|    size_t i;
  273|       |
  274|    287|    if(path == NULL || pathlen == 0) {stat = NC_EURL; goto done;}
  ------------------
  |  |  584|      0|#define NC_EURL         (NC_EDAPURL)   /**< Malformed URL */
  |  |  ------------------
  |  |  |  |  514|      0|#define NC_EDAPURL      (-74)      /**< Malformed DAP URL */
  |  |  ------------------
  ------------------
  |  Branch (274:8): [True: 0, False: 287]
  |  Branch (274:24): [True: 0, False: 287]
  ------------------
  275|       |
  276|       |    /* Defaults */
  277|    287|    if(urip) *urip = NULL;
  ------------------
  |  Branch (277:8): [True: 287, False: 0]
  ------------------
  278|       |
  279|    287|    ncuriparse(path,&uri);
  280|    287|    if(uri == NULL) goto done; /* not url */
  ------------------
  |  Branch (280:8): [True: 287, False: 0]
  ------------------
  281|       |
  282|       |    /* Look up the protocol */
  283|      0|    for(found=0,protolist=ncprotolist;protolist->protocol;protolist++) {
  ------------------
  |  Branch (283:39): [True: 0, False: 0]
  ------------------
  284|      0|        if(strcmp(uri->protocol,protolist->protocol) == 0) {
  ------------------
  |  Branch (284:12): [True: 0, False: 0]
  ------------------
  285|      0|	    found = 1;
  286|      0|	    break;
  287|      0|	}
  288|      0|    }
  289|      0|    if(!found)
  ------------------
  |  Branch (289:8): [True: 0, False: 0]
  ------------------
  290|      0|	{stat = NC_EINVAL; goto done;} /* unrecognized URL form */
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  291|       |
  292|       |    /* process the corresponding fragments for that protocol */
  293|      0|    if(protolist->fragments != NULL) {
  ------------------
  |  Branch (293:8): [True: 0, False: 0]
  ------------------
  294|      0|	tmp = nclistnew();
  295|      0|	if((stat = parseonchar(protolist->fragments,'&',tmp))) goto done;
  ------------------
  |  Branch (295:5): [True: 0, False: 0]
  ------------------
  296|      0|	for(i=0;i<nclistlength(tmp);i++) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (296:10): [True: 0, False: 0]
  ------------------
  297|      0|	    char* key=NULL;
  298|      0|    	    char* value=NULL;
  299|      0|	    if((stat = parsepair(nclistget(tmp,i),&key,&value))) goto done;
  ------------------
  |  Branch (299:9): [True: 0, False: 0]
  ------------------
  300|      0|	    if(value == NULL) value = strdup("");
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|	    nclistpush(fraglenv,key);
  302|      0|    	    nclistpush(fraglenv,value);
  303|      0|	}
  304|      0|	nclistfreeall(tmp); tmp = NULL;
  305|      0|    }
  306|       |
  307|       |    /* Substitute the protocol in any case */
  308|      0|    if(protolist->substitute) ncurisetprotocol(uri,protolist->substitute);
  ------------------
  |  Branch (308:8): [True: 0, False: 0]
  ------------------
  309|       |
  310|       |    /* capture the fragments of the url */
  311|      0|    ufrags = (const NClist*)ncurifragmentparams(uri);
  312|      0|    for(i=0;i<nclistlength(ufrags);i+=2) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (312:13): [True: 0, False: 0]
  ------------------
  313|      0|	const char* key = nclistget(ufrags,i);
  314|      0|	const char* value = nclistget(ufrags,i+1);
  315|      0|        nclistpush(fraglenv,nulldup(key));
  ------------------
  |  |  147|      0|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  316|      0|	value = (value==NULL?"":value);
  ------------------
  |  Branch (316:11): [True: 0, False: 0]
  ------------------
  317|      0|	nclistpush(fraglenv,strdup(value));
  318|      0|    }
  319|      0|    if(urip) {
  ------------------
  |  Branch (319:8): [True: 0, False: 0]
  ------------------
  320|      0|	*urip = uri;
  321|      0|	uri = NULL;
  322|      0|    }
  323|       |
  324|    287|done:
  325|    287|    nclistfreeall(tmp);
  326|    287|    nullfree(str);
  ------------------
  |  |  155|    287|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  327|    287|    if(uri != NULL) ncurifree(uri);
  ------------------
  |  Branch (327:8): [True: 0, False: 287]
  ------------------
  328|    287|    return check(stat);
  ------------------
  |  |  106|    287|#define check(err) (err)
  ------------------
  329|      0|}
dinfermodel.c:NC_omodeinfer:
  751|    287|{
  752|    287|    int stat = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  753|       |
  754|       |    /* If no format flags are set, then use default */
  755|    287|    if(!fIsSet(cmode,NC_FORMAT_ALL))
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  ------------------
  |  Branch (755:8): [True: 287, False: 0]
  ------------------
  756|    287|	set_default_mode(&cmode);
  757|       |
  758|       |    /* Process the cmode; may override some already set flags. The
  759|       |     * user-defined formats must be checked first. They may choose to
  760|       |     * use some of the other flags, like NC_NETCDF4, so we must first
  761|       |     * check NC_UDF0-NC_UDF9 before checking for any other flag. */
  762|    287|    int udf_found = 0;
  763|       |    /* Lookup table for all UDF mode flags. This replaces the previous bit-shift
  764|       |     * calculation which was fragile due to non-sequential bit positions
  765|       |     * (bits 16, 19-25 to avoid conflicts with NC_NOATTCREORD and NC_NODIMSCALE_ATTACH). */
  766|    287|    static const int udf_flags[NC_MAX_UDF_FORMATS] = {
  767|    287|        NC_UDF0, NC_UDF1, NC_UDF2, NC_UDF3, NC_UDF4,
  ------------------
  |  |  152|    287|#define NC_UDF0          0x0040  /**< User-defined format 0 (bit 6). */
  ------------------
                      NC_UDF0, NC_UDF1, NC_UDF2, NC_UDF3, NC_UDF4,
  ------------------
  |  |  153|    287|#define NC_UDF1          0x0080  /**< User-defined format 1 (bit 7). */
  ------------------
                      NC_UDF0, NC_UDF1, NC_UDF2, NC_UDF3, NC_UDF4,
  ------------------
  |  |  156|    287|#define NC_UDF2          0x10000  /**< User-defined format 2 (bit 16). */
  ------------------
                      NC_UDF0, NC_UDF1, NC_UDF2, NC_UDF3, NC_UDF4,
  ------------------
  |  |  157|    287|#define NC_UDF3          0x80000  /**< User-defined format 3 (bit 19). */
  ------------------
                      NC_UDF0, NC_UDF1, NC_UDF2, NC_UDF3, NC_UDF4,
  ------------------
  |  |  158|    287|#define NC_UDF4          0x100000  /**< User-defined format 4 (bit 20). */
  ------------------
  768|    287|        NC_UDF5, NC_UDF6, NC_UDF7, NC_UDF8, NC_UDF9
  ------------------
  |  |  159|    287|#define NC_UDF5          0x200000  /**< User-defined format 5 (bit 21). */
  ------------------
                      NC_UDF5, NC_UDF6, NC_UDF7, NC_UDF8, NC_UDF9
  ------------------
  |  |  160|    287|#define NC_UDF6          0x400000  /**< User-defined format 6 (bit 22). */
  ------------------
                      NC_UDF5, NC_UDF6, NC_UDF7, NC_UDF8, NC_UDF9
  ------------------
  |  |  161|    287|#define NC_UDF7          0x800000  /**< User-defined format 7 (bit 23). */
  ------------------
                      NC_UDF5, NC_UDF6, NC_UDF7, NC_UDF8, NC_UDF9
  ------------------
  |  |  162|    287|#define NC_UDF8          0x1000000  /**< User-defined format 8 (bit 24). */
  ------------------
                      NC_UDF5, NC_UDF6, NC_UDF7, NC_UDF8, NC_UDF9
  ------------------
  |  |  163|    287|#define NC_UDF9          0x2000000  /**< User-defined format 9 (bit 25). */
  ------------------
  769|    287|    };
  770|       |    /* Check if any UDF format flag is set in the mode */
  771|  3.15k|    for(int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
  ------------------
  |  |  199|  3.15k|#define NC_MAX_UDF_FORMATS 10
  ------------------
  |  Branch (771:20): [True: 2.87k, False: 287]
  ------------------
  772|  2.87k|        if(fIsSet(cmode, udf_flags[i])) {
  ------------------
  |  |   15|  2.87k|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 2.87k]
  |  |  ------------------
  ------------------
  773|       |            /* Convert array index to format constant (handles gap in numbering) */
  774|      0|            int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  259|      0|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
                          int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  265|      0|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
  |  Branch (774:27): [True: 0, False: 0]
  ------------------
  775|      0|            model->impl = formatx;
  776|      0|            udf_found = 1;
  777|      0|            break;
  778|      0|        }
  779|  2.87k|    }
  780|       |    
  781|    287|    if(udf_found)
  ------------------
  |  Branch (781:8): [True: 0, False: 287]
  ------------------
  782|      0|    {
  783|      0|        if(fIsSet(cmode,NC_64BIT_OFFSET)) 
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  784|      0|        {
  785|      0|            model->format = NC_FORMAT_64BIT_OFFSET;
  ------------------
  |  |  214|      0|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
  786|      0|        }
  787|      0|        else if(fIsSet(cmode,NC_64BIT_DATA))
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  788|      0|        {
  789|      0|            model->format = NC_FORMAT_64BIT_DATA;
  ------------------
  |  |  218|      0|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
  790|      0|        }
  791|      0|        else if(fIsSet(cmode,NC_NETCDF4))
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  792|      0|        {
  793|      0|            if(fIsSet(cmode,NC_CLASSIC_MODEL))
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  794|      0|                model->format = NC_FORMAT_NETCDF4_CLASSIC;
  ------------------
  |  |  217|      0|#define NC_FORMAT_NETCDF4_CLASSIC (4)
  ------------------
  795|      0|            else
  796|      0|                model->format = NC_FORMAT_NETCDF4;
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
  797|      0|        }
  798|      0|        if(! model->format)
  ------------------
  |  Branch (798:12): [True: 0, False: 0]
  ------------------
  799|      0|            model->format = NC_FORMAT_CLASSIC;
  ------------------
  |  |  208|      0|#define NC_FORMAT_CLASSIC         (1)
  ------------------
  800|      0|	goto done;
  801|      0|    }
  802|       |
  803|    287|    if(fIsSet(cmode,NC_64BIT_OFFSET)) {
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  804|      0|	model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  ------------------
  805|      0|	model->format = NC_FORMAT_64BIT_OFFSET;
  ------------------
  |  |  214|      0|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
  806|      0|        goto done;
  807|      0|    }
  808|       |
  809|    287|    if(fIsSet(cmode,NC_64BIT_DATA)) {
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  810|      0|	model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  ------------------
  811|      0|	model->format = NC_FORMAT_64BIT_DATA;
  ------------------
  |  |  218|      0|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
  812|      0|        goto done;
  813|      0|    }
  814|       |
  815|    287|    if(fIsSet(cmode,NC_NETCDF4)) {
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  816|      0|	model->impl = NC_FORMATX_NC4;
  ------------------
  |  |  248|      0|#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
  |  |  ------------------
  |  |  |  |  247|      0|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  |  |  ------------------
  ------------------
  817|      0|        if(fIsSet(cmode,NC_CLASSIC_MODEL))
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|	    model->format = NC_FORMAT_NETCDF4_CLASSIC;
  ------------------
  |  |  217|      0|#define NC_FORMAT_NETCDF4_CLASSIC (4)
  ------------------
  819|      0|	else
  820|      0|	    model->format = NC_FORMAT_NETCDF4;
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
  821|      0|        goto done;
  822|      0|    }
  823|       |
  824|       |    /* Default to classic model */
  825|    287|    model->format = NC_FORMAT_CLASSIC;
  ------------------
  |  |  208|    287|#define NC_FORMAT_CLASSIC         (1)
  ------------------
  826|    287|    model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|    287|#define NC_FORMATX_NC3       (1)
  ------------------
  827|       |
  828|    287|done:
  829|       |    /* Apply parallel flag */
  830|    287|    if(useparallel) {
  ------------------
  |  Branch (830:8): [True: 0, False: 287]
  ------------------
  831|      0|        if(model->impl == NC_FORMATX_NC3)
  ------------------
  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  ------------------
  |  Branch (831:12): [True: 0, False: 0]
  ------------------
  832|      0|	    model->impl = NC_FORMATX_PNETCDF;
  ------------------
  |  |  250|      0|#define NC_FORMATX_PNETCDF   (4)
  ------------------
  833|      0|    }
  834|    287|    return check(stat);
  ------------------
  |  |  106|    287|#define check(err) (err)
  ------------------
  835|    287|}
dinfermodel.c:set_default_mode:
  844|    287|{
  845|    287|    int mode = *modep;
  846|    287|    int dfaltformat;
  847|       |
  848|    287|    dfaltformat = nc_get_default_format();
  849|    287|    switch (dfaltformat) {
  850|      0|    case NC_FORMAT_64BIT_OFFSET: mode |= NC_64BIT_OFFSET; break;
  ------------------
  |  |  214|      0|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
                  case NC_FORMAT_64BIT_OFFSET: mode |= NC_64BIT_OFFSET; break;
  ------------------
  |  |  167|      0|#define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
  ------------------
  |  Branch (850:5): [True: 0, False: 287]
  ------------------
  851|      0|    case NC_FORMAT_64BIT_DATA: mode |= NC_64BIT_DATA; break;
  ------------------
  |  |  218|      0|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
                  case NC_FORMAT_64BIT_DATA: mode |= NC_64BIT_DATA; break;
  ------------------
  |  |  143|      0|#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
  ------------------
  |  Branch (851:5): [True: 0, False: 287]
  ------------------
  852|      0|    case NC_FORMAT_NETCDF4: mode |= NC_NETCDF4; break;
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
                  case NC_FORMAT_NETCDF4: mode |= NC_NETCDF4; break;
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
  |  Branch (852:5): [True: 0, False: 287]
  ------------------
  853|      0|    case NC_FORMAT_NETCDF4_CLASSIC: mode |= (NC_NETCDF4|NC_CLASSIC_MODEL); break;
  ------------------
  |  |  217|      0|#define NC_FORMAT_NETCDF4_CLASSIC (4)
  ------------------
                  case NC_FORMAT_NETCDF4_CLASSIC: mode |= (NC_NETCDF4|NC_CLASSIC_MODEL); break;
  ------------------
  |  |  179|      0|#define NC_NETCDF4       0x1000  /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
  ------------------
                  case NC_FORMAT_NETCDF4_CLASSIC: mode |= (NC_NETCDF4|NC_CLASSIC_MODEL); break;
  ------------------
  |  |  166|      0|#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
  ------------------
  |  Branch (853:5): [True: 0, False: 287]
  ------------------
  854|    287|    case NC_FORMAT_CLASSIC: /* fall thru */
  ------------------
  |  |  208|    287|#define NC_FORMAT_CLASSIC         (1)
  ------------------
  |  Branch (854:5): [True: 287, False: 0]
  ------------------
  855|    287|    default: break; /* default to classic */
  ------------------
  |  Branch (855:5): [True: 0, False: 287]
  ------------------
  856|    287|    }
  857|    287|    *modep = mode; /* final result */
  858|    287|}
dinfermodel.c:isreadable:
 1088|    287|{
 1089|    287|    int canread = 0;
 1090|    287|    struct Readable* r;
 1091|       |    /* Step 1: Look up the implementation */
 1092|    287|    for(r=readable;r->impl;r++) {
  ------------------
  |  Branch (1092:20): [True: 287, False: 0]
  ------------------
 1093|    287|	if(model->impl == r->impl) {canread = r->readable; break;}
  ------------------
  |  Branch (1093:5): [True: 287, False: 0]
  ------------------
 1094|    287|    }
 1095|       |    /* Step 2: check for bytes mode */
 1096|    287|    if(!canread && NC_testmode(uri,"bytes") && (model->impl == NC_FORMATX_NC4 || model->impl == NC_FORMATX_NC_HDF5))
  ------------------
  |  |  248|      0|#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
  |  |  ------------------
  |  |  |  |  247|      0|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  |  |  ------------------
  ------------------
                  if(!canread && NC_testmode(uri,"bytes") && (model->impl == NC_FORMATX_NC4 || model->impl == NC_FORMATX_NC_HDF5))
  ------------------
  |  |  247|      0|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  ------------------
  |  Branch (1096:8): [True: 0, False: 287]
  |  Branch (1096:20): [True: 0, False: 0]
  |  Branch (1096:49): [True: 0, False: 0]
  |  Branch (1096:82): [True: 0, False: 0]
  ------------------
 1097|      0|        canread = 1;
 1098|    287|    return canread;
 1099|    287|}
dinfermodel.c:check_file_type:
 1247|    287|{
 1248|    287|    char magic[NC_MAX_MAGIC_NUMBER_LEN];
 1249|    287|    int status = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
 1250|    287|    struct MagicFile magicinfo;
 1251|       |#ifdef _WIN32
 1252|       |    NC* nc = NULL;
 1253|       |#endif
 1254|       |
 1255|    287|    memset((void*)&magicinfo,0,sizeof(magicinfo));
 1256|       |
 1257|       |#ifdef _WIN32 /* including MINGW */
 1258|       |    /* Windows does not handle multiple handles to the same file very well.
 1259|       |       So if file is already open/created, then find it and just get the
 1260|       |       model from that. */
 1261|       |    if((nc = find_in_NCList_by_name(path)) != NULL) {
 1262|       |	int format = 0;
 1263|       |	/* Get the model from this NC */
 1264|       |	if((status = nc_inq_format_extended(nc->ext_ncid,&format,NULL))) goto done;
 1265|       |	model->impl = format;
 1266|       |	if((status = nc_inq_format(nc->ext_ncid,&format))) goto done;
 1267|       |	model->format = format;
 1268|       |	goto done;
 1269|       |    }
 1270|       |#endif
 1271|       |
 1272|    287|    magicinfo.path = path; /* do not free */
 1273|    287|    magicinfo.uri = uri; /* do not free */
 1274|    287|    magicinfo.omode = omode;
 1275|    287|    magicinfo.model = model; /* do not free */
 1276|    287|    magicinfo.parameters = parameters; /* do not free */
 1277|       |#ifdef USE_STDIO
 1278|       |    magicinfo.use_parallel = 0;
 1279|       |#else
 1280|    287|    magicinfo.use_parallel = use_parallel;
 1281|    287|#endif
 1282|       |
 1283|    287|    if((status = openmagic(&magicinfo))) goto done;
  ------------------
  |  Branch (1283:8): [True: 0, False: 287]
  ------------------
 1284|       |
 1285|       |    /* Verify we have a large enough file */
 1286|    287|    if(MAGIC_NUMBER_LEN >= (unsigned long long)magicinfo.filelen)
  ------------------
  |  |   38|    287|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
  |  Branch (1286:8): [True: 0, False: 287]
  ------------------
 1287|      0|	{status = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1288|    287|    if((status = readmagic(&magicinfo,0L,magic)) != NC_NOERR) {
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1288:8): [True: 0, False: 287]
  ------------------
 1289|      0|	status = NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1290|      0|	goto done;
 1291|      0|    }
 1292|       |
 1293|       |    /* Look at the magic number */
 1294|    287|    if(NC_interpret_magic_number(magic,model) == NC_NOERR
  ------------------
  |  |  417|    574|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1294:8): [True: 257, False: 30]
  ------------------
 1295|    257|	&& model->format != 0) {
  ------------------
  |  Branch (1295:5): [True: 257, False: 0]
  ------------------
 1296|    257|        if (use_parallel && (model->format == NC_FORMAT_NC3 || model->impl == NC_FORMATX_NC3))
  ------------------
  |  |  281|      0|#define NC_FORMAT_NC3       NC_FORMATX_NC3 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC3 */
  |  |  ------------------
  |  |  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  |  |  ------------------
  ------------------
                      if (use_parallel && (model->format == NC_FORMAT_NC3 || model->impl == NC_FORMATX_NC3))
  ------------------
  |  |  246|      0|#define NC_FORMATX_NC3       (1)
  ------------------
  |  Branch (1296:13): [True: 0, False: 257]
  |  Branch (1296:30): [True: 0, False: 0]
  |  Branch (1296:64): [True: 0, False: 0]
  ------------------
 1297|       |            /* this is called from nc_open_par() and file is classic */
 1298|      0|            model->impl = NC_FORMATX_PNETCDF;
  ------------------
  |  |  250|      0|#define NC_FORMATX_PNETCDF   (4)
  ------------------
 1299|    257|        goto done; /* found something */
 1300|    257|    }
 1301|       |
 1302|       |    /* Remaining case when implementation is an HDF5 file;
 1303|       |       search forward at starting at 512
 1304|       |       and doubling to see if we have HDF5 magic number */
 1305|     30|    {
 1306|     30|	size_t pos = 512L;
 1307|    251|        for(;;) {
 1308|    251|	    if((pos+MAGIC_NUMBER_LEN) > (unsigned long long)magicinfo.filelen)
  ------------------
  |  |   38|    251|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
  |  Branch (1308:9): [True: 28, False: 223]
  ------------------
 1309|     28|		{status = NC_ENOTNC; goto done;}
  ------------------
  |  |  473|     28|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1310|    223|            if((status = readmagic(&magicinfo,pos,magic)) != NC_NOERR)
  ------------------
  |  |  417|    223|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1310:16): [True: 0, False: 223]
  ------------------
 1311|      0|	        {status = NC_ENOTNC; goto done; }
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1312|    223|            NC_interpret_magic_number(magic,model);
 1313|    223|            if(model->impl == NC_FORMATX_NC4) break;
  ------------------
  |  |  248|    223|#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
  |  |  ------------------
  |  |  |  |  247|    223|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  |  |  ------------------
  ------------------
  |  Branch (1313:16): [True: 2, False: 221]
  ------------------
 1314|       |	    /* double and try again */
 1315|    221|	    pos = 2*pos;
 1316|    221|        }
 1317|     30|    }
 1318|    287|done:
 1319|    287|    closemagic(&magicinfo);
 1320|    287|    return check(status);
  ------------------
  |  |  106|    287|#define check(err) (err)
  ------------------
 1321|     30|}
dinfermodel.c:openmagic:
 1330|    287|{
 1331|    287|    int status = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
 1332|    287|    if(fIsSet(file->omode,NC_INMEMORY)) {
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 287, False: 0]
  |  |  ------------------
  ------------------
 1333|       |	/* Get its length */
 1334|    287|	NC_memio* meminfo = (NC_memio*)file->parameters;
 1335|    287|        assert(meminfo != NULL);
  ------------------
  |  Branch (1335:9): [True: 0, False: 287]
  |  Branch (1335:9): [True: 287, False: 0]
  ------------------
 1336|    287|	file->filelen = (long long)meminfo->size;
 1337|    287|	goto done;
 1338|    287|    }
 1339|      0|    if(file->uri != NULL) {
  ------------------
  |  Branch (1339:8): [True: 0, False: 0]
  ------------------
 1340|       |#ifdef NETCDF_ENABLE_BYTERANGE
 1341|       |	/* Construct a URL minus any fragment */
 1342|       |        file->curlurl = ncuribuild(file->uri,NULL,NULL,NCURISVC);
 1343|       |	/* Open the curl handle */
 1344|       |        if((status=nc_http_open(file->path, &file->state))) goto done;
 1345|       |	if((status=nc_http_size(file->state,&file->filelen))) goto done;
 1346|       |#else /*!BYTERANGE*/
 1347|      0|	{status = NC_ENOTBUILT;}
  ------------------
  |  |  557|      0|#define NC_ENOTBUILT     (-128)    /**< Attempt to use feature that was not turned on when netCDF was built. */
  ------------------
 1348|      0|#endif /*BYTERANGE*/
 1349|      0|	goto done;
 1350|      0|    }	
 1351|       |#ifdef USE_PARALLEL
 1352|       |    if (file->use_parallel) {
 1353|       |	int retval;
 1354|       |	MPI_Offset size;
 1355|       |        assert(file->parameters != NULL);
 1356|       |	if((retval = MPI_File_open(((NC_MPI_INFO*)file->parameters)->comm,
 1357|       |                                   (char*)file->path,MPI_MODE_RDONLY,
 1358|       |                                   ((NC_MPI_INFO*)file->parameters)->info,
 1359|       |                                   &file->fh)) != MPI_SUCCESS) {
 1360|       |#ifdef MPI_ERR_NO_SUCH_FILE
 1361|       |	    int errorclass;
 1362|       |	    MPI_Error_class(retval, &errorclass);
 1363|       |	    if (errorclass == MPI_ERR_NO_SUCH_FILE)
 1364|       |#ifdef NC_ENOENT
 1365|       |	        status = NC_ENOENT;
 1366|       |#else /*!NC_ENOENT*/
 1367|       |		status = errno;
 1368|       |#endif /*NC_ENOENT*/
 1369|       |	    else
 1370|       |#endif /*MPI_ERR_NO_SUCH_FILE*/
 1371|       |	        status = NC_EPARINIT;
 1372|       |	    file->fh = MPI_FILE_NULL;
 1373|       |	    goto done;
 1374|       |	}
 1375|       |	/* Get its length */
 1376|       |	if((retval=MPI_File_get_size(file->fh, &size)) != MPI_SUCCESS)
 1377|       |	    {status = NC_EPARINIT; goto done;}
 1378|       |	file->filelen = (long long)size;
 1379|       |	goto done;
 1380|       |    }
 1381|       |#endif /* USE_PARALLEL */
 1382|      0|    {
 1383|      0|        if (file->path == NULL || strlen(file->path) == 0)
  ------------------
  |  Branch (1383:13): [True: 0, False: 0]
  |  Branch (1383:35): [True: 0, False: 0]
  ------------------
 1384|      0|            {status = NC_EINVAL; goto done;}
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 1385|      0|        file->fp = NCfopen(file->path, "r");
  ------------------
  |  |  210|      0|#define NCfopen(path,flags) fopen((path),(flags))
  ------------------
 1386|      0|        if(file->fp == NULL)
  ------------------
  |  Branch (1386:12): [True: 0, False: 0]
  ------------------
 1387|      0|	    {status = errno; goto done;}
 1388|       |	/* Get its length */
 1389|      0|	{
 1390|      0|	    int fd = fileno(file->fp);
 1391|       |#ifdef _WIN32
 1392|       |	    __int64 len64 = _filelengthi64(fd);
 1393|       |	    if(len64 < 0)
 1394|       |		{status = errno; goto done;}
 1395|       |	    file->filelen = (long long)len64;
 1396|       |#else
 1397|      0|	    off_t size;
 1398|      0|	    size = lseek(fd, 0, SEEK_END);
 1399|      0|	    if(size == -1)
  ------------------
  |  Branch (1399:9): [True: 0, False: 0]
  ------------------
 1400|      0|		{status = errno; goto done;}
 1401|      0|		file->filelen = (long long)size;
 1402|      0|#endif
 1403|      0|	}
 1404|      0|        int retval2 = fseek(file->fp, 0L, SEEK_SET);        
 1405|      0|	    if(retval2 != 0)
  ------------------
  |  Branch (1405:9): [True: 0, False: 0]
  ------------------
 1406|      0|		{status = errno; goto done;}
 1407|      0|    }
 1408|    287|done:
 1409|    287|    return check(status);
  ------------------
  |  |  106|    287|#define check(err) (err)
  ------------------
 1410|      0|}
dinfermodel.c:readmagic:
 1414|    510|{
 1415|    510|    int status = NC_NOERR;
  ------------------
  |  |  417|    510|#define NC_NOERR        0          /**< No Error */
  ------------------
 1416|    510|    NCbytes* buf = ncbytesnew();
 1417|       |
 1418|    510|    memset(magic,0,MAGIC_NUMBER_LEN);
  ------------------
  |  |   38|    510|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
 1419|    510|    if(fIsSet(file->omode,NC_INMEMORY)) {
  ------------------
  |  |   15|    510|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 510, False: 0]
  |  |  ------------------
  ------------------
 1420|    510|	char* mempos;
 1421|    510|	NC_memio* meminfo = (NC_memio*)file->parameters;
 1422|    510|	if((pos + MAGIC_NUMBER_LEN) > meminfo->size)
  ------------------
  |  |   38|    510|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
  |  Branch (1422:5): [True: 0, False: 510]
  ------------------
 1423|      0|	    {status = NC_EINMEMORY; goto done;}
  ------------------
  |  |  565|      0|#define NC_EINMEMORY     (-135)    /**< In-memory file error */
  ------------------
 1424|    510|	mempos = ((char*)meminfo->memory) + pos;
 1425|    510|	memcpy((void*)magic,mempos,MAGIC_NUMBER_LEN);
  ------------------
  |  |   38|    510|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
 1426|       |#ifdef DEBUG
 1427|       |	printmagic("XXX: readmagic",magic,file);
 1428|       |#endif
 1429|    510|    } else if(file->uri != NULL) {
  ------------------
  |  Branch (1429:15): [True: 0, False: 0]
  ------------------
 1430|       |#ifdef NETCDF_ENABLE_BYTERANGE
 1431|       |        size64_t start = (size64_t)pos;
 1432|       |        size64_t count = MAGIC_NUMBER_LEN;
 1433|       |        status = nc_http_read(file->state, start, count, buf);
 1434|       |        if (status == NC_NOERR) {
 1435|       |            if (ncbyteslength(buf) != count)
 1436|       |                status = NC_EINVAL;
 1437|       |            else
 1438|       |                memcpy(magic, ncbytescontents(buf), count);
 1439|       |        }
 1440|       |#endif
 1441|      0|    } else {
 1442|       |#ifdef USE_PARALLEL
 1443|       |        if (file->use_parallel) {
 1444|       |	    MPI_Status mstatus;
 1445|       |	    int retval;
 1446|       |	    if((retval = MPI_File_read_at_all(file->fh, pos, magic,
 1447|       |			    MAGIC_NUMBER_LEN, MPI_CHAR, &mstatus)) != MPI_SUCCESS)
 1448|       |	        {status = NC_EPARINIT; goto done;}
 1449|       |        }
 1450|       |        else
 1451|       |#endif /* USE_PARALLEL */
 1452|      0|        { /* Ordinary read */
 1453|      0|            long i;
 1454|      0|            i = fseek(file->fp, (long)pos, SEEK_SET);
 1455|      0|            if (i < 0) { status = errno; goto done; }
  ------------------
  |  Branch (1455:17): [True: 0, False: 0]
  ------------------
 1456|      0|            ncbytessetlength(buf, 0);
 1457|      0|            if ((status = NC_readfileF(file->fp, buf, MAGIC_NUMBER_LEN))) goto done;
  ------------------
  |  |   38|      0|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
  |  Branch (1457:17): [True: 0, False: 0]
  ------------------
 1458|      0|            memcpy(magic, ncbytescontents(buf), MAGIC_NUMBER_LEN);
  ------------------
  |  |   56|      0|#define ncbytescontents(bb) (((bb)!=NULL && (bb)->content!=NULL)?(bb)->content:(char*)"")
  |  |  ------------------
  |  |  |  Branch (56:31): [True: 0, False: 0]
  |  |  |  Branch (56:45): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                          memcpy(magic, ncbytescontents(buf), MAGIC_NUMBER_LEN);
  ------------------
  |  |   38|      0|#define MAGIC_NUMBER_LEN ((unsigned long long)8)
  ------------------
 1459|      0|        }
 1460|      0|    }
 1461|       |
 1462|    510|done:
 1463|    510|    ncbytesfree(buf);
 1464|    510|    if(file && file->fp) clearerr(file->fp);
  ------------------
  |  Branch (1464:8): [True: 510, False: 0]
  |  Branch (1464:16): [True: 0, False: 510]
  ------------------
 1465|    510|    return check(status);
  ------------------
  |  |  106|    510|#define check(err) (err)
  ------------------
 1466|    510|}
dinfermodel.c:NC_interpret_magic_number:
 1521|    510|{
 1522|    510|    int status = NC_NOERR;
  ------------------
  |  |  417|    510|#define NC_NOERR        0          /**< No Error */
  ------------------
 1523|    510|    int tmpimpl = 0;
 1524|       |    /* Look at the magic number - save any UDF format on entry */
 1525|    510|    if(model->impl >= NC_FORMATX_UDF0 && model->impl <= NC_FORMATX_UDF1)
  ------------------
  |  |  259|  1.02k|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
                  if(model->impl >= NC_FORMATX_UDF0 && model->impl <= NC_FORMATX_UDF1)
  ------------------
  |  |  260|      0|#define NC_FORMATX_UDF1      (9)  /**< User-defined format 1 */
  ------------------
  |  Branch (1525:8): [True: 0, False: 510]
  |  Branch (1525:42): [True: 0, False: 0]
  ------------------
 1526|      0|        tmpimpl = model->impl;
 1527|    510|    else if(model->impl >= NC_FORMATX_UDF2 && model->impl <= NC_FORMATX_UDF9)
  ------------------
  |  |  265|  1.02k|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
                  else if(model->impl >= NC_FORMATX_UDF2 && model->impl <= NC_FORMATX_UDF9)
  ------------------
  |  |  272|      0|#define NC_FORMATX_UDF9      (18) /**< User-defined format 9 */
  ------------------
  |  Branch (1527:13): [True: 0, False: 510]
  |  Branch (1527:47): [True: 0, False: 0]
  ------------------
 1528|      0|        tmpimpl = model->impl;
 1529|       |
 1530|       |    /* Use the complete magic number string for HDF5 */
 1531|    510|    if(memcmp(magic,HDF5_SIGNATURE,sizeof(HDF5_SIGNATURE))==0) {
  ------------------
  |  Branch (1531:8): [True: 2, False: 508]
  ------------------
 1532|      2|	model->impl = NC_FORMATX_NC4;
  ------------------
  |  |  248|      2|#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
  |  |  ------------------
  |  |  |  |  247|      2|#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
  |  |  ------------------
  ------------------
 1533|      2|	model->format = NC_FORMAT_NETCDF4;
  ------------------
  |  |  216|      2|#define NC_FORMAT_NETCDF4         (3)
  ------------------
 1534|      2|	goto done;
 1535|      2|    }
 1536|    508|    if(magic[0] == '\016' && magic[1] == '\003'
  ------------------
  |  Branch (1536:8): [True: 24, False: 484]
  |  Branch (1536:30): [True: 16, False: 8]
  ------------------
 1537|     16|              && magic[2] == '\023' && magic[3] == '\001') {
  ------------------
  |  Branch (1537:18): [True: 8, False: 8]
  |  Branch (1537:40): [True: 0, False: 8]
  ------------------
 1538|      0|	model->impl = NC_FORMATX_NC_HDF4;
  ------------------
  |  |  249|      0|#define NC_FORMATX_NC_HDF4   (3) /**< netCDF-4 subset of HDF4 */
  ------------------
 1539|      0|	model->format = NC_FORMAT_NETCDF4;
  ------------------
  |  |  216|      0|#define NC_FORMAT_NETCDF4         (3)
  ------------------
 1540|      0|	goto done;
 1541|      0|    }
 1542|    508|    if(magic[0] == 'C' && magic[1] == 'D' && magic[2] == 'F') {
  ------------------
  |  Branch (1542:8): [True: 327, False: 181]
  |  Branch (1542:27): [True: 314, False: 13]
  |  Branch (1542:46): [True: 301, False: 13]
  ------------------
 1543|    301|        if(magic[3] == '\001') {
  ------------------
  |  Branch (1543:12): [True: 99, False: 202]
  ------------------
 1544|     99|	    model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|     99|#define NC_FORMATX_NC3       (1)
  ------------------
 1545|     99|	    model->format = NC_FORMAT_CLASSIC;
  ------------------
  |  |  208|     99|#define NC_FORMAT_CLASSIC         (1)
  ------------------
 1546|     99|	    goto done;
 1547|     99|	}
 1548|    202|        if(magic[3] == '\002') {
  ------------------
  |  Branch (1548:12): [True: 101, False: 101]
  ------------------
 1549|    101|	    model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|    101|#define NC_FORMATX_NC3       (1)
  ------------------
 1550|    101|	    model->format = NC_FORMAT_64BIT_OFFSET;
  ------------------
  |  |  214|    101|#define NC_FORMAT_64BIT_OFFSET    (2)
  ------------------
 1551|    101|	    goto done;
 1552|    101|        }
 1553|    101|        if(magic[3] == '\005') {
  ------------------
  |  Branch (1553:12): [True: 84, False: 17]
  ------------------
 1554|     84|	  model->impl = NC_FORMATX_NC3;
  ------------------
  |  |  246|     84|#define NC_FORMATX_NC3       (1)
  ------------------
 1555|     84|	  model->format = NC_FORMAT_64BIT_DATA;
  ------------------
  |  |  218|     84|#define NC_FORMAT_64BIT_DATA      (5)
  ------------------
 1556|     84|	  goto done;
 1557|     84|	}
 1558|    101|     }
 1559|       |     /* No match  */
 1560|    224|     if (!tmpimpl) 
  ------------------
  |  Branch (1560:10): [True: 224, False: 0]
  ------------------
 1561|    224|         status = NC_ENOTNC;         
  ------------------
  |  |  473|    224|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1562|       |
 1563|    224|     goto done;
 1564|       |
 1565|    510|done:
 1566|       |     /* if model->impl was any UDF format (0-9) on entry, make it so on exit */
 1567|    510|     if(tmpimpl)
  ------------------
  |  Branch (1567:9): [True: 0, False: 510]
  ------------------
 1568|      0|         model->impl = tmpimpl;
 1569|       |     /* if this is a UDF magic_number update the model->impl */
 1570|  5.61k|     for(int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
  ------------------
  |  |  199|  5.61k|#define NC_MAX_UDF_FORMATS 10
  ------------------
  |  Branch (1570:21): [True: 5.10k, False: 510]
  ------------------
 1571|  5.10k|         if (strlen(UDF_magic_numbers[i]) && !strncmp(UDF_magic_numbers[i], magic,
  ------------------
  |  Branch (1571:14): [True: 0, False: 5.10k]
  |  Branch (1571:46): [True: 0, False: 0]
  ------------------
 1572|      0|                                                       strlen(UDF_magic_numbers[i])))
 1573|      0|         {
 1574|      0|             int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  259|      0|#define NC_FORMATX_UDF0      (8)  /**< User-defined format 0 */
  ------------------
                           int formatx = (i <= 1) ? (NC_FORMATX_UDF0 + i) : (NC_FORMATX_UDF2 + i - 2);
  ------------------
  |  |  265|      0|#define NC_FORMATX_UDF2      (11) /**< User-defined format 2 */
  ------------------
  |  Branch (1574:28): [True: 0, False: 0]
  ------------------
 1575|      0|             model->impl = formatx;
 1576|      0|             status = NC_NOERR;
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
 1577|      0|             break;
 1578|      0|         }
 1579|  5.10k|     }    
 1580|       |
 1581|    510|     return check(status);
  ------------------
  |  |  106|    510|#define check(err) (err)
  ------------------
 1582|    508|}
dinfermodel.c:closemagic:
 1479|    287|{
 1480|    287|    int status = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
 1481|       |
 1482|    287|    if(fIsSet(file->omode,NC_INMEMORY)) {
  ------------------
  |  |   15|    287|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 287, False: 0]
  |  |  ------------------
  ------------------
 1483|       |	/* noop */
 1484|    287|    } else if(file->uri != NULL) {
  ------------------
  |  Branch (1484:15): [True: 0, False: 0]
  ------------------
 1485|       |#ifdef NETCDF_ENABLE_BYTERANGE
 1486|       |	    status = nc_http_close(file->state);
 1487|       |#endif
 1488|      0|	    nullfree(file->curlurl);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1489|      0|    } else {
 1490|       |#ifdef USE_PARALLEL
 1491|       |        if (file->use_parallel) {
 1492|       |	    int retval;
 1493|       |	    if(file->fh != MPI_FILE_NULL
 1494|       |	       && (retval = MPI_File_close(&file->fh)) != MPI_SUCCESS)
 1495|       |		    {status = NC_EPARINIT; return status;}
 1496|       |        } else
 1497|       |#endif
 1498|      0|        {
 1499|      0|	    if(file->fp) fclose(file->fp);
  ------------------
  |  Branch (1499:9): [True: 0, False: 0]
  ------------------
 1500|      0|        }
 1501|      0|    }
 1502|    287|    return status;
 1503|    287|}
dinfermodel.c:isdaoscontainer:
 1596|    287|{
 1597|    287|    int stat = NC_ENOTNC; /* default is that this is not a DAOS container */
  ------------------
  |  |  473|    287|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1598|    287|#ifndef _WIN32
 1599|       |#ifdef USE_HDF5
 1600|       |#if H5_VERSION_GE(1,12,0)
 1601|       |    htri_t accessible;
 1602|       |    hid_t fapl_id;
 1603|       |    int rc;
 1604|       |    /* Check for a DAOS container */
 1605|       |    if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {stat = NC_EHDFERR; goto done;}
 1606|       |    H5Pset_fapl_sec2(fapl_id);
 1607|       |    accessible = H5Fis_accessible(path, fapl_id);
 1608|       |    H5Pclose(fapl_id); /* Ignore any error */
 1609|       |    rc = 0;
 1610|       |    if(accessible > 0) {
 1611|       |#ifdef HAVE_SYS_XATTR_H
 1612|       |	ssize_t xlen;
 1613|       |	xlen = LISTXATTR(path,NULL,0);
 1614|       |        if(xlen > 0) {
 1615|       |  	    char* xlist = NULL;
 1616|       |	    char* xvalue = NULL;
 1617|       |	    char* p;
 1618|       |	    char* endp;
 1619|       |	    if((xlist = (char*)calloc(1,(size_t)xlen))==NULL)
 1620|       |		{stat = NC_ENOMEM; goto done;}
 1621|       |	    (void)LISTXATTR(path,xlist,xlen);
 1622|       |	    p = xlist; endp = p + xlen; /* delimit names */
 1623|       |	    /* walk the list of xattr names */
 1624|       |	    for(;p < endp;p += (strlen(p)+1)) {
 1625|       |		/* The popen version looks for the string ".daos";
 1626|       |                   It would be nice if we know whether that occurred
 1627|       |		   int the xattr's name or it value.
 1628|       |		   Oh well, we will do the general search */
 1629|       |		/* Look for '.daos' in the key */
 1630|       |		if(strstr(p,".daos") != NULL) {rc = 1; break;} /* success */
 1631|       |		/* Else get the p'th xattr's value size */
 1632|       |		xlen = GETXATTR(path,p,NULL,0);
 1633|       |		if((xvalue = (char*)calloc(1,(size_t)xlen))==NULL)
 1634|       |		    {stat = NC_ENOMEM; goto done;}
 1635|       |		/* Read the value */
 1636|       |		(void)GETXATTR(path,p,xvalue,xlen);
 1637|       |		/* Look for '.daos' in the value */
 1638|       |		if(strstr(xvalue,".daos") != NULL) {rc = 1; break;} /* success */
 1639|       |	    }
 1640|       |        }
 1641|       |#else /*!HAVE_SYS_XATTR_H*/
 1642|       |
 1643|       |#ifdef HAVE_GETFATTR
 1644|       |	{
 1645|       |	    FILE *fp;
 1646|       |	    char cmd[4096];
 1647|       |	    memset(cmd,0,sizeof(cmd));
 1648|       |      snprintf(cmd,sizeof(cmd),"getfattr \"%s\" | grep -c '.daos'",path);
 1649|       |      fp = popen(cmd, "r");
 1650|       |      if(fp != NULL) {
 1651|       |        fscanf(fp, "%d", &rc);
 1652|       |        pclose(fp);
 1653|       |	    } else {
 1654|       |    		rc = 0; /* Cannot test; assume not DAOS */
 1655|       |	    }
 1656|       |	}
 1657|       |    }
 1658|       |#else /*!HAVE_GETFATTR*/
 1659|       |    /* We just can't test for DAOS container.*/
 1660|       |    rc = 0;
 1661|       |#endif /*HAVE_GETFATTR*/
 1662|       |#endif /*HAVE_SYS_XATTR_H*/
 1663|       |    }
 1664|       |    /* Test for DAOS container */
 1665|       |    stat = (rc == 1 ? NC_NOERR : NC_ENOTNC);
 1666|       |done:
 1667|       |#endif
 1668|       |#endif
 1669|    287|#endif
 1670|       |    errno = 0; /* reset */
 1671|    287|    return stat;
 1672|    287|}

nc_strlcat:
   89|      1|{
   90|      1|	const char *odst = dst;
   91|      1|	const char *osrc = src;
   92|      1|	size_t n = dsize;
   93|      1|	size_t dlen;
   94|       |
   95|       |	/* Find the end of dst and adjust bytes left but don't go past end. */
   96|      1|	while (n-- != 0 && *dst != '\0')
  ------------------
  |  Branch (96:9): [True: 1, False: 0]
  |  Branch (96:21): [True: 0, False: 1]
  ------------------
   97|      0|		dst++;
   98|      1|	dlen = dst - odst;
   99|      1|	n = dsize - dlen;
  100|       |
  101|      1|	if (n-- == 0)
  ------------------
  |  Branch (101:6): [True: 0, False: 1]
  ------------------
  102|      0|		return(dlen + strlen(src));
  103|      6|	while (*src != '\0') {
  ------------------
  |  Branch (103:9): [True: 5, False: 1]
  ------------------
  104|      5|		if (n != 0) {
  ------------------
  |  Branch (104:7): [True: 5, False: 0]
  ------------------
  105|      5|			*dst++ = *src;
  106|      5|			n--;
  107|      5|		}
  108|      5|		src++;
  109|      5|	}
  110|      1|	*dst = '\0';
  111|       |
  112|      1|	return(dlen + (src - osrc));	/* count does not include NUL */
  113|      1|}

NC_compute_alignments:
  149|      1|{
  150|      1|    if(NC_alignments_computed) return;
  ------------------
  |  Branch (150:8): [True: 0, False: 1]
  ------------------
  151|       |    /* Compute the alignments for all the common C data types*/
  152|       |    /* First for the struct*/
  153|       |    /* initialize*/
  154|      1|    memset((void*)&set,0,sizeof(set));
  155|      1|    memset((void*)vec,0,sizeof(vec));
  156|       |
  157|      1|    COMP_ALIGNMENT(set.charalign,char);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  158|      1|    COMP_ALIGNMENT(set.ucharalign,unsigned char);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  159|      1|    COMP_ALIGNMENT(set.shortalign,short);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  160|      1|    COMP_ALIGNMENT(set.ushortalign,unsigned short);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  161|      1|    COMP_ALIGNMENT(set.intalign,int);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  162|      1|    COMP_ALIGNMENT(set.uintalign,unsigned int);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  163|      1|    COMP_ALIGNMENT(set.longlongalign,long long);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  164|      1|    COMP_ALIGNMENT(set.ulonglongalign,unsigned long long);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  165|      1|    COMP_ALIGNMENT(set.floatalign,float);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  166|      1|    COMP_ALIGNMENT(set.doublealign,double);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  167|      1|    COMP_ALIGNMENT(set.ptralign,void*);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  168|      1|    COMP_ALIGNMENT(set.ncvlenalign,nc_vlen_t);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  169|       |
  170|       |    /* Then the vector*/
  171|      1|    COMP_ALIGNMENT(vec[NC_CHARINDEX],char);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  172|      1|    COMP_ALIGNMENT(vec[NC_UCHARINDEX],unsigned char); 
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  173|      1|    COMP_ALIGNMENT(vec[NC_SHORTINDEX],short);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  174|      1|    COMP_ALIGNMENT(vec[NC_USHORTINDEX],unsigned short);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  175|      1|    COMP_ALIGNMENT(vec[NC_INTINDEX],int);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  176|      1|    COMP_ALIGNMENT(vec[NC_UINTINDEX],unsigned int);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  177|      1|    COMP_ALIGNMENT(vec[NC_LONGLONGINDEX],long long);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  178|      1|    COMP_ALIGNMENT(vec[NC_ULONGLONGINDEX],unsigned long long);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  179|      1|    COMP_ALIGNMENT(vec[NC_FLOATINDEX],float);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  180|      1|    COMP_ALIGNMENT(vec[NC_DOUBLEINDEX],double);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  181|      1|    COMP_ALIGNMENT(vec[NC_PTRINDEX],void*);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  182|      1|    COMP_ALIGNMENT(vec[NC_NCVLENINDEX],nc_vlen_t);
  ------------------
  |  |   89|      1|#define COMP_ALIGNMENT(DST,TYPE)  {\
  |  |   90|      1|    struct {char f1; TYPE x;} tmp; \
  |  |   91|      1|    DST.type_name = #TYPE ;        \
  |  |   92|      1|    DST.alignment = (size_t)((char*)(&(tmp.x)) - (char*)(&tmp));}
  ------------------
  183|      1|    NC_alignments_computed = 1;
  184|      1|}

NCpathcanonical:
  186|      1|{
  187|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  188|      1|    char* canon = NULL;
  189|      1|    struct Path path = empty;
  190|       |
  191|      1|    if(srcpath == NULL) goto done;
  ------------------
  |  Branch (191:8): [True: 0, False: 1]
  ------------------
  192|       |
  193|      1|    if(!pathinitialized) pathinit();
  ------------------
  |  Branch (193:8): [True: 1, False: 0]
  ------------------
  194|       |
  195|       |    /* parse the src path */
  196|      1|    if((stat = parsepath(srcpath,&path))) {goto done;}
  ------------------
  |  Branch (196:8): [True: 0, False: 1]
  ------------------
  197|       |
  198|       |    /* Convert to cygwin form */
  199|      1|    if((stat = unparsepath(&path,&canon, NCPD_CYGWIN)))
  ------------------
  |  |  241|      1|#define NCPD_CYGWIN 3
  ------------------
  |  Branch (199:8): [True: 0, False: 1]
  ------------------
  200|      0|        goto done;
  201|       |
  202|      1|    if(canonp) {*canonp = canon; canon = NULL;}
  ------------------
  |  Branch (202:8): [True: 1, False: 0]
  ------------------
  203|       |
  204|      1|done:
  205|       |    nullfree(canon);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  206|      1|    clearPath(&path);
  207|      1|    return stat;
  208|      1|}
NCgetlocalpathkind:
 1199|      3|{
 1200|      3|    int kind = NCPD_UNKNOWN;
  ------------------
  |  |  238|      3|#define NCPD_UNKNOWN 0
  ------------------
 1201|      3|    if(platform) return platform;
  ------------------
  |  Branch (1201:8): [True: 0, False: 3]
  ------------------
 1202|       |#ifdef __CYGWIN__
 1203|       |	kind = NCPD_CYGWIN;
 1204|       |#elif defined _MSC_VER /* not _WIN32 */
 1205|       |	kind = NCPD_WIN;
 1206|       |#elif defined __MSYS__
 1207|       |	kind = NCPD_MSYS;
 1208|       |#elif defined __MINGW32__
 1209|       |	kind = NCPD_WIN; /* alias */
 1210|       |#else
 1211|      3|	kind = NCPD_NIX;
  ------------------
  |  |  239|      3|#define NCPD_NIX 1
  ------------------
 1212|      3|#endif
 1213|      3|    return kind;
 1214|      3|}
dpathmgr.c:pathinit:
  287|      1|{
  288|      1|    if(pathinitialized) return;
  ------------------
  |  Branch (288:8): [True: 0, False: 1]
  ------------------
  289|      1|    pathinitialized = 1; /* avoid recursion */
  290|       |
  291|       |    /* Check for path debug env vars */
  292|      1|    if(pathdebug < 0) {
  ------------------
  |  Branch (292:8): [True: 1, False: 0]
  ------------------
  293|      1|	const char* s = getenv("NCPATHDEBUG");
  294|      1|        pathdebug = (s == NULL ? 0 : 1);
  ------------------
  |  Branch (294:22): [True: 1, False: 0]
  ------------------
  295|      1|    }
  296|      1|    (void)getwdpath();
  297|       |
  298|       |#ifdef _WIN32
  299|       |    /* Get the current code page */
  300|       |    acp = GetACP();
  301|       |#endif
  302|       |
  303|      1|    memset(&mountpoint,0,sizeof(mountpoint));
  304|       |#ifdef REGEDIT
  305|       |    { /* See if we can get the MSYS2 prefix from the registry */
  306|       |	if(getmountpoint(mountpoint.prefix,sizeof(mountpoint.prefix)))
  307|       |	    goto next;
  308|       |	mountpoint.defined = 1;
  309|       |if(pathdebug > 0)
  310|       |  fprintf(stderr,">>>> registry: mountprefix=|%s|\n",mountpoint.prefix);
  311|       |    }
  312|       |next:
  313|       |#endif
  314|      1|    if(!mountpoint.defined) {
  ------------------
  |  Branch (314:8): [True: 1, False: 0]
  ------------------
  315|      1|	mountpoint.prefix[0] = '\0';
  316|       |        /* See if MSYS2_PREFIX is defined */
  317|      1|        if(getenv("MSYS2_PREFIX")) {
  ------------------
  |  Branch (317:12): [True: 0, False: 1]
  ------------------
  318|      0|	    const char* m2 = getenv("MSYS2_PREFIX");
  319|      0|	    mountpoint.prefix[0] = '\0';
  320|      0|            strlcat(mountpoint.prefix,m2,sizeof(mountpoint.prefix));
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  321|      0|	}
  322|      1|        if(pathdebug > 0) {
  ------------------
  |  Branch (322:12): [True: 0, False: 1]
  ------------------
  323|      0|            fprintf(stderr,">>>> prefix: mountprefix=|%s|\n",mountpoint.prefix);
  324|      0|        }
  325|      1|    }
  326|      1|    if(mountpoint.defined) {
  ------------------
  |  Branch (326:8): [True: 0, False: 1]
  ------------------
  327|      0|	char* p;
  328|      0|	size_t size = strlen(mountpoint.prefix);
  329|      0|        for(p=mountpoint.prefix;*p;p++) {if(*p == '\\') *p = '/';} /* forward slash*/
  ------------------
  |  Branch (329:33): [True: 0, False: 0]
  |  Branch (329:45): [True: 0, False: 0]
  ------------------
  330|      0|	if(mountpoint.prefix[size-1] == '/') {
  ------------------
  |  Branch (330:5): [True: 0, False: 0]
  ------------------
  331|      0|	    size--;
  332|      0|	    mountpoint.prefix[size] = '\0'; /* no trailing slash */
  333|      0|	}
  334|       |	/* Finally extract the drive letter, if any */
  335|       |	/* assumes mount prefix is in windows form */
  336|      0|	mountpoint.drive = 0;
  337|      0|	if(strchr(windrive,mountpoint.prefix[0]) != NULL
  ------------------
  |  Branch (337:5): [True: 0, False: 0]
  ------------------
  338|      0|           && mountpoint.prefix[1] == ':') {
  ------------------
  |  Branch (338:15): [True: 0, False: 0]
  ------------------
  339|      0|	    char* q = mountpoint.prefix;
  340|      0|	    mountpoint.drive = mountpoint.prefix[0];
  341|       |	    /* Shift prefix left 2 chars */
  342|      0|            for(p=mountpoint.prefix+2;*p;p++) {*q++ = *p;}
  ------------------
  |  Branch (342:39): [True: 0, False: 0]
  ------------------
  343|      0|	    *q = '\0';
  344|      0|	}
  345|      0|    }
  346|       |
  347|       |    /* Check for the MSYS_NO_PATHCONV env var */
  348|      1|    {
  349|      1|	const char* s = getenv("MSYS_NO_PATHCONV");
  350|      1|	env_msys_no_pathconv = (s == NULL ? 0 : 1);
  ------------------
  |  Branch (350:26): [True: 1, False: 0]
  ------------------
  351|      1|    }
  352|       |
  353|      1|    pathinitialized = 1;
  354|      1|}
dpathmgr.c:getwdpath:
 1153|      1|{
 1154|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
 1155|      1|    char* path = NULL;
 1156|       |
 1157|      1|    wdprefix[0] = '\0';
 1158|       |#ifdef _WIN32
 1159|       |    {
 1160|       |        wchar_t* wcwd = NULL;
 1161|       |        wchar_t* wpath = NULL;
 1162|       |        wcwd = (wchar_t*)calloc(8192, sizeof(wchar_t));
 1163|       |        wpath = _wgetcwd(wcwd, 8192);
 1164|       |        path = NULL;
 1165|       |        stat = wide2utf8(wpath, &path);
 1166|       |        nullfree(wcwd);
 1167|       |        if (stat) return stat;
 1168|       |	strlcat(wdprefix,path,sizeof(wdprefix));
 1169|       |    }
 1170|       |#else
 1171|      1|    {
 1172|      1|        getcwd(wdprefix, sizeof(wdprefix));
 1173|      1|    }
 1174|      1|#endif
 1175|      1|    nullfree(path); path = NULL;
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1176|      1|    return stat;
 1177|      1|}
dpathmgr.c:clearPath:
  358|      1|{
  359|      1|    nullfree(path->path);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  360|       |    path->path = NULL;
  361|      1|}
dpathmgr.c:parsepath:
  815|      1|{
  816|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  817|      1|    char* tmp1 = NULL;
  818|      1|    size_t len;
  819|      1|    char* p;
  820|      1|    int platform = NCgetlocalpathkind();
  821|       |
  822|      1|    assert(path);
  ------------------
  |  Branch (822:5): [True: 0, False: 1]
  |  Branch (822:5): [True: 1, False: 0]
  ------------------
  823|      1|    memset(path,0,sizeof(struct Path));
  824|       |
  825|      1|    if(inpath == NULL) goto done; /* defensive driving */
  ------------------
  |  Branch (825:8): [True: 0, False: 1]
  ------------------
  826|      1|    if(!pathinitialized) pathinit();
  ------------------
  |  Branch (826:8): [True: 0, False: 1]
  ------------------
  827|       |
  828|       |#if 0
  829|       |    /* Convert to UTF8 */
  830|       |    if((stat = NCpath2utf8(inpath,&tmp1))) goto done;
  831|       |#else
  832|      1|    tmp1 = strdup(inpath);
  833|      1|#endif
  834|       |    /* Convert to forward slash to simplify later code */
  835|      6|    for(p=tmp1;*p;p++) {if(*p == '\\') *p = '/';}
  ------------------
  |  Branch (835:16): [True: 5, False: 1]
  |  Branch (835:28): [True: 0, False: 5]
  ------------------
  836|       |
  837|       |    /* parse all paths to 2 parts:
  838|       |	1. drive letter (optional)
  839|       |	2. path after drive letter
  840|       |    */
  841|       |
  842|      1|    len = strlen(tmp1);
  843|       |
  844|       |    /* 1. look for Windows network path //...; drive letter is faked using
  845|       |          the character '/' */
  846|      1|    if(len >= 2 && (tmp1[0] == '/') && (tmp1[1] == '/')) {
  ------------------
  |  Branch (846:8): [True: 1, False: 0]
  |  Branch (846:20): [True: 1, False: 0]
  |  Branch (846:40): [True: 0, False: 1]
  ------------------
  847|      0|	path->drive = netdrive;
  848|       |	/* Remainder */
  849|      0|	if(tmp1[2] == '\0')
  ------------------
  |  Branch (849:5): [True: 0, False: 0]
  ------------------
  850|      0|	    path->path = NULL;
  851|      0|	else
  852|      0|	    path->path = strdup(tmp1+1); /*keep first '/' */
  853|      0|	if(path == NULL)
  ------------------
  |  Branch (853:5): [True: 0, False: 0]
  ------------------
  854|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  855|      0|	path->kind = NCPD_WIN;
  ------------------
  |  |  242|      0|#define NCPD_WIN 4
  ------------------
  856|      0|    }
  857|       |    /* 2. Look for leading /cygdrive/D where D is a single-char drive letter */
  858|      1|    else if(len >= (cdlen+1)
  ------------------
  |  Branch (858:13): [True: 0, False: 1]
  ------------------
  859|      0|	&& memcmp(tmp1,"/cygdrive/",cdlen)==0
  ------------------
  |  Branch (859:5): [True: 0, False: 0]
  ------------------
  860|      0|	&& strchr(windrive,tmp1[cdlen]) != NULL
  ------------------
  |  Branch (860:5): [True: 0, False: 0]
  ------------------
  861|      0|	&& (tmp1[cdlen+1] == '/'
  ------------------
  |  Branch (861:6): [True: 0, False: 0]
  ------------------
  862|      0|	    || tmp1[cdlen+1] == '\0')) {
  ------------------
  |  Branch (862:9): [True: 0, False: 0]
  ------------------
  863|       |	/* Assume this is a cygwin path */
  864|      0|	path->drive = tmp1[cdlen];
  865|       |	/* Remainder */
  866|      0|	if(tmp1[cdlen+1] == '\0')
  ------------------
  |  Branch (866:5): [True: 0, False: 0]
  ------------------
  867|      0|	    path->path = NULL;
  868|      0|	else
  869|      0|	    path->path = strdup(tmp1+cdlen+1);
  870|      0|	if(path == NULL)
  ------------------
  |  Branch (870:5): [True: 0, False: 0]
  ------------------
  871|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  872|      0|	path->kind = NCPD_CYGWIN;
  ------------------
  |  |  241|      0|#define NCPD_CYGWIN 3
  ------------------
  873|      0|    }
  874|       |    /* 4. Look for windows path:  D:/... where D is a single-char
  875|       |          drive letter */
  876|      1|    else if(len >= 2
  ------------------
  |  Branch (876:13): [True: 1, False: 0]
  ------------------
  877|      1|	&& strchr(windrive,tmp1[0]) != NULL
  ------------------
  |  Branch (877:5): [True: 1, False: 0]
  ------------------
  878|      1|	&& tmp1[1] == ':'
  ------------------
  |  Branch (878:5): [True: 0, False: 1]
  ------------------
  879|      0|	&& (tmp1[2] == '\0' || tmp1[2] == '/')) {
  ------------------
  |  Branch (879:6): [True: 0, False: 0]
  |  Branch (879:25): [True: 0, False: 0]
  ------------------
  880|       |	/* Assume this is a windows path */
  881|      0|	path->drive = tmp1[0];
  882|       |	/* Remainder */
  883|      0|	if(tmp1[2] == '\0')
  ------------------
  |  Branch (883:5): [True: 0, False: 0]
  ------------------
  884|      0|	    path->path = NULL;
  885|      0|	else
  886|      0|	    path->path = strdup(tmp1+2);
  887|      0|	if(path == NULL)
  ------------------
  |  Branch (887:5): [True: 0, False: 0]
  ------------------
  888|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  889|      0|	path->kind = NCPD_WIN; /* Might be MINGW */
  ------------------
  |  |  242|      0|#define NCPD_WIN 4
  ------------------
  890|      0|    }
  891|       |    /* The /D/x/y/z MSYS paths cause much parsing confusion.
  892|       |       So only use it if the current platform is msys and MSYS_NO_PATHCONV
  893|       |       is undefined and NCpathsetplatform was called. Otherwise use windows
  894|       |       paths.
  895|       |    */
  896|       |    /* X. look for MSYS path /D/... */
  897|      1|    else if(platform == NCPD_MSYS
  ------------------
  |  |  240|      2|#define NCPD_MSYS 2
  ------------------
  |  Branch (897:13): [True: 0, False: 1]
  ------------------
  898|      0|	&& !env_msys_no_pathconv
  ------------------
  |  Branch (898:5): [True: 0, False: 0]
  ------------------
  899|      0|        && len >= 2
  ------------------
  |  Branch (899:12): [True: 0, False: 0]
  ------------------
  900|      0|	&& (tmp1[0] == '/')
  ------------------
  |  Branch (900:5): [True: 0, False: 0]
  ------------------
  901|      0|	&& strchr(windrive,tmp1[1]) != NULL
  ------------------
  |  Branch (901:5): [True: 0, False: 0]
  ------------------
  902|      0|	&& (tmp1[2] == '/' || tmp1[2] == '\0')) {
  ------------------
  |  Branch (902:6): [True: 0, False: 0]
  |  Branch (902:24): [True: 0, False: 0]
  ------------------
  903|       |	/* Assume this is that stupid MSYS path format */
  904|      0|	path->drive = tmp1[1];
  905|       |	/* Remainder */
  906|      0|	if(tmp1[2] == '\0')
  ------------------
  |  Branch (906:5): [True: 0, False: 0]
  ------------------
  907|      0|	    path->path = NULL;
  908|      0|	else
  909|      0|	    path->path = strdup(tmp1+2);
  910|      0|	if(path == NULL)
  ------------------
  |  Branch (910:5): [True: 0, False: 0]
  ------------------
  911|      0|	    {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  912|      0|	path->kind = NCPD_MSYS;
  ------------------
  |  |  240|      0|#define NCPD_MSYS 2
  ------------------
  913|      0|    }
  914|       |    /* 5. look for *nix* path; note this includes MSYS2 paths as well */
  915|      1|    else if(len >= 1 && tmp1[0] == '/') {
  ------------------
  |  Branch (915:13): [True: 1, False: 0]
  |  Branch (915:25): [True: 1, False: 0]
  ------------------
  916|       |	/* Assume this is a *nix path */
  917|      1|	path->drive = 0; /* no drive letter */
  918|       | 	/* Remainder */
  919|      1|	path->path = tmp1; tmp1 = NULL;
  920|      1|	path->kind = NCPD_NIX;
  ------------------
  |  |  239|      1|#define NCPD_NIX 1
  ------------------
  921|      1|    } else {/* 6. Relative path of unknown type */
  922|      0|	path->kind = NCPD_REL;
  ------------------
  |  |  244|      0|#define NCPD_REL 6 /* actual kind is unknown */
  ------------------
  923|      0|	path->path = tmp1; tmp1 = NULL;
  924|      0|    }
  925|       |
  926|      1|done:
  927|      1|    nullfree(tmp1);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  928|      1|    if(stat) {clearPath(path);}
  ------------------
  |  Branch (928:8): [True: 0, False: 1]
  ------------------
  929|      1|    return stat;
  930|      1|}
dpathmgr.c:unparsepath:
  934|      1|{
  935|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  936|      1|    size_t len;
  937|      1|    char* path = NULL;
  938|      1|    char sdrive[4] = "\0\0\0\0";
  939|      1|    char* p = NULL;
  940|      1|    int cygspecial = 0;
  941|      1|    char drive = 0;
  942|       |
  943|       |    /* Short circuit a relative path */
  944|      1|    if(xp->kind == NCPD_REL) {
  ------------------
  |  |  244|      1|#define NCPD_REL 6 /* actual kind is unknown */
  ------------------
  |  Branch (944:8): [True: 0, False: 1]
  ------------------
  945|       |	/* Pass thru relative paths, but with proper slashes */
  946|      0|	if((path = strdup(xp->path))==NULL) stat = NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (946:5): [True: 0, False: 0]
  ------------------
  947|      0|	if(platform == NCPD_WIN || platform == NCPD_MSYS) {
  ------------------
  |  |  242|      0|#define NCPD_WIN 4
  ------------------
              	if(platform == NCPD_WIN || platform == NCPD_MSYS) {
  ------------------
  |  |  240|      0|#define NCPD_MSYS 2
  ------------------
  |  Branch (947:5): [True: 0, False: 0]
  |  Branch (947:29): [True: 0, False: 0]
  ------------------
  948|      0|	    char* p;
  949|      0|            for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* back slash*/
  ------------------
  |  Branch (949:24): [True: 0, False: 0]
  |  Branch (949:36): [True: 0, False: 0]
  ------------------
  950|      0|	}
  951|      0|	goto exit;
  952|      0|    }
  953|       |
  954|       |    /* We need a two level switch with an arm
  955|       |       for every pair of (xp->kind,platform)
  956|       |    */
  957|       |
  958|      1|#define CASE(k,t) case ((k)*10+(t))
  959|       |
  960|      1|    switch (xp->kind*10 + platform) {
  961|      0|    CASE(NCPD_NIX,NCPD_NIX):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (961:5): [True: 0, False: 1]
  ------------------
  962|      0|	assert(xp->drive == 0);
  ------------------
  |  Branch (962:2): [True: 0, False: 0]
  |  Branch (962:2): [True: 0, False: 0]
  ------------------
  963|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  964|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (964:5): [True: 0, False: 0]
  ------------------
  965|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
  966|      0|	path[0] = '\0';
  967|      0|	if(xp->path != NULL)
  ------------------
  |  Branch (967:5): [True: 0, False: 0]
  ------------------
  968|      0|	    strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  969|      0|	break;
  970|      0|    CASE(NCPD_NIX,NCPD_MSYS):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (970:5): [True: 0, False: 1]
  ------------------
  971|      0|    CASE(NCPD_NIX,NCPD_WIN):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (971:5): [True: 0, False: 1]
  ------------------
  972|      0|	assert(xp->drive == 0);
  ------------------
  |  Branch (972:2): [True: 0, False: 0]
  |  Branch (972:2): [True: 0, False: 0]
  ------------------
  973|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  974|      0|	if(!mountpoint.defined)
  ------------------
  |  Branch (974:5): [True: 0, False: 0]
  ------------------
  975|      0|	    {stat = NC_EINVAL; goto done;} /* drive required */
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  976|      0|	len += (strlen(mountpoint.prefix) + 2);
  977|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (977:5): [True: 0, False: 0]
  ------------------
  978|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
  979|      0|	path[0] = '\0';
  980|      0|	assert(mountpoint.drive != 0);
  ------------------
  |  Branch (980:2): [True: 0, False: 0]
  |  Branch (980:2): [True: 0, False: 0]
  ------------------
  981|      0|	sdrive[0] = mountpoint.drive;
  982|      0|	sdrive[1] = ':';
  983|      0|	sdrive[2] = '\0';
  984|      0|	strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  985|      0|	strlcat(path,mountpoint.prefix,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  986|      0|	if(xp->path != NULL) strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  |  Branch (986:5): [True: 0, False: 0]
  ------------------
  987|      0|        for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
  ------------------
  |  Branch (987:20): [True: 0, False: 0]
  |  Branch (987:32): [True: 0, False: 0]
  ------------------
  988|      0|	break;
  989|      1|    CASE(NCPD_NIX,NCPD_CYGWIN):
  ------------------
  |  |  958|      1|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (989:5): [True: 1, False: 0]
  ------------------
  990|      1|	assert(xp->drive == 0);
  ------------------
  |  Branch (990:2): [True: 0, False: 1]
  |  Branch (990:2): [True: 1, False: 0]
  ------------------
  991|       |	/* Is this one of the special cygwin paths? */
  992|      1|	cygspecial = iscygwinspecial(xp->path);
  993|      1|	len = 0;
  994|      1|	if(!cygspecial && mountpoint.drive != 0) {
  ------------------
  |  Branch (994:5): [True: 1, False: 0]
  |  Branch (994:20): [True: 0, False: 1]
  ------------------
  995|      0|	    len = cdlen + 1+1; /* /cygdrive/D */
  996|      0|	    len += nulllen(mountpoint.prefix);
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [Folded, False: 0]
  |  |  ------------------
  ------------------
  997|      0|	}
  998|      1|	if(xp->path)
  ------------------
  |  Branch (998:5): [True: 1, False: 0]
  ------------------
  999|      1|	    len += strlen(xp->path);
 1000|      1|	len++; /* nul term */
 1001|      1|        if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1001:12): [True: 0, False: 1]
  ------------------
 1002|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1003|      1|	path[0] = '\0';
 1004|      1|	if(!cygspecial && mountpoint.drive != 0) {
  ------------------
  |  Branch (1004:5): [True: 1, False: 0]
  |  Branch (1004:20): [True: 0, False: 1]
  ------------------
 1005|      0|            strlcat(path,"/cygdrive/",len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1006|      0|	    sdrive[0] = mountpoint.drive;
 1007|      0|	    sdrive[1] = '\0';
 1008|      0|            strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1009|      0|            strlcat(path,mountpoint.prefix,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1010|      0|	}
 1011|      1|  	if(xp->path)
  ------------------
  |  Branch (1011:7): [True: 1, False: 0]
  ------------------
 1012|      1|	    strlcat(path,xp->path,len);
  ------------------
  |  |   80|      1|#define strlcat nc_strlcat
  ------------------
 1013|      1|	break;
 1014|       |
 1015|      0|    CASE(NCPD_CYGWIN,NCPD_NIX):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1015:5): [True: 0, False: 1]
  ------------------
 1016|      0|        len = nulllen(xp->path);
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1017|      0|        if(xp->drive != 0)
  ------------------
  |  Branch (1017:12): [True: 0, False: 0]
  ------------------
 1018|      0|	    len += (cdlen + 1); /* strlen("/cygdrive/D") */
 1019|      0|	len++; /* nul term */
 1020|      0|        if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1020:12): [True: 0, False: 0]
  ------------------
 1021|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1022|      0|	path[0] = '\0';
 1023|      0|	if(xp->drive != 0) {
  ------------------
  |  Branch (1023:5): [True: 0, False: 0]
  ------------------
 1024|       |	    /* There is no good/standard way to map a windows
 1025|       |               drive letter to a *nix* path.*/
 1026|       |#if 0
 1027|       |            strlcat(path,"/cygdrive/",len);
 1028|       |#else
 1029|       |	    /* so, just use "/D" where D is the drive letter */
 1030|      0|	    strlcat(path,"/",len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1031|      0|#endif
 1032|      0|	    sdrive[0] = xp->drive; sdrive[1] = '\0';
 1033|      0|            strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1034|      0|	}
 1035|      0|  	if(xp->path)
  ------------------
  |  Branch (1035:7): [True: 0, False: 0]
  ------------------
 1036|      0|	    strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1037|      0|	break;
 1038|       |
 1039|      0|    CASE(NCPD_CYGWIN,NCPD_WIN):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1039:5): [True: 0, False: 1]
  ------------------
 1040|      0|    CASE(NCPD_CYGWIN,NCPD_MSYS):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1040:5): [True: 0, False: 1]
  ------------------
 1041|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1042|      0|	if(xp->drive == 0 && !mountpoint.defined)
  ------------------
  |  Branch (1042:5): [True: 0, False: 0]
  |  Branch (1042:23): [True: 0, False: 0]
  ------------------
 1043|      0|	    {stat = NC_EINVAL; goto done;} /* drive required */
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 1044|      0|        if (xp->drive == 0)
  ------------------
  |  Branch (1044:13): [True: 0, False: 0]
  ------------------
 1045|      0|            len += (strlen(mountpoint.prefix) + 2);
 1046|      0|        else
 1047|      0|            len += sizeof(sdrive);
 1048|      0|        len++;
 1049|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1049:5): [True: 0, False: 0]
  ------------------
 1050|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1051|      0|	path[0] = '\0';
 1052|      0|	if(xp->drive != 0)
  ------------------
  |  Branch (1052:5): [True: 0, False: 0]
  ------------------
 1053|      0|	    drive = xp->drive;
 1054|      0|	else
 1055|      0|	    drive = mountpoint.drive;
 1056|      0|	sdrive[0] = drive; sdrive[1] = ':'; sdrive[2] = '\0';
 1057|      0|        strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1058|      0|	if(xp->path != NULL)
  ------------------
  |  Branch (1058:5): [True: 0, False: 0]
  ------------------
 1059|      0|            strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1060|      0|        for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
  ------------------
  |  Branch (1060:20): [True: 0, False: 0]
  |  Branch (1060:32): [True: 0, False: 0]
  ------------------
 1061|      0|	break;
 1062|       |
 1063|      0|    CASE(NCPD_CYGWIN,NCPD_CYGWIN):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1063:5): [True: 0, False: 1]
  ------------------
 1064|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1065|      0|	if(xp->drive != 0)
  ------------------
  |  Branch (1065:5): [True: 0, False: 0]
  ------------------
 1066|      0|	    len += (cdlen + 2);
 1067|      0|	len++;
 1068|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1068:5): [True: 0, False: 0]
  ------------------
 1069|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1070|      0|	path[0] = '\0';
 1071|      0|	if(xp->drive != 0) {
  ------------------
  |  Branch (1071:5): [True: 0, False: 0]
  ------------------
 1072|      0|	    sdrive[0] = xp->drive; sdrive[1] = '\0';
 1073|      0|	    strlcat(path,"/cygdrive/",len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1074|      0|	    strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1075|      0|	}
 1076|      0|	if(xp->path != NULL)
  ------------------
  |  Branch (1076:5): [True: 0, False: 0]
  ------------------
 1077|      0|	    strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1078|      0|	break;
 1079|       |
 1080|      0|    CASE(NCPD_WIN, NCPD_WIN) :
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1080:5): [True: 0, False: 1]
  ------------------
 1081|      0|    CASE(NCPD_MSYS, NCPD_MSYS) :
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1081:5): [True: 0, False: 1]
  ------------------
 1082|      0|    CASE(NCPD_WIN, NCPD_MSYS) :
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1082:5): [True: 0, False: 1]
  ------------------
 1083|      0|    CASE(NCPD_MSYS, NCPD_WIN) :
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1083:5): [True: 0, False: 1]
  ------------------
 1084|      0|	if(xp->drive == 0 && !mountpoint.defined)
  ------------------
  |  Branch (1084:5): [True: 0, False: 0]
  |  Branch (1084:23): [True: 0, False: 0]
  ------------------
 1085|      0|	    {stat = NC_EINVAL; goto done;} /* drive required */
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 1086|      0|        len = nulllen(xp->path) + 1 + sizeof(sdrive);
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1087|      0|	if(xp->drive == 0)
  ------------------
  |  Branch (1087:5): [True: 0, False: 0]
  ------------------
 1088|      0|	    len += strlen(mountpoint.prefix);
 1089|      0|	len++;
 1090|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1090:5): [True: 0, False: 0]
  ------------------
 1091|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1092|      0|	path[0] = '\0';
 1093|      0|	if(xp->drive != 0)
  ------------------
  |  Branch (1093:5): [True: 0, False: 0]
  ------------------
 1094|      0|	    drive = xp->drive;
 1095|      0|	else
 1096|      0|	    drive = mountpoint.drive;
 1097|      0|	sdrive[0] = drive;
 1098|      0|	sdrive[1] = (drive == netdrive ? '\0' : ':');
  ------------------
  |  Branch (1098:15): [True: 0, False: 0]
  ------------------
 1099|      0|	sdrive[2] = '\0';
 1100|      0|        strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1101|      0|	if(xp->path != NULL)
  ------------------
  |  Branch (1101:5): [True: 0, False: 0]
  ------------------
 1102|      0|            strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1103|      0|        for(p=path;*p;p++) {if(*p == '/') *p = '\\';} /* restore back slash */
  ------------------
  |  Branch (1103:20): [True: 0, False: 0]
  |  Branch (1103:32): [True: 0, False: 0]
  ------------------
 1104|      0|	break;
 1105|       |
 1106|      0|    CASE(NCPD_WIN,NCPD_NIX):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1106:5): [True: 0, False: 1]
  ------------------
 1107|      0|    CASE(NCPD_MSYS,NCPD_NIX):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1107:5): [True: 0, False: 1]
  ------------------
 1108|      0|	assert(xp->drive != 0);
  ------------------
  |  Branch (1108:2): [True: 0, False: 0]
  |  Branch (1108:2): [True: 0, False: 0]
  ------------------
 1109|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1110|      0|	if(xp->drive != 0)
  ------------------
  |  Branch (1110:5): [True: 0, False: 0]
  ------------------
 1111|      0|            len += sizeof(sdrive);
 1112|      0|	len++;
 1113|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1113:5): [True: 0, False: 0]
  ------------------
 1114|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1115|      0|	path[0] = '\0';
 1116|      0|	if(xp->drive != 0) {
  ------------------
  |  Branch (1116:5): [True: 0, False: 0]
  ------------------
 1117|      0|	    sdrive[0] = '/'; sdrive[1] = xp->drive; sdrive[2] = '\0';
 1118|      0|            strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1119|      0|	}
 1120|      0|	if(xp->path != NULL) strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  |  Branch (1120:5): [True: 0, False: 0]
  ------------------
 1121|      0|	break;
 1122|       |
 1123|      0|    CASE(NCPD_MSYS,NCPD_CYGWIN):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1123:5): [True: 0, False: 1]
  ------------------
 1124|      0|    CASE(NCPD_WIN,NCPD_CYGWIN):
  ------------------
  |  |  958|      0|#define CASE(k,t) case ((k)*10+(t))
  ------------------
  |  Branch (1124:5): [True: 0, False: 1]
  ------------------
 1125|      0|	assert(xp->drive != 0);
  ------------------
  |  Branch (1125:2): [True: 0, False: 0]
  |  Branch (1125:2): [True: 0, False: 0]
  ------------------
 1126|      0|	len = nulllen(xp->path)+1;
  ------------------
  |  |  151|      0|#define nulllen(s) ((s)==NULL?0:strlen(s))
  |  |  ------------------
  |  |  |  Branch (151:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1127|      0|        len += (cdlen + 2);
 1128|      0|	len++;
 1129|      0|	if((path = (char*)malloc(len))==NULL)
  ------------------
  |  Branch (1129:5): [True: 0, False: 0]
  ------------------
 1130|      0|	    {stat = NCTHROW(NC_ENOMEM); goto done;}
  ------------------
  |  |   58|      0|#define NCTHROW(e) (e)
  ------------------
 1131|      0|	path[0] = '\0';
 1132|      0|        sdrive[0] = xp->drive; sdrive[1] = '\0';
 1133|      0|	strlcat(path,"/cygdrive/",len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1134|      0|        strlcat(path,sdrive,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
 1135|      0|	if(xp->path != NULL) strlcat(path,xp->path,len);
  ------------------
  |  |   80|      0|#define strlcat nc_strlcat
  ------------------
  |  Branch (1135:5): [True: 0, False: 0]
  ------------------
 1136|      0|	break;
 1137|       |
 1138|      0|    default: stat = NC_EINTERNAL; goto done;
  ------------------
  |  |  523|      0|#define NC_EINTERNAL     (-92)      /**< NetCDF Library Internal Error */
  ------------------
  |  Branch (1138:5): [True: 0, False: 1]
  ------------------
 1139|      1|    }
 1140|       |
 1141|      1|    if(pathdebug > 0)
  ------------------
  |  Branch (1141:8): [True: 0, False: 1]
  ------------------
 1142|      0|	fprintf(stderr,">>> unparse: platform=%s xp=%s path=|%s|\n",NCgetkindname(platform),printPATH(xp),path);
 1143|       |
 1144|      1|exit:
 1145|      1|    if(pathp) {*pathp = path; path = NULL;}
  ------------------
  |  Branch (1145:8): [True: 1, False: 0]
  ------------------
 1146|      1|done:
 1147|       |    nullfree(path);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1148|      1|    return stat;
 1149|      1|}
dpathmgr.c:iscygwinspecial:
  368|      1|{
  369|      1|    const char** p;
  370|      1|    if(path == NULL) return 0;
  ------------------
  |  Branch (370:8): [True: 0, False: 1]
  ------------------
  371|     11|    for(p=cygwinspecial;*p;p++) {
  ------------------
  |  Branch (371:25): [True: 10, False: 1]
  ------------------
  372|     10|        if(strncmp(*p,path,strlen(*p))==0) return 1;
  ------------------
  |  Branch (372:12): [True: 0, False: 10]
  ------------------
  373|     10|    }
  374|      1|    return 0;
  375|      1|}

nc_plugin_path_initialize:
   60|      1|{
   61|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   62|      1|    struct NCglobalstate* gs = NULL;
   63|      1|    NCPluginList dirs = {0,NULL};
   64|       |#ifdef USE_HDF5
   65|       |    int hdf5found = 0; /* 1 => we got a legit plugin path set from HDF5 */
   66|       |#endif
   67|       |
   68|      1|    if(!NC_initialized) nc_initialize();
  ------------------
  |  Branch (68:8): [True: 0, False: 1]
  ------------------
   69|      1|    if(NC_plugin_path_initialized != 0) goto done;
  ------------------
  |  Branch (69:8): [True: 0, False: 1]
  ------------------
   70|      1|    NC_plugin_path_initialized = 1;
   71|       |
   72|      1|    if(getenv(PLUGINPATHVERIFY) != NULL) NC_plugin_path_verify = 1;
  ------------------
  |  |   41|      1|#define PLUGINPATHVERIFY "NC_PLUGIN_PATH_VERIFY"
  ------------------
  |  Branch (72:8): [True: 0, False: 1]
  ------------------
   73|       |
   74|      1|    gs = NC_getglobalstate();
   75|       |
   76|       |   /**
   77|       |    * When the netcdf-c library initializes itself (at runtime), it chooses an
   78|       |    * initial global plugin path using the following rules, which are those used
   79|       |    * by the HDF5 library, except as modified for plugin install (which HDF5 does not support).
   80|       |    */
   81|       |
   82|       |    /* Initialize the implementations */
   83|       |#ifdef NETCDF_ENABLE_NCZARR_FILTERS
   84|       |    if((stat = NCZ_plugin_path_initialize())) goto done;    
   85|       |#endif
   86|       |#ifdef USE_HDF5
   87|       |    if((stat = NC4_hdf5_plugin_path_initialize())) goto done;
   88|       |#endif
   89|       |
   90|       |    /* Compute the initial global plugin path */
   91|      1|    assert(dirs.ndirs == 0 && dirs.dirs == NULL);
  ------------------
  |  Branch (91:5): [True: 0, False: 1]
  |  Branch (91:5): [True: 0, False: 0]
  |  Branch (91:5): [True: 1, False: 0]
  |  Branch (91:5): [True: 1, False: 0]
  ------------------
   92|      1|    if((stat = buildinitialpluginpath(&dirs))) goto done; /* Construct a default */
  ------------------
  |  Branch (92:8): [True: 0, False: 1]
  ------------------
   93|       |
   94|       |    /* Sync to the actual implementations */
   95|       |#ifdef USE_HDF5
   96|       |    if(!hdf5found)
   97|       |	{if((stat = NC4_hdf5_plugin_path_set(&dirs))) goto done;}
   98|       |#endif
   99|       |#ifdef NETCDF_ENABLE_NCZARR_FILTERS
  100|       |    if((stat = NCZ_plugin_path_set(&dirs))) goto done;
  101|       |#endif
  102|       |    /* Set the global plugin dirs sequence */
  103|      1|    assert(gs->pluginpaths == NULL);
  ------------------
  |  Branch (103:5): [True: 0, False: 1]
  |  Branch (103:5): [True: 1, False: 0]
  ------------------
  104|      1|    gs->pluginpaths = nclistnew();
  105|      1|    if(dirs.ndirs > 0) {
  ------------------
  |  Branch (105:8): [True: 1, False: 0]
  ------------------
  106|      1|	size_t i;
  107|      1|	char** dst;
  108|      1|        nclistsetlength(gs->pluginpaths,dirs.ndirs);
  109|      1|	dst = (char**)nclistcontents(gs->pluginpaths);
  ------------------
  |  |   72|      1|#define nclistcontents(l)  ((l)==NULL?NULL:(l)->content)
  |  |  ------------------
  |  |  |  Branch (72:29): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  110|      1|	assert(dst != NULL);
  ------------------
  |  Branch (110:2): [True: 0, False: 1]
  |  Branch (110:2): [True: 1, False: 0]
  ------------------
  111|      3|	for(i=0;i<dirs.ndirs;i++)
  ------------------
  |  Branch (111:10): [True: 2, False: 1]
  ------------------
  112|      2|	    dst[i] = strdup(dirs.dirs[i]);
  113|      1|    }
  114|      1|done:
  115|      1|    ncaux_plugin_path_clear(&dirs);
  116|      1|    return NCTHROW(stat);
  ------------------
  |  |   58|      1|#define NCTHROW(e) (e)
  ------------------
  117|      1|}
nc_plugin_path_finalize:
  130|      1|{
  131|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  132|      1|    struct NCglobalstate* gs = NC_getglobalstate();
  133|       |
  134|      1|    if(NC_plugin_path_initialized == 0) goto done;
  ------------------
  |  Branch (134:8): [True: 0, False: 1]
  ------------------
  135|      1|    NC_plugin_path_initialized = 0;
  136|       |
  137|      1|    NC_plugin_path_verify = 0;
  138|       |
  139|       |    /* Finalize the actual implementation */
  140|       |#ifdef NETCDF_ENABLE_NCZARR_FILTERS
  141|       |    if((stat = NCZ_plugin_path_finalize())) goto done;    
  142|       |#endif
  143|       |#ifdef USE_HDF5
  144|       |    if((stat = NC4_hdf5_plugin_path_finalize())) goto done;
  145|       |#endif
  146|       |
  147|      1|    nclistfreeall(gs->pluginpaths); gs->pluginpaths = NULL;
  148|      1|done:
  149|      1|    return NCTHROW(stat);
  ------------------
  |  |   58|      1|#define NCTHROW(e) (e)
  ------------------
  150|      1|}
dplugins.c:buildinitialpluginpath:
  327|      1|{
  328|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  329|      1|    const char* hdf5path = NULL;
  330|       |    /* Find the plugin directory root(s) */
  331|      1|    hdf5path = getenv(PLUGIN_ENV); /* HDF5_PLUGIN_PATH */
  ------------------
  |  |   38|      1|#define PLUGIN_ENV "HDF5_PLUGIN_PATH"
  ------------------
  332|      1|    if(hdf5path == NULL) {
  ------------------
  |  Branch (332:8): [True: 1, False: 0]
  ------------------
  333|       |	/* Use NETCDF_PLUGIN_SEARCH_PATH */
  334|      1|	hdf5path = NETCDF_PLUGIN_SEARCH_PATH;
  ------------------
  |  |  176|      1|#define NETCDF_PLUGIN_SEARCH_PATH "/usr/local/hdf5/lib/plugin:/usr/local/hdf5/lib/plugin"
  ------------------
  335|      1|    }
  336|      1|    if((stat = ncaux_plugin_path_parse(hdf5path,'\0',dirs))) goto done;
  ------------------
  |  Branch (336:8): [True: 0, False: 1]
  ------------------
  337|       |
  338|      1|done:
  339|      1|    return stat;
  340|      1|}

ncrc_initialize:
  139|      1|{
  140|      1|    if(NCRCinitialized) return;
  ------------------
  |  Branch (140:8): [True: 0, False: 1]
  ------------------
  141|      1|    NCRCinitialized = 1; /* prevent recursion */
  142|       |
  143|      1|#ifndef NOREAD
  144|      1|    {
  145|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  146|      1|    NCglobalstate* ncg = NC_getglobalstate();
  147|       |    /* Load entries */
  148|      1|    if((stat = NC_rcload())) {
  ------------------
  |  Branch (148:8): [True: 0, False: 1]
  ------------------
  149|      0|        nclog(NCLOGWARN,".rc loading failed");
  ------------------
  |  |   23|      0|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  150|      0|    }
  151|       |    /* Load .aws/config &/ credentials */
  152|      1|    if((stat = NC_aws_load_credentials(ncg))) {
  ------------------
  |  Branch (152:8): [True: 1, False: 0]
  ------------------
  153|      1|        nclog(NCLOGWARN,"AWS config file not loaded");
  ------------------
  |  |   23|      1|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  154|      1|    }
  155|      1|    }
  156|      1|#endif
  157|      1|}
NC_rcclear:
  177|      1|{
  178|      1|    if(info == NULL) return;
  ------------------
  |  Branch (178:8): [True: 0, False: 1]
  ------------------
  179|      1|    nullfree(info->rcfile);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  180|       |    nullfree(info->rchome);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  181|      1|    rcfreeentries(info->entries);
  182|      1|    NC_s3freeprofilelist(info->s3profiles);
  183|      1|}
NC_rclookup:
  281|     31|{
  282|     31|    struct NCRCentry* entry = NULL;
  283|     31|    if(!NCRCinitialized) ncrc_initialize();
  ------------------
  |  Branch (283:8): [True: 0, False: 31]
  ------------------
  284|     31|    entry = rclocate(key,hostport,urlpath);
  285|     31|    return (entry == NULL ? NULL : entry->value);
  ------------------
  |  Branch (285:13): [True: 31, False: 0]
  ------------------
  286|     31|}
drc.c:rcfreeentries:
  197|      1|{
  198|      1|    size_t i;
  199|      1|    for(i=0;i<nclistlength(rc);i++) {
  ------------------
  |  |   73|      1|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (199:13): [True: 0, False: 1]
  ------------------
  200|      0|	NCRCentry* t = (NCRCentry*)nclistget(rc,i);
  201|      0|	rcfreeentry(t);
  202|      0|    }
  203|      1|    nclistfree(rc);
  204|      1|}
drc.c:NC_rcload:
  209|      1|{
  210|      1|    size_t i;
  211|      1|    int ret = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  212|      1|    char* path = NULL;
  213|      1|    NCglobalstate* globalstate = NULL;
  214|      1|    NClist* rcfileorder = nclistnew();
  215|       |
  216|      1|    if(!NCRCinitialized) ncrc_initialize();
  ------------------
  |  Branch (216:8): [True: 0, False: 1]
  ------------------
  217|      1|    globalstate = NC_getglobalstate();
  218|       |
  219|      1|    if(globalstate->rcinfo->ignore) {
  ------------------
  |  Branch (219:8): [True: 0, False: 1]
  ------------------
  220|      0|        nclog(NCLOGNOTE,".rc file loading suppressed");
  ------------------
  |  |   24|      0|#define NCLOGNOTE  (3)	/* General info */
  ------------------
  221|      0|	goto done;
  222|      0|    }
  223|      1|    if(globalstate->rcinfo->loaded) goto done;
  ------------------
  |  Branch (223:8): [True: 0, False: 1]
  ------------------
  224|       |
  225|       |    /* locate the configuration files in order of use:
  226|       |       1. Specified by NCRCENV_RC environment variable.
  227|       |       2. If NCRCENV_RC is not set then merge the set of rc files in this order:
  228|       |	  1. $HOME/.ncrc
  229|       |	  2. $HOME/.dodsrc
  230|       |	  3. $CWD/.ncrc
  231|       |	  4. $CWD/.dodsrc
  232|       |	  Entries in later files override any of the earlier files
  233|       |    */
  234|      1|    if(globalstate->rcinfo->rcfile != NULL) { /* always use this */
  ------------------
  |  Branch (234:8): [True: 0, False: 1]
  ------------------
  235|      0|	nclistpush(rcfileorder,strdup(globalstate->rcinfo->rcfile));
  236|      1|    } else {
  237|      1|	const char** rcname;
  238|      1|	const char* dirnames[3];
  239|      1|	const char** dir;
  240|       |
  241|       |        /* Make sure rcinfo.rchome is defined */
  242|      1|	ncrc_setrchome();
  243|      1|	dirnames[0] = globalstate->rcinfo->rchome;
  244|      1|	dirnames[1] = globalstate->cwd;
  245|      1|	dirnames[2] = NULL;
  246|       |
  247|      3|        for(dir=dirnames;*dir;dir++) {
  ------------------
  |  Branch (247:26): [True: 2, False: 1]
  ------------------
  248|      8|	    for(rcname=rcfilenames;*rcname;rcname++) {
  ------------------
  |  Branch (248:29): [True: 6, False: 2]
  ------------------
  249|      6|	        ret = rcsearch(*dir,*rcname,&path);
  250|      6|		if(ret == NC_NOERR && path != NULL)
  ------------------
  |  |  417|     12|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (250:6): [True: 6, False: 0]
  |  Branch (250:25): [True: 0, False: 6]
  ------------------
  251|      0|		    nclistpush(rcfileorder,path);
  252|      6|		path = NULL;
  253|      6|	    }
  254|      2|	}
  255|      1|    }
  256|      1|    for(i=0;i<nclistlength(rcfileorder);i++) {
  ------------------
  |  |   73|      1|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (256:13): [True: 0, False: 1]
  ------------------
  257|      0|	path = (char*)nclistget(rcfileorder,i);
  258|      0|	if((ret=rccompile(path))) {
  ------------------
  |  Branch (258:5): [True: 0, False: 0]
  ------------------
  259|      0|	    nclog(NCLOGWARN, "Error parsing %s\n",path);
  ------------------
  |  |   23|      0|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  260|      0|	    ret = NC_NOERR; /* ignore it */
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  261|      0|	    goto done;
  262|      0|	}
  263|      0|    }
  264|       |
  265|      1|done:
  266|      1|    globalstate->rcinfo->loaded = 1; /* even if not exists */
  267|      1|    nclistfreeall(rcfileorder);
  268|      1|    return (ret);
  269|      1|}
drc.c:ncrc_setrchome:
  161|      1|{
  162|      1|    const char* tmp = NULL;
  163|      1|    NCglobalstate* ncg = NC_getglobalstate();
  164|      1|    assert(ncg && ncg->home);
  ------------------
  |  Branch (164:5): [True: 0, False: 1]
  |  Branch (164:5): [True: 0, False: 0]
  |  Branch (164:5): [True: 1, False: 0]
  |  Branch (164:5): [True: 1, False: 0]
  ------------------
  165|      1|    if(ncg->rcinfo->rchome) return;
  ------------------
  |  Branch (165:8): [True: 0, False: 1]
  ------------------
  166|      1|    tmp = getenv(NCRCENVHOME);
  ------------------
  |  |   24|      1|#define NCRCENVHOME "NCRCENV_HOME"
  ------------------
  167|      1|    if(tmp == NULL || strlen(tmp) == 0)
  ------------------
  |  Branch (167:8): [True: 1, False: 0]
  |  Branch (167:23): [True: 0, False: 0]
  ------------------
  168|      1|	tmp = ncg->home;
  169|      1|    ncg->rcinfo->rchome = strdup(tmp);
  170|       |#ifdef DRCDEBUG
  171|       |    fprintf(stderr,"ncrc_setrchome: %s\n",ncg->rcinfo->rchome);
  172|       |#endif
  173|      1|}
drc.c:rcsearch:
  639|      6|{
  640|      6|    char* path = NULL;
  641|      6|    FILE* f = NULL;
  642|      6|    size_t plen = (prefix?strlen(prefix):0);
  ------------------
  |  Branch (642:20): [True: 6, False: 0]
  ------------------
  643|      6|    size_t rclen = strlen(rcname);
  644|      6|    int ret = NC_NOERR;
  ------------------
  |  |  417|      6|#define NC_NOERR        0          /**< No Error */
  ------------------
  645|       |
  646|      6|    size_t pathlen = plen+rclen+1+1; /*+1 for '/' +1 for nul */
  647|      6|    path = (char*)malloc(pathlen); /* +1 for nul*/
  648|      6|    if(path == NULL) {ret = NC_ENOMEM;	goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (648:8): [True: 0, False: 6]
  ------------------
  649|      6|    snprintf(path, pathlen, "%s/%s", prefix, rcname);
  650|       |    /* see if file is readable */
  651|      6|    f = NCfopen(path,"r");
  ------------------
  |  |  210|      6|#define NCfopen(path,flags) fopen((path),(flags))
  ------------------
  652|      6|    if(f != NULL)
  ------------------
  |  Branch (652:8): [True: 0, False: 6]
  ------------------
  653|      0|        nclog(NCLOGNOTE, "Found rc file=%s",path);
  ------------------
  |  |   24|      0|#define NCLOGNOTE  (3)	/* General info */
  ------------------
  654|      6|done:
  655|      6|    if(f == NULL || ret != NC_NOERR) {
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (655:8): [True: 6, False: 0]
  |  Branch (655:21): [True: 0, False: 0]
  ------------------
  656|      6|	nullfree(path);
  ------------------
  |  |  155|      6|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 6, False: 0]
  |  |  ------------------
  ------------------
  657|      6|	path = NULL;
  658|      6|    }
  659|      6|    if(f != NULL)
  ------------------
  |  Branch (659:8): [True: 0, False: 6]
  ------------------
  660|      0|      fclose(f);
  661|      6|    if(pathp != NULL)
  ------------------
  |  Branch (661:8): [True: 6, False: 0]
  ------------------
  662|      6|      *pathp = path;
  663|      0|    else {
  664|      0|      nullfree(path);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  665|      0|      path = NULL;
  666|      0|    }
  667|       |    errno = 0; /* silently ignore errors */
  668|      6|    return (ret);
  669|      6|}
drc.c:rclocate:
  621|     31|{
  622|     31|    int pos;
  623|     31|    NCglobalstate* globalstate = NC_getglobalstate();
  624|     31|    struct NCRCinfo* info = globalstate->rcinfo;
  625|       |
  626|     31|    if(globalstate->rcinfo->ignore) return NULL;
  ------------------
  |  Branch (626:8): [True: 0, False: 31]
  ------------------
  627|     31|    if(key == NULL || info == NULL) return NULL;
  ------------------
  |  Branch (627:8): [True: 0, False: 31]
  |  Branch (627:23): [True: 0, False: 31]
  ------------------
  628|     31|    pos = rclocatepos(key,hostport,urlpath);
  629|     31|    if(pos < 0) return NULL;
  ------------------
  |  Branch (629:8): [True: 31, False: 0]
  ------------------
  630|      0|    return NC_rcfile_ith(info,(size_t)pos);
  631|     31|}
drc.c:rclocatepos:
  593|     31|{
  594|     31|    size_t i;
  595|     31|    NCglobalstate* globalstate = NC_getglobalstate();
  596|     31|    struct NCRCinfo* info = globalstate->rcinfo;
  597|     31|    NCRCentry* entry = NULL;
  598|     31|    NCRCentry candidate;
  599|     31|    NClist* rc = info->entries;
  600|       |
  601|     31|    if(info->ignore) return -1;
  ------------------
  |  Branch (601:8): [True: 0, False: 31]
  ------------------
  602|       |
  603|     31|    candidate.key = (char*)key;
  604|     31|    candidate.value = (char*)NULL;
  605|     31|    candidate.host = (char*)hostport;
  606|     31|    candidate.urlpath = (char*)urlpath;
  607|       |
  608|     31|    for(i=0;i<nclistlength(rc);i++) {
  ------------------
  |  |   73|     31|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  |  Branch (608:13): [True: 0, False: 31]
  ------------------
  609|      0|      entry = (NCRCentry*)nclistget(rc,i);
  610|      0|      if(rcequal(entry,&candidate)) return (int)i;
  ------------------
  |  Branch (610:10): [True: 0, False: 0]
  ------------------
  611|      0|    }
  612|     31|    return -1;
  613|     31|}

NC_s3freeprofilelist:
  488|      3|{
  489|      3|    if(profiles) {
  ------------------
  |  Branch (489:8): [True: 2, False: 1]
  ------------------
  490|      3|	for(size_t i=0;i<nclistlength(profiles);i++) {
  ------------------
  |  |   73|      3|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 3]
  |  |  ------------------
  ------------------
  |  Branch (490:17): [True: 1, False: 2]
  ------------------
  491|      1|	    struct AWSprofile* p = (struct AWSprofile*)nclistget(profiles,i);
  492|      1|	    freeprofile(p);
  493|      1|	}
  494|      2|	nclistfree(profiles);
  495|      2|    }
  496|      3|}
NC_aws_load_credentials:
  514|      1|{
  515|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  516|      1|    NClist* profiles = nclistnew();
  517|      1|    NCbytes* buf = ncbytesnew();
  518|      1|    char path[8192];
  519|      1|    const char* aws_root = getenv(NC_TEST_AWS_DIR);
  ------------------
  |  |   37|      1|#define NC_TEST_AWS_DIR "NC_TEST_AWS_DIR"
  ------------------
  520|      1|    const char* awscfg_local[NCONFIGFILES + 1]; /* +1 for the env variable */
  521|      1|    const char** awscfg = NULL;
  522|       |
  523|       |    /* add a "no" credentials */
  524|      1|    {
  525|      1|	struct AWSprofile* noprof = (struct AWSprofile*)calloc(1,sizeof(struct AWSprofile));
  526|      1|	noprof->name = strdup("no");
  527|      1|	noprof->entries = nclistnew();
  528|      1|	nclistpush(profiles,noprof); noprof = NULL;
  529|      1|    }
  530|       |
  531|      1|    awscfg = awsconfigfiles;
  532|      1|    if((awscfg_local[0] = NC_getglobalstate()->aws.config_file)!=NULL) {
  ------------------
  |  Branch (532:8): [True: 0, False: 1]
  ------------------
  533|      0|	memcpy(&awscfg_local[1],awsconfigfiles,sizeof(char*)*NCONFIGFILES);
  ------------------
  |  |   43|      0|#define NCONFIGFILES (sizeof(awsconfigfiles)/sizeof(char*))
  ------------------
  534|      0|	awscfg = awscfg_local;
  535|      0|    }
  536|      3|    for(;*awscfg;awscfg++) {
  ------------------
  |  Branch (536:10): [True: 2, False: 1]
  ------------------
  537|       |        /* Construct the path ${HOME}/<file> or Windows equivalent. */
  538|      2|	const char* cfg = *awscfg;
  539|       |
  540|      2|        snprintf(path,sizeof(path),"%s%s%s",
  541|      2|	    (aws_root?aws_root:gstate->home),
  ------------------
  |  Branch (541:7): [True: 0, False: 2]
  ------------------
  542|      2|	    (*cfg == '/'?"":"/"),
  ------------------
  |  Branch (542:7): [True: 0, False: 2]
  ------------------
  543|      2|	    cfg);
  544|      2|	ncbytesclear(buf);
  ------------------
  |  |   58|      2|#define ncbytesclear(bb) ((bb)!=NULL?(bb)->length=0:0)
  |  |  ------------------
  |  |  |  Branch (58:27): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  545|      2|        if((stat=NC_readfile(path,buf))) {
  ------------------
  |  Branch (545:12): [True: 2, False: 0]
  ------------------
  546|      2|            nclog(NCLOGWARN, "Could not open file: %s",path);
  ------------------
  |  |   23|      2|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  547|      2|        } else {
  548|       |            /* Parse the credentials file */
  549|      0|	    const char* text = ncbytescontents(buf);
  ------------------
  |  |   56|      0|#define ncbytescontents(bb) (((bb)!=NULL && (bb)->content!=NULL)?(bb)->content:(char*)"")
  |  |  ------------------
  |  |  |  Branch (56:31): [True: 0, False: 0]
  |  |  |  Branch (56:45): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  550|      0|            if((stat = awsparse(text,profiles))) goto done;
  ------------------
  |  Branch (550:16): [True: 0, False: 0]
  ------------------
  551|      0|	}
  552|      2|    }
  553|       |  
  554|       |    /* If there is no default credentials, then try to synthesize one
  555|       |       from various environment variables */
  556|      1|    {
  557|      1|	size_t i;
  558|      1|        struct AWSprofile* dfalt = NULL;
  559|      1|        struct AWSentry* entry = NULL;
  560|      1|        NCglobalstate* gs = NC_getglobalstate();
  561|       |	/* Verify that we can build a default */
  562|      1|        if(gs->aws.access_key_id != NULL && gs->aws.secret_access_key != NULL) {
  ------------------
  |  Branch (562:12): [True: 0, False: 1]
  |  Branch (562:45): [True: 0, False: 0]
  ------------------
  563|       |	    /* Kill off any previous default profile */
  564|      0|	    for(i=nclistlength(profiles)-1;i>=0;i--) {/* walk backward because we are removing entries */
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (564:37): [True: 0, False: 0]
  ------------------
  565|      0|		struct AWSprofile* prof = (struct AWSprofile*)nclistget(profiles,i);
  566|      0|		if(strcasecmp(prof->name,"default")==0) {
  ------------------
  |  Branch (566:6): [True: 0, False: 0]
  ------------------
  567|      0|		    nclistremove(profiles,i);
  568|      0|		    freeprofile(prof);
  569|      0|		}
  570|      0|	    }
  571|       |	    /* Build new default profile */
  572|      0|	    if((dfalt = (struct AWSprofile*)calloc(1,sizeof(struct AWSprofile)))==NULL) {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (572:9): [True: 0, False: 0]
  ------------------
  573|      0|	    dfalt->name = strdup("default");
  574|      0|	    dfalt->entries = nclistnew();
  575|       |	    /* Save the new default profile */
  576|      0|	    nclistpush(profiles,dfalt); dfalt = NULL;
  577|       |	    /* Create the entries for default */
  578|      0|	    if((entry = (struct AWSentry*)calloc(1,sizeof(struct AWSentry)))==NULL) {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (578:9): [True: 0, False: 0]
  ------------------
  579|      0|	    entry->key = strdup(AWS_PROF_ACCESS_KEY_ID);
  ------------------
  |  |   28|      0|#define AWS_PROF_ACCESS_KEY_ID "aws_access_key_id"
  ------------------
  580|      0|	    entry->value = strdup(gs->aws.access_key_id);
  581|      0|	    nclistpush(dfalt->entries,entry); entry = NULL;
  582|      0|	    if((entry = (struct AWSentry*)calloc(1,sizeof(struct AWSentry)))==NULL) {stat = NC_ENOMEM; goto done;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (582:9): [True: 0, False: 0]
  ------------------
  583|      0|	    entry->key = strdup(AWS_PROF_SECRET_ACCESS_KEY);
  ------------------
  |  |   29|      0|#define AWS_PROF_SECRET_ACCESS_KEY "aws_secret_access_key"
  ------------------
  584|      0|	    entry->value = strdup(gs->aws.secret_access_key);
  585|      0|	    nclistpush(dfalt->entries,entry); entry = NULL;
  586|      0|	}
  587|      1|    }
  588|       |
  589|      1|    if(gstate->rcinfo->s3profiles)
  ------------------
  |  Branch (589:8): [True: 1, False: 0]
  ------------------
  590|      1|        NC_s3freeprofilelist(gstate->rcinfo->s3profiles);
  591|      1|    gstate->rcinfo->s3profiles = profiles; profiles = NULL;
  592|       |
  593|       |#ifdef AWSDEBUG
  594|       |    awsprofiles();
  595|       |#endif
  596|       |
  597|      1|done:
  598|      1|    ncbytesfree(buf);
  599|      1|    NC_s3freeprofilelist(profiles);
  600|      1|    return stat;
  601|      1|}
ds3util.c:freeprofile:
  471|      1|{
  472|      1|    if(profile) {
  ------------------
  |  Branch (472:8): [True: 1, False: 0]
  ------------------
  473|       |#ifdef AWSDEBUG
  474|       |fprintf(stderr,">>> freeprofile: %s\n",profile->name);
  475|       |#endif
  476|      1|	for(size_t i=0;i<nclistlength(profile->entries);i++) {
  ------------------
  |  |   73|      1|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (476:17): [True: 0, False: 1]
  ------------------
  477|      0|	    struct AWSentry* e = (struct AWSentry*)nclistget(profile->entries,i);
  478|      0|	    freeentry(e);
  479|      0|	}
  480|      1|        nclistfree(profile->entries);
  481|      1|	nullfree(profile->name);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  482|       |	nullfree(profile);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  483|      1|    }
  484|      1|}

free_NC_string:
   30|   759k|{
   31|   759k|	if(ncstrp==NULL)
  ------------------
  |  Branch (31:5): [True: 0, False: 759k]
  ------------------
   32|      0|		return;
   33|   759k|	free(ncstrp);
   34|   759k|}
new_NC_string:
  232|   759k|{
  233|   759k|	NC_string *ncstrp;
  234|   759k|	size_t sz;
  235|       |
  236|   759k|	if (slen > SIZE_MAX - M_RNDUP(sizeof(NC_string)) - 1)
  ------------------
  |  |   19|   759k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   759k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   759k|	* (unit))
  |  |  ------------------
  ------------------
  |  Branch (236:6): [True: 0, False: 759k]
  ------------------
  237|      0|		return NULL;
  238|       |	
  239|   759k|	sz = M_RNDUP(sizeof(NC_string)) + slen + 1;
  ------------------
  |  |   19|   759k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   759k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   759k|	* (unit))
  |  |  ------------------
  ------------------
  240|       |
  241|       |#if 0
  242|       |	sz = _RNDUP(sz, X_ALIGN);
  243|       |#endif
  244|       |
  245|   759k|	ncstrp = (NC_string *)malloc(sz);
  246|   759k|	if( ncstrp == NULL )
  ------------------
  |  Branch (246:6): [True: 9, False: 759k]
  ------------------
  247|      9|		return NULL;
  248|   759k|	(void) memset(ncstrp, 0, sz);
  249|       |
  250|   759k|	ncstrp->nchars = sz - M_RNDUP(sizeof(NC_string)) - 1;
  ------------------
  |  |   19|   759k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   759k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   759k|	* (unit))
  |  |  ------------------
  ------------------
  251|   759k|	assert(ncstrp->nchars + 1 > slen);
  ------------------
  |  Branch (251:2): [True: 0, False: 759k]
  |  Branch (251:2): [True: 759k, False: 0]
  ------------------
  252|   759k|	ncstrp->cp = (char *)ncstrp + M_RNDUP(sizeof(NC_string));
  ------------------
  |  |   19|   759k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   759k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   759k|	* (unit))
  |  |  ------------------
  ------------------
  253|       |
  254|   759k|	if(str != NULL && *str != 0)
  ------------------
  |  Branch (254:5): [True: 0, False: 759k]
  |  Branch (254:20): [True: 0, False: 0]
  ------------------
  255|      0|	{
  256|      0|		(void) strncpy(ncstrp->cp, str, ncstrp->nchars +1);
  257|      0|		ncstrp->cp[ncstrp->nchars] = 0;
  258|      0|	}
  259|       |
  260|   759k|	return(ncstrp);
  261|   759k|}

NC_udf_load_plugins:
  237|      1|{
  238|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  239|       |    
  240|       |    /* Loop through all 10 UDF slots */
  241|     11|    for (int i = 0; i < NC_MAX_UDF_FORMATS; i++) {
  ------------------
  |  |  199|     11|#define NC_MAX_UDF_FORMATS 10
  ------------------
  |  Branch (241:21): [True: 10, False: 1]
  ------------------
  242|     10|        char key_lib[64], key_init[64], key_magic[64];
  243|     10|        const char* lib = NULL;
  244|     10|        const char* init = NULL;
  245|     10|        const char* magic = NULL;
  246|       |        
  247|       |        /* Build RC key names for this UDF slot */
  248|     10|        snprintf(key_lib, sizeof(key_lib), "NETCDF.UDF%d.LIBRARY", i);
  249|     10|        snprintf(key_init, sizeof(key_init), "NETCDF.UDF%d.INIT", i);
  250|     10|        snprintf(key_magic, sizeof(key_magic), "NETCDF.UDF%d.MAGIC", i);
  251|       |        
  252|       |        /* Look up RC values */
  253|     10|        lib = NC_rclookup(key_lib, NULL, NULL);
  254|     10|        init = NC_rclookup(key_init, NULL, NULL);
  255|     10|        magic = NC_rclookup(key_magic, NULL, NULL);
  256|       |        
  257|       |        /* If both LIBRARY and INIT are present, try to load the plugin */
  258|     10|        if (lib && init) {
  ------------------
  |  Branch (258:13): [True: 0, False: 10]
  |  Branch (258:20): [True: 0, False: 0]
  ------------------
  259|      0|            if ((stat = load_udf_plugin(i, lib, init, magic))) {
  ------------------
  |  Branch (259:17): [True: 0, False: 0]
  ------------------
  260|      0|                nclog(NCLOGWARN, "Failed to load UDF%d plugin from %s: %d", i, lib, stat);
  ------------------
  |  |   23|      0|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  261|      0|            }
  262|     10|        } else if (lib || init) {
  ------------------
  |  Branch (262:20): [True: 0, False: 10]
  |  Branch (262:27): [True: 0, False: 10]
  ------------------
  263|       |            /* Warn about partial configuration */
  264|      0|            nclog(NCLOGWARN, "Ignoring partial UDF%d configuration "
  ------------------
  |  |   23|      0|#define NCLOGWARN  (2)	/* Warnings */
  ------------------
  265|      0|                  "(both NETCDF.UDF%d.LIBRARY and NETCDF.UDF%d.INIT are required)",
  266|      0|                  i, i, i);
  267|      0|        }
  268|     10|    }
  269|       |    
  270|       |    /* Always return success - plugin loading failures are not fatal */
  271|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  272|      1|}

NC_readfile:
  274|      2|{
  275|      2|    int stat;
  276|      2|    stat = NC_readfilen(filename, content, -1);
  277|      2|    return stat;
  278|      2|}
NC_readfilen:
  282|      2|{
  283|      2|    int ret = NC_NOERR;
  ------------------
  |  |  417|      2|#define NC_NOERR        0          /**< No Error */
  ------------------
  284|      2|    FILE* stream = NULL;
  285|       |
  286|      2|    stream = NCfopen(filename,"r");
  ------------------
  |  |  210|      2|#define NCfopen(path,flags) fopen((path),(flags))
  ------------------
  287|      2|    if(stream == NULL) {ret=errno; goto done;}
  ------------------
  |  Branch (287:8): [True: 2, False: 0]
  ------------------
  288|      0|    ret = NC_readfileF(stream,content,amount);
  289|      0|    if (stream) fclose(stream);
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      2|done:
  291|      2|    return ret;
  292|      0|}

NC_check_id:
   43|    289|{
   44|    289|    NC* nc = find_in_NCList(ncid);
   45|    289|    if(nc == NULL) return NC_EBADID;
  ------------------
  |  |  424|      0|#define	NC_EBADID	(-33)
  ------------------
  |  Branch (45:8): [True: 0, False: 289]
  ------------------
   46|    289|    if(ncpp) *ncpp = nc;
  ------------------
  |  Branch (46:8): [True: 289, False: 0]
  ------------------
   47|    289|    return NC_NOERR;
  ------------------
  |  |  417|    289|#define NC_NOERR        0          /**< No Error */
  ------------------
   48|    289|}
free_NC:
   61|    257|{
   62|    257|    if(ncp == NULL)
  ------------------
  |  Branch (62:8): [True: 0, False: 257]
  ------------------
   63|      0|        return;
   64|    257|    if(ncp->path)
  ------------------
  |  Branch (64:8): [True: 257, False: 0]
  ------------------
   65|    257|        free(ncp->path);
   66|       |    /* We assume caller has already cleaned up ncp->dispatchdata */
   67|    257|    free(ncp);
   68|    257|}
new_NC:
   87|    257|{
   88|    257|    NC *ncp = (NC*)calloc(1,sizeof(NC));
   89|    257|    if(ncp == NULL) return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (89:8): [True: 0, False: 257]
  ------------------
   90|    257|    ncp->dispatch = dispatcher;
   91|    257|    ncp->path = nulldup(path);
  ------------------
  |  |  147|    257|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 257]
  |  |  ------------------
  ------------------
   92|    257|    ncp->mode = mode;
   93|    257|    if(ncp->path == NULL) { /* fail */
  ------------------
  |  Branch (93:8): [True: 0, False: 257]
  ------------------
   94|      0|        free_NC(ncp);
   95|      0|        return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
   96|      0|    }
   97|    257|    if(ncpp) {
  ------------------
  |  Branch (97:8): [True: 257, False: 0]
  ------------------
   98|    257|        *ncpp = ncp;
   99|    257|    } else {
  100|      0|        free_NC(ncp);
  101|      0|    }
  102|    257|    return NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  103|    257|}
nc_get_default_format:
  155|    287|{
  156|    287|    return default_create_format;
  157|    287|}

ncbytesnew:
   36|    512|{
   37|    512|  NCbytes* bb = (NCbytes*)malloc(sizeof(NCbytes));
   38|    512|  if(bb == NULL) return (ncbytesfail(),NULL);
  ------------------
  |  Branch (38:6): [True: 0, False: 512]
  ------------------
   39|    512|  bb->alloc=0;
   40|    512|  bb->length=0;
   41|       |  bb->content=NULL;
   42|    512|  bb->extendible = 1;
   43|    512|  return bb;
   44|    512|}
ncbytessetalloc:
   48|     12|{
   49|     12|  char* newcontent;
   50|     12|  if(bb == NULL) return ncbytesfail();
  ------------------
  |  Branch (50:6): [True: 0, False: 12]
  ------------------
   51|     12|  if(sz == 0) {sz = (bb->alloc?2*bb->alloc:DEFAULTALLOC);}
  ------------------
  |  |   17|      0|#define DEFAULTALLOC 1024
  ------------------
  |  Branch (51:6): [True: 0, False: 12]
  |  Branch (51:22): [True: 0, False: 0]
  ------------------
   52|     12|  if(bb->alloc >= sz) return TRUE;
  ------------------
  |  |   11|      3|#define TRUE 1
  ------------------
  |  Branch (52:6): [True: 3, False: 9]
  ------------------
   53|      9|  if(!bb->extendible) return ncbytesfail();
  ------------------
  |  Branch (53:6): [True: 0, False: 9]
  ------------------
   54|      9|  newcontent=(char*)calloc(sz,sizeof(char));
   55|      9|  if(newcontent == NULL) ncbytesfail();
  ------------------
  |  Branch (55:6): [True: 0, False: 9]
  ------------------
   56|      9|  if(bb->alloc > 0 && bb->length > 0 && bb->content != NULL) {
  ------------------
  |  Branch (56:6): [True: 8, False: 1]
  |  Branch (56:23): [True: 8, False: 0]
  |  Branch (56:41): [True: 8, False: 0]
  ------------------
   57|      8|    memcpy((void*)newcontent,(void*)bb->content,sizeof(char)*bb->length);
   58|      8|  }
   59|      9|  if(bb->content != NULL) free(bb->content);
  ------------------
  |  Branch (59:6): [True: 8, False: 1]
  ------------------
   60|      9|  bb->content=newcontent;
   61|      9|  bb->alloc=sz;
   62|      9|  return TRUE;
  ------------------
  |  |   11|      9|#define TRUE 1
  ------------------
   63|      9|}
ncbytesfree:
   67|    512|{
   68|    512|  if(bb == NULL) return;
  ------------------
  |  Branch (68:6): [True: 0, False: 512]
  ------------------
   69|    512|  if(bb->extendible && bb->content != NULL) free(bb->content);
  ------------------
  |  Branch (69:6): [True: 512, False: 0]
  |  Branch (69:24): [True: 0, False: 512]
  ------------------
   70|    512|  free(bb);
   71|    512|}
ncbytesappend:
  112|      3|{
  113|      3|  char s[2];
  114|      3|  if(bb == NULL) return ncbytesfail();
  ------------------
  |  Branch (114:6): [True: 0, False: 3]
  ------------------
  115|      3|  s[0] = elem;
  116|      3|  s[1] = '\0';
  117|      3|  ncbytesappendn(bb,s,1);
  118|      3|  return TRUE;
  ------------------
  |  |   11|      3|#define TRUE 1
  ------------------
  119|      3|}
ncbytescat:
  124|      9|{
  125|      9|  if(bb == NULL) return ncbytesfail();
  ------------------
  |  Branch (125:6): [True: 0, False: 9]
  ------------------
  126|      9|  if(s == NULL) return 1;
  ------------------
  |  Branch (126:6): [True: 0, False: 9]
  ------------------
  127|      9|  ncbytesappendn(bb,(void*)s,strlen(s)+1); /* include trailing null*/
  128|       |  /* back up over the trailing null*/
  129|      9|  if(bb->length == 0) return ncbytesfail();
  ------------------
  |  Branch (129:6): [True: 0, False: 9]
  ------------------
  130|      9|  bb->length--;
  131|      9|  return 1;
  132|      9|}
ncbytesappendn:
  136|     12|{
  137|     12|  if(bb == NULL || elem == NULL) return ncbytesfail();
  ------------------
  |  Branch (137:6): [True: 0, False: 12]
  |  Branch (137:20): [True: 0, False: 12]
  ------------------
  138|     12|  if(n == 0) {n = strlen((char*)elem);}
  ------------------
  |  Branch (138:6): [True: 0, False: 12]
  ------------------
  139|     12|  ncbytessetalloc(bb,bb->length+n);
  140|     12|  memcpy((void*)&bb->content[bb->length],(void*)elem,n);
  141|     12|  bb->length += n;
  142|     12|  return TRUE;
  ------------------
  |  |   11|     12|#define TRUE 1
  ------------------
  143|     12|}
ncbytesextract:
  169|      1|{
  170|      1|    char* result = bb->content;
  171|      1|    bb->alloc = 0;
  172|      1|    bb->length = 0;
  173|       |    bb->content = NULL;
  174|      1|    return result;
  175|      1|}
ncbytesnull:
  193|      1|{
  194|      1|    ncbytesappend(bb,'\0');
  195|      1|    bb->length--;
  196|      1|    return 1;
  197|      1|}

NC_hashmapkey:
  166|    624|{
  167|    624|    return (nchashkey_t)NC_crc64(0,(void*)key,(unsigned int)size);
  168|    624|}
NC_hashmapnew:
  172|    156|{
  173|    156|    NC_hashmap* hm = NULL;
  174|       |
  175|    156|    Trace("NC_hashmapnew");
  176|       |
  177|    156|    hm = (NC_hashmap*)malloc(sizeof(NC_hashmap));
  178|       |
  179|    156|    if(startsize == 0 || startsize < MINTABLESIZE)
  ------------------
  |  |   58|    156|#define MINTABLESIZE 131U
  ------------------
  |  Branch (179:8): [True: 0, False: 156]
  |  Branch (179:26): [True: 17, False: 139]
  ------------------
  180|     17|	startsize = MINTABLESIZE;
  ------------------
  |  |   58|     17|#define MINTABLESIZE 131U
  ------------------
  181|    139|    else {
  182|    139|    if(startsize > SIZE_MAX / 4){nullfree(hm);return 0;}
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (182:8): [True: 0, False: 139]
  ------------------
  183|    139|	startsize *= 4;
  184|    139|	startsize /= 3;
  185|    139|	startsize = findPrimeGreaterThan(startsize);
  186|    139|	if(startsize == 0) {nullfree(hm); return 0;}
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (186:5): [True: 0, False: 139]
  ------------------
  187|    139|    }
  188|    156|    hm->table = (NC_hentry*)calloc(sizeof(NC_hentry), (size_t)startsize);
  189|    156|    if(hm->table == NULL) {nullfree(hm);return 0;}
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (189:8): [True: 0, False: 156]
  ------------------
  190|    156|    hm->alloc = startsize;
  191|    156|    hm->active = 0;
  192|    156|    return hm;
  193|    156|}
NC_hashmapadd:
  197|   585k|{
  198|   585k|  NC_hentry* entry;
  199|   585k|  nchashkey_t hashkey;
  ------------------
  |  |   42|   585k|#define nchashkey_t unsigned
  ------------------
  200|       |
  201|   585k|    Trace("NC_hashmapadd");
  202|       |
  203|   585k|    if(key == NULL || keysize == 0)
  ------------------
  |  Branch (203:8): [True: 0, False: 585k]
  |  Branch (203:23): [True: 584k, False: 624]
  ------------------
  204|   584k|      return 0;
  205|    624|    hashkey = NC_hashmapkey(key,keysize);
  206|       |
  207|    624|    if((hash->alloc*3)/4 <= hash->active)
  ------------------
  |  Branch (207:8): [True: 0, False: 624]
  ------------------
  208|      0|	{if(!rehash(hash)) return 0;}
  ------------------
  |  Branch (208:6): [True: 0, False: 0]
  ------------------
  209|    624|    for(;;) {
  210|    624|	size_t index;
  211|    624|	if(!locate(hash,hashkey,key,keysize,&index,1)) {
  ------------------
  |  Branch (211:5): [True: 0, False: 624]
  ------------------
  212|      0|	    if(!rehash(hash)) return 0;
  ------------------
  |  Branch (212:9): [True: 0, False: 0]
  ------------------
  213|      0|	    continue; /* try on larger table */
  214|      0|	}
  215|    624|        entry = &hash->table[index];
  216|    624|	if(entry->flags & ACTIVE) {
  ------------------
  |  |   63|    624|#define ACTIVE 1
  ------------------
  |  Branch (216:5): [True: 436, False: 188]
  ------------------
  217|       |	    /* key already exists in table => overwrite data */
  218|    436|	    entry->data = data;
  219|    436|	    return 1;
  220|    436|        } else { /* !ACTIVE || DELETED */
  221|    188|	    entry->flags = ACTIVE;
  ------------------
  |  |   63|    188|#define ACTIVE 1
  ------------------
  222|    188|	    entry->data = data;
  223|    188|	    entry->hashkey = hashkey;
  224|    188|	    entry->keysize = keysize;
  225|    188|	    entry->key = malloc(keysize+1);
  226|    188|	    if(entry->key == NULL)
  ------------------
  |  Branch (226:9): [True: 0, False: 188]
  ------------------
  227|      0|		return 0;
  228|    188|	    memcpy(entry->key,key,keysize);
  229|    188|	    entry->key[keysize] = '\0'; /* ensure null terminated */
  230|    188|	    ++hash->active;
  231|    188|	    return 1;
  232|    188|	}
  233|    624|     }
  234|      0|     return 0;
  235|    624|}
NC_hashmapfree:
  340|    156|{
  341|    156|    Trace("NC_hashmapfree");
  342|    156|    if(hash) {
  ------------------
  |  Branch (342:8): [True: 156, False: 0]
  ------------------
  343|    156|      int i;
  344|       |#ifdef DEBUG
  345|       |      printhashmapstats(hash);
  346|       |#endif
  347|  1.03G|      for(i=0;i<hash->alloc;i++) {
  ------------------
  |  Branch (347:15): [True: 1.03G, False: 156]
  ------------------
  348|  1.03G|	NC_hentry* he = &hash->table[i];
  349|  1.03G|	if((he->flags & ACTIVE) && he->key != NULL)
  ------------------
  |  |   63|  1.03G|#define ACTIVE 1
  ------------------
  |  Branch (349:5): [True: 188, False: 1.03G]
  |  Branch (349:29): [True: 188, False: 0]
  ------------------
  350|    188|	   free(he->key);
  351|  1.03G|      }
  352|    156|      free(hash->table);
  353|    156|      free(hash);
  354|    156|    }
  355|    156|    return 1;
  356|    156|}
nchashmap.c:locate:
  118|    624|{
  119|    624|    size_t i;
  120|    624|    size_t index;
  121|    624|    size_t step = 1; /* simple linear probe */
  122|    624|    int deletefound = 0;
  123|    624|    size_t deletedindex = 0; /* first deleted entry encountered */
  124|    624|    NC_hentry* entry;
  125|    624|    Trace("locate");
  126|       |    /* Compute starting point */
  127|    624|    assert(hash->alloc > 0);
  ------------------
  |  Branch (127:5): [True: 0, False: 624]
  |  Branch (127:5): [True: 624, False: 0]
  ------------------
  128|    624|    index = (size_t)(hashkey % hash->alloc);
  129|       |
  130|       |    /* Search table using linear probing */
  131|    625|    for (i = 0; i < hash->alloc; i++) {
  ------------------
  |  Branch (131:17): [True: 625, False: 0]
  ------------------
  132|    625|      entry = &hash->table[index];
  133|    625|      if(entry->flags & ACTIVE) {
  ------------------
  |  |   63|    625|#define ACTIVE 1
  ------------------
  |  Branch (133:10): [True: 437, False: 188]
  ------------------
  134|    437|	    if(indexp) *indexp = index; /* assume a match */
  ------------------
  |  Branch (134:9): [True: 437, False: 0]
  ------------------
  135|    437|            if(entry->hashkey == hashkey && entry->keysize == keysize) {
  ------------------
  |  Branch (135:16): [True: 437, False: 0]
  |  Branch (135:45): [True: 436, False: 1]
  ------------------
  136|       |		/* Check content */
  137|    436|		if(memcmp(entry->key,key,keysize)==0)
  ------------------
  |  Branch (137:6): [True: 436, False: 0]
  ------------------
  138|    436|		    return 1;
  139|    436|            }
  140|       |	    /* Keep looking */
  141|    437|	} else if(entry->flags & DELETED) {
  ------------------
  |  |   65|    188|#define DELETED 2
  ------------------
  |  Branch (141:12): [True: 0, False: 188]
  ------------------
  142|      0|	    if(!deletefound) {/* save this position */
  ------------------
  |  Branch (142:9): [True: 0, False: 0]
  ------------------
  143|      0|	        deletefound = 1;
  144|      0|		deletedindex = index;
  145|      0|	    }
  146|       |	    /* Keep looking */
  147|    188| 	} else { /* Empty slot */
  148|    188|	    if(indexp) *indexp = index;
  ------------------
  |  Branch (148:9): [True: 188, False: 0]
  ------------------
  149|    188|	    return 1;
  150|    188|	}
  151|       |        /* linear probe */
  152|    625|	assert(hash->alloc > 0);
  ------------------
  |  Branch (152:2): [True: 0, False: 1]
  |  Branch (152:2): [True: 1, False: 0]
  ------------------
  153|      1|	index = (index + step) % hash->alloc;
  154|      1|    }
  155|      0|    if(deletedok && deletefound) {
  ------------------
  |  Branch (155:8): [True: 0, False: 0]
  |  Branch (155:21): [True: 0, False: 0]
  ------------------
  156|      0|	if(indexp) *indexp = deletedindex;
  ------------------
  |  Branch (156:5): [True: 0, False: 0]
  ------------------
  157|      0|	return 1;
  158|      0|    }
  159|      0|    return 0;
  160|      0|}
nchashmap.c:findPrimeGreaterThan:
  435|    139|{
  436|    139|      size_t n = NC_nprimes;
  437|    139|      size_t L = 1; /* skip leading flag number */
  438|    139|      size_t R = (n - 2); /* skip trailing flag */
  439|    139|      size_t v = 0;
  440|    139|      size_t m;
  441|       |
  442|    139|      if(val >= 0xFFFFFFFF)
  ------------------
  |  Branch (442:10): [True: 0, False: 139]
  ------------------
  443|      0|        return 0; /* Too big */
  444|    139|      v = val;
  445|       |
  446|    139|      if (v > NC_primes[n - 2]) {
  ------------------
  |  Branch (446:11): [True: 57, False: 82]
  ------------------
  447|       |        /*
  448|       |         If we have a value greater than the largest value in the 
  449|       |         NC_primes table, then search for a prime instead of just
  450|       |         doing a simple lookup.
  451|       |        */
  452|     57|	return nextPrime(val);
  453|     57|      }
  454|       |
  455|  1.05k|      for(;;) {
  456|  1.05k|        if(L >= R) break;
  ------------------
  |  Branch (456:12): [True: 0, False: 1.05k]
  ------------------
  457|       |
  458|  1.05k|        m = (L + R) / 2;
  459|       |        /* is this an acceptable prime? */
  460|  1.05k|        if(NC_primes[m-1] < v && NC_primes[m] >= v)
  ------------------
  |  Branch (460:12): [True: 360, False: 696]
  |  Branch (460:34): [True: 82, False: 278]
  ------------------
  461|     82|          return NC_primes[m]; /* acceptable*/
  462|    974|        else if(NC_primes[m-1] >= v)
  ------------------
  |  Branch (462:17): [True: 696, False: 278]
  ------------------
  463|    696|          R = m;
  464|    278|        else if(NC_primes[m] < v)
  ------------------
  |  Branch (464:17): [True: 278, False: 0]
  ------------------
  465|    278|          L = m;
  466|  1.05k|      }
  467|      0|      return 0;
  468|     82|}
nchashmap.c:nextPrime:
  409|     57|{
  410|     57|    if (val <= 1)
  ------------------
  |  Branch (410:9): [True: 0, False: 57]
  ------------------
  411|      0|        return 2;
  412|       |
  413|     57|    size_t prime = val;
  414|     57|    if (prime % 2 == 0) { /* Make sure `prime` is odd */
  ------------------
  |  Branch (414:9): [True: 26, False: 31]
  ------------------
  415|     26|      prime--;
  416|     26|    }
  417|       |
  418|       |    /* Loop continuously until isPrime returns */
  419|       |    /* true for a number greater than n */
  420|    396|    for (;;) {
  421|    396|        prime += 2;
  422|    396|        if (isPrime(prime))
  ------------------
  |  Branch (422:13): [True: 57, False: 339]
  ------------------
  423|     57|	  break;
  424|    396|    }
  425|     57|    return prime;
  426|     57|}
nchashmap.c:isPrime:
  389|    396|{
  390|    396|    size_t i;
  391|       |    
  392|    396|    if (n <= 1)  return 0;
  ------------------
  |  Branch (392:9): [True: 0, False: 396]
  ------------------
  393|    396|    if (n <= 3)  return 1;
  ------------------
  |  Branch (393:9): [True: 0, False: 396]
  ------------------
  394|       |    
  395|  37.1k|    for (i=1; i < NC_nprimes - 1; i++) {
  ------------------
  |  Branch (395:15): [True: 37.1k, False: 0]
  ------------------
  396|  37.1k|      size_t prime = NC_primes[i];
  397|  37.1k|      if (n % prime == 0) {
  ------------------
  |  Branch (397:11): [True: 339, False: 36.8k]
  ------------------
  398|    339|	return 0;
  399|    339|      }
  400|  36.8k|      if (prime * prime > n) {
  ------------------
  |  Branch (400:11): [True: 57, False: 36.7k]
  ------------------
  401|     57|	break;
  402|     57|      }
  403|  36.8k|    }
  404|     57|    return 1;
  405|    396|}

nclistnew:
   46|  1.15k|{
   47|  1.15k|  NClist* l;
   48|       |/*
   49|       |  if(!ncinitialized) {
   50|       |    memset((void*)&ncDATANULL,0,sizeof(void*));
   51|       |    ncinitialized = 1;
   52|       |  }
   53|       |*/
   54|  1.15k|  l = (NClist*)calloc(1,sizeof(NClist));
   55|  1.15k|  if(l) {
  ------------------
  |  Branch (55:6): [True: 1.15k, False: 0]
  ------------------
   56|  1.15k|    l->alloc=0;
   57|  1.15k|    l->length=0;
   58|       |    l->content=NULL;
   59|  1.15k|    l->extendible = 1;
   60|  1.15k|  }
   61|  1.15k|  return l;
   62|  1.15k|}
nclistfree:
   66|  1.72k|{
   67|  1.72k|  if(l) {
  ------------------
  |  Branch (67:6): [True: 1.15k, False: 575]
  ------------------
   68|  1.15k|    l->alloc = 0;
   69|  1.15k|    if(l->extendible && l->content != NULL) {free(l->content); l->content = NULL;}
  ------------------
  |  Branch (69:8): [True: 1.15k, False: 0]
  |  Branch (69:25): [True: 864, False: 290]
  ------------------
   70|  1.15k|    free(l);
   71|  1.15k|  }
   72|  1.72k|  return TRUE;
  ------------------
  |  |   19|  1.72k|#define TRUE 1
  ------------------
   73|  1.72k|}
nclistfreeall:
   80|  1.43k|{
   81|  1.43k|    nclistclearall(l);
   82|  1.43k|    return nclistfree(l);
   83|  1.43k|}
nclistclearall:
   90|  1.43k|{
   91|  1.43k|  size_t i,len;
   92|  1.43k|  if(l == NULL) return TRUE;
  ------------------
  |  |   19|    574|#define TRUE 1
  ------------------
  |  Branch (92:6): [True: 574, False: 863]
  ------------------
   93|    863|  len = l->length;
   94|    865|  for(i=0;i<len;i++) {
  ------------------
  |  Branch (94:11): [True: 2, False: 863]
  ------------------
   95|      2|      void* value = l->content[i];
   96|      2|      if(value != NULL) free(value);
  ------------------
  |  Branch (96:10): [True: 2, False: 0]
  ------------------
   97|      2|  }
   98|    863|  nclistsetlength(l,0);
   99|    863|  return TRUE;
  ------------------
  |  |   19|    863|#define TRUE 1
  ------------------
  100|  1.43k|}
nclistsetalloc:
  108|    864|{
  109|    864|  void** newcontent = NULL;
  110|    864|  size_t alloc;
  111|    864|  if(l == NULL) return nclistfail();
  ------------------
  |  Branch (111:6): [True: 0, False: 864]
  ------------------
  112|    864|  if(newalloc == 0) newalloc = DEFAULTALLOC; /* force newalloc to be greater than 0 */
  ------------------
  |  |   25|      1|#define DEFAULTALLOC 16
  ------------------
  |  Branch (112:6): [True: 1, False: 863]
  ------------------
  113|    864|  if(l->alloc >= newalloc) {return TRUE;} /* already enough space */
  ------------------
  |  |   19|      0|#define TRUE 1
  ------------------
  |  Branch (113:6): [True: 0, False: 864]
  ------------------
  114|       |  /* Iterate to find an allocation greater or equal to newalloc */
  115|    864|  alloc = l->alloc;
  116|  1.73k|  while(alloc < newalloc)
  ------------------
  |  Branch (116:9): [True: 869, False: 864]
  ------------------
  117|    869|      alloc = (2*alloc + 1); /* Double until we have a suitable allocation; +1 in case alloc is zero*/
  118|    864|  newcontent=(void**)calloc(alloc,sizeof(void*));
  119|    864|  if(newcontent == NULL) return nclistfail(); /* out of memory */
  ------------------
  |  Branch (119:6): [True: 0, False: 864]
  ------------------
  120|       |  /* Copy data, if any,  to new contents */
  121|    864|  if(l->alloc > 0 && l->length > 0 && l->content != NULL)
  ------------------
  |  Branch (121:6): [True: 0, False: 864]
  |  Branch (121:22): [True: 0, False: 0]
  |  Branch (121:39): [True: 0, False: 0]
  ------------------
  122|      0|    memcpy((void*)newcontent,(void*)l->content,sizeof(void*)*l->length);
  123|    864|  if(l->content != NULL) free(l->content); /* reclaim old contents */
  ------------------
  |  Branch (123:6): [True: 0, False: 864]
  ------------------
  124|    864|  l->content = newcontent;
  125|    864|  l->alloc = alloc;
  126|    864|  return TRUE;
  ------------------
  |  |   19|    864|#define TRUE 1
  ------------------
  127|    864|}
nclistsetlength:
  131|    864|{
  132|    864|  if(l == NULL) return nclistfail();
  ------------------
  |  Branch (132:6): [True: 0, False: 864]
  ------------------
  133|    864|  if(newlen >= l->alloc && !nclistsetalloc(l,newlen+1)) /* +1 in case newlen == l->alloc */
  ------------------
  |  Branch (133:6): [True: 863, False: 1]
  |  Branch (133:28): [True: 0, False: 863]
  ------------------
  134|      0|      return nclistfail();
  135|    864|  if(newlen > l->length) {
  ------------------
  |  Branch (135:6): [True: 1, False: 863]
  ------------------
  136|       |      /* clear any extension */
  137|      1|      memset(&l->content[l->length],0,(newlen - l->length)*sizeof(void*));
  138|      1|  }
  139|    864|  l->length = newlen;
  140|    864|  return TRUE;
  ------------------
  |  |   19|    864|#define TRUE 1
  ------------------
  141|    864|}
nclistget:
  145|      1|{
  146|      1|  if(l == NULL) return (nclistfail(),NULL);
  ------------------
  |  Branch (146:6): [True: 0, False: 1]
  ------------------
  147|      1|  if(l->length == 0) return NULL;
  ------------------
  |  Branch (147:6): [True: 0, False: 1]
  ------------------
  148|      1|  if(index >= l->length) return NULL;
  ------------------
  |  Branch (148:6): [True: 0, False: 1]
  ------------------
  149|      1|  return l->content[index];
  150|      1|}
nclistpush:
  188|      1|{
  189|      1|  if(l == NULL) return nclistfail();
  ------------------
  |  Branch (189:6): [True: 0, False: 1]
  ------------------
  190|      1|  if(l->content == NULL)
  ------------------
  |  Branch (190:6): [True: 1, False: 0]
  ------------------
  191|      1|      nclistsetalloc(l,0);
  192|      1|  if(l->length >= l->alloc) nclistsetalloc(l,l->length+1);
  ------------------
  |  Branch (192:6): [True: 0, False: 1]
  ------------------
  193|      1|  l->content[l->length] = (void*)elem;
  194|      1|  l->length++;
  195|      1|  return TRUE;
  ------------------
  |  |   19|      1|#define TRUE 1
  ------------------
  196|      1|}

free_NCList:
   56|    257|{
   57|    257|    if(numfiles > 0) return; /* not empty */
  ------------------
  |  Branch (57:8): [True: 0, False: 257]
  ------------------
   58|    257|    if(nc_filelist != NULL) free(nc_filelist);
  ------------------
  |  Branch (58:8): [True: 257, False: 0]
  ------------------
   59|       |    nc_filelist = NULL;
   60|    257|}
add_to_NCList:
   83|    257|{
   84|    257|    unsigned int i;
   85|    257|    unsigned int new_id;
   86|    257|    if(nc_filelist == NULL) {
  ------------------
  |  Branch (86:8): [True: 257, False: 0]
  ------------------
   87|    257|        if (!(nc_filelist = calloc(1, sizeof(NC*)*NCFILELISTLENGTH)))
  ------------------
  |  |   28|    257|#define NCFILELISTLENGTH 0x10000
  ------------------
  |  Branch (87:13): [True: 0, False: 257]
  ------------------
   88|      0|            return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
   89|    257|        numfiles = 0;
   90|    257|    }
   91|       |
   92|    257|    new_id = 0; /* id's begin at 1 */
   93|    257|    for(i=1; i < NCFILELISTLENGTH; i++) {
  ------------------
  |  |   28|    257|#define NCFILELISTLENGTH 0x10000
  ------------------
  |  Branch (93:14): [True: 257, False: 0]
  ------------------
   94|    257|        if(nc_filelist[i] == NULL) {new_id = i; break;}
  ------------------
  |  Branch (94:12): [True: 257, False: 0]
  ------------------
   95|    257|    }
   96|    257|    if(new_id == 0) return NC_ENOMEM; /* no more slots */
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (96:8): [True: 0, False: 257]
  ------------------
   97|    257|    nc_filelist[new_id] = ncp;
   98|    257|    numfiles++;
   99|    257|    ncp->ext_ncid = (int)(new_id << ID_SHIFT);
  ------------------
  |  |   22|    257|#define ID_SHIFT (16)
  ------------------
  100|    257|    return NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  101|    257|}
del_from_NCList:
  146|    257|{
  147|    257|    unsigned int ncid = ((unsigned int)ncp->ext_ncid) >> ID_SHIFT;
  ------------------
  |  |   22|    257|#define ID_SHIFT (16)
  ------------------
  148|    257|    if(numfiles == 0 || ncid == 0 || nc_filelist == NULL) return;
  ------------------
  |  Branch (148:8): [True: 0, False: 257]
  |  Branch (148:25): [True: 0, False: 257]
  |  Branch (148:38): [True: 0, False: 257]
  ------------------
  149|    257|    if(nc_filelist[ncid] != ncp) return;
  ------------------
  |  Branch (149:8): [True: 0, False: 257]
  ------------------
  150|       |
  151|    257|    nc_filelist[ncid] = NULL;
  152|    257|    numfiles--;
  153|       |
  154|       |    /* If all files have been closed, release the filelist memory. */
  155|    257|    if (numfiles == 0)
  ------------------
  |  Branch (155:9): [True: 257, False: 0]
  ------------------
  156|    257|        free_NCList();
  157|    257|}
find_in_NCList:
  171|    289|{
  172|    289|    NC* f = NULL;
  173|       |
  174|       |    /* Discard the first two bytes of ext_ncid to get ncid. */
  175|    289|    unsigned int ncid = ((unsigned int)ext_ncid) >> ID_SHIFT;
  ------------------
  |  |   22|    289|#define ID_SHIFT (16)
  ------------------
  176|       |
  177|       |    /* If we have a filelist, there will be an entry, possibly NULL,
  178|       |     * for this ncid. */
  179|    289|    if (nc_filelist)
  ------------------
  |  Branch (179:9): [True: 289, False: 0]
  ------------------
  180|    289|    {
  181|    289|        assert(numfiles);
  ------------------
  |  Branch (181:9): [True: 0, False: 289]
  |  Branch (181:9): [True: 289, False: 0]
  ------------------
  182|    289|        f = nc_filelist[ncid];
  183|    289|    }
  184|       |
  185|       |    /* For classic files, ext_ncid must be a multiple of
  186|       |     * (1<<ID_SHIFT). That is, the group part of the ext_ncid (the
  187|       |     * last two bytes) must be zero. If not, then return NULL, which
  188|       |     * will eventually lead to an NC_EBADID error being returned to
  189|       |     * user. */
  190|    289|    if (f != NULL && f->dispatch != NULL
  ------------------
  |  Branch (190:9): [True: 289, False: 0]
  |  Branch (190:22): [True: 289, False: 0]
  ------------------
  191|    289|	&& f->dispatch->model == NC_FORMATX_NC3 && (ext_ncid % (1<<ID_SHIFT)))
  ------------------
  |  |  246|    578|#define NC_FORMATX_NC3       (1)
  ------------------
              	&& f->dispatch->model == NC_FORMATX_NC3 && (ext_ncid % (1<<ID_SHIFT)))
  ------------------
  |  |   22|    289|#define ID_SHIFT (16)
  ------------------
  |  Branch (191:5): [True: 289, False: 0]
  |  Branch (191:45): [True: 0, False: 289]
  ------------------
  192|      0|        return NULL;
  193|       |
  194|    289|    return f;
  195|    289|}

ncloginit:
   60|      1|{
   61|      1|    const char* envv = NULL;
   62|      1|    if(nclogginginitialized)
  ------------------
  |  Branch (62:8): [True: 0, False: 1]
  ------------------
   63|      0|	return;
   64|      1|    nclogginginitialized = 1;
   65|      1|    memset(&nclog_global,0,sizeof(nclog_global));
   66|      1|    ncsetloglevel(NCLOGOFF);
  ------------------
  |  |   21|      1|#define NCLOGOFF   (0)	/* Stop Logging */
  ------------------
   67|      1|    nclog_global.tracelevel = -1;    
   68|      1|    nclog_global.nclogstream = stderr;
   69|       |    /* Use environment variables to preset nclogging state*/
   70|      1|    envv = getenv(NCENVLOGGING);
  ------------------
  |  |   16|      1|#define NCENVLOGGING "NCLOGGING"
  ------------------
   71|      1|    if(envv != NULL) {
  ------------------
  |  Branch (71:8): [True: 0, False: 1]
  ------------------
   72|      0|	int level = nctagforname(envv);
   73|      0|        if(level > 0) {
  ------------------
  |  Branch (73:12): [True: 0, False: 0]
  ------------------
   74|      0|            ncsetloglevel(NCLOGNOTE);
  ------------------
  |  |   24|      0|#define NCLOGNOTE  (3)	/* General info */
  ------------------
   75|      0|        }
   76|      0|    }
   77|      1|    envv = getenv(NCENVTRACING);
  ------------------
  |  |   17|      1|#define NCENVTRACING "NCTRACING"
  ------------------
   78|      1|    if(envv != NULL) nctracelevel(atoi(envv));
  ------------------
  |  Branch (78:8): [True: 0, False: 1]
  ------------------
   79|      1|}
ncsetloglevel:
   93|      1|{
   94|      1|    int was;
   95|      1|    if(!nclogginginitialized) ncloginit();
  ------------------
  |  Branch (95:8): [True: 0, False: 1]
  ------------------
   96|      1|    was = nclog_global.loglevel;
   97|      1|    if(level >= 0 && level <= NCLOGDEBUG)
  ------------------
  |  |   25|      1|#define NCLOGDEBUG (4)	/* Everything */
  ------------------
  |  Branch (97:8): [True: 1, False: 0]
  |  Branch (97:22): [True: 1, False: 0]
  ------------------
   98|      1|	nclog_global.loglevel = level;
   99|      1|    if(nclog_global.nclogstream == NULL) nclogopen(NULL);
  ------------------
  |  Branch (99:8): [True: 1, False: 0]
  ------------------
  100|      1|    return was;
  101|      1|}
nclogopen:
  105|      1|{
  106|      1|    if(!nclogginginitialized) ncloginit();
  ------------------
  |  Branch (106:8): [True: 0, False: 1]
  ------------------
  107|      1|    if(stream == NULL) stream = stderr;
  ------------------
  |  Branch (107:8): [True: 1, False: 0]
  ------------------
  108|      1|    nclog_global.nclogstream = stream;
  109|      1|    return 1;
  110|      1|}
nclog:
  123|      3|{
  124|      3|    if(fmt != NULL) {
  ------------------
  |  Branch (124:8): [True: 3, False: 0]
  ------------------
  125|      3|      va_list args;
  126|      3|      va_start(args, fmt);
  127|      3|      ncvlog(tag,fmt,args);
  128|       |      va_end(args);
  129|      3|    }
  130|      3|}
ncvlog:
  134|      3|{
  135|      3|    const char* prefix;
  136|       |
  137|      3|    if(!nclogginginitialized) ncloginit();
  ------------------
  |  Branch (137:8): [True: 0, False: 3]
  ------------------
  138|       |
  139|      3|    if(nclog_global.nclogstream == NULL) return; /* No place to send log message */
  ------------------
  |  Branch (139:8): [True: 0, False: 3]
  ------------------
  140|      3|    if(level != NCLOGERR) { /* If log level is an error, then force printing */
  ------------------
  |  |   22|      3|#define NCLOGERR   (1)	/* Errors */
  ------------------
  |  Branch (140:8): [True: 3, False: 0]
  ------------------
  141|      3|        if(nclog_global.loglevel < level) return;
  ------------------
  |  Branch (141:12): [True: 3, False: 0]
  ------------------
  142|      3|    }
  143|       |
  144|      0|    prefix = nctagname(level);
  145|      0|    fprintf(nclog_global.nclogstream,"%s: ",prefix);
  146|      0|    if(fmt != NULL) {
  ------------------
  |  Branch (146:8): [True: 0, False: 0]
  ------------------
  147|      0|      vfprintf(nclog_global.nclogstream, fmt, ap);
  148|      0|    }
  149|      0|    fprintf(nclog_global.nclogstream, "\n" );
  150|      0|    fflush(nclog_global.nclogstream);
  151|      0|}

ncuriparse:
  117|    287|{
  118|    287|    int ret = NC_NOERR;
  ------------------
  |  |  417|    287|#define NC_NOERR        0          /**< No Error */
  ------------------
  119|    287|    NCURI tmp;
  120|    287|    char* p;
  121|    287|    char* q;
  122|    287|    int isfile;
  123|    287|    int hashost;
  124|    287|    char* uri = NULL;
  125|    287|    NCURI* duri = NULL;
  126|    287|    char* prefix = NULL;
  127|    287|    char* next = NULL;
  128|    287|    NClist* params = nclistnew();
  129|    287|    NClist* querylist = nclistnew();
  130|    287|    size_t len0;
  131|    287|    char pathchar;
  132|       |
  133|    287|    if(uri0 == NULL)
  ------------------
  |  Branch (133:8): [True: 0, False: 287]
  ------------------
  134|      0|	{THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  135|       |
  136|    287|    len0 = strlen(uri0);
  137|    287|    if(len0 == 0)
  ------------------
  |  Branch (137:8): [True: 0, False: 287]
  ------------------
  138|      0|	{THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  139|       |
  140|       |    /* Create a local NCURI instance to hold
  141|       |       pointers into the parsed string
  142|       |    */
  143|    287|    memset(&tmp,0,sizeof(tmp));
  144|       |
  145|       |    /* make mutable copy. Add some extra space
  146|       |       because we will need to null terminate the host section
  147|       |       without losing the first character of the path section.
  148|       |    */
  149|    287|    uri = (char*)malloc(len0+1+1); /* +2 for nul term and for host section terminator */
  150|    287|    if(uri == NULL)
  ------------------
  |  Branch (150:8): [True: 0, False: 287]
  ------------------
  151|      0|	{THROW(NC_ENOMEM);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  152|       |    /* Safe because we allocated enough space right above (and */
  153|       |    /* `strdup` isn't usable because we need "one more char"). */
  154|    287|    strcpy(uri,uri0);
  155|       |
  156|       |    /* Walk the uri and do the following:
  157|       |	1. remove leading and trailing whitespace
  158|       |	2. convert all '\\' -> '\' (Temp hack to remove escape characters
  159|       |                                    inserted by Windows or MinGW)
  160|       |    */
  161|    287|    p = uri;
  162|    287|    while(*p == ' ') p++;
  ------------------
  |  Branch (162:11): [True: 0, False: 287]
  ------------------
  163|  3.73k|    for(q=uri;*p;p++) {if((*p == '\\' && p[1] == '\\')) {continue;} else {*q++ = *p;}}
  ------------------
  |  Branch (163:15): [True: 3.44k, False: 287]
  |  Branch (163:28): [True: 0, False: 3.44k]
  |  Branch (163:42): [True: 0, False: 0]
  ------------------
  164|    287|    while((q - 1) >= uri && *(q - 1) == ' ') q--;
  ------------------
  |  Branch (164:11): [True: 287, False: 0]
  |  Branch (164:29): [True: 0, False: 287]
  ------------------
  165|    287|    *q = '\0';
  166|       |
  167|    287|    p = uri;
  168|       |
  169|       |    /* break up the url into coarse pieces */
  170|    287|    if(*p == LBRACKET) {
  ------------------
  |  |   34|    287|#define LBRACKET '['
  ------------------
  |  Branch (170:8): [True: 0, False: 287]
  ------------------
  171|      0|        prefix = p;
  172|      0|        ret = collectprefixparams(p,&next); /* collect the prefix; convert to & form */
  173|      0|        if(ret != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (173:12): [True: 0, False: 0]
  ------------------
  174|      0|            {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  175|      0|         p = next;
  176|    287|    } else {
  177|    287|	prefix = NULL;
  178|    287|    }
  179|    287|    tmp.uri = p; /* will be the core */
  180|       |    /* Skip past the core of the url */
  181|    287|    next = nclocate(p,"?#");
  182|    287|    if(next != NULL) {
  ------------------
  |  Branch (182:8): [True: 0, False: 287]
  ------------------
  183|      0|	int c = *next;
  184|      0|	terminate(next);
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  185|      0|	next++;
  186|      0|	if(c == '?') {
  ------------------
  |  Branch (186:5): [True: 0, False: 0]
  ------------------
  187|      0|	    tmp.query = next;
  188|      0|	    next = nclocate(next,"#");
  189|      0|	    if(next == NULL)
  ------------------
  |  Branch (189:9): [True: 0, False: 0]
  ------------------
  190|      0|		tmp.fragment = NULL;
  191|      0|	    else {
  192|      0|		terminate(next);
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  193|      0|		next++;
  194|      0|	        tmp.fragment = next;
  195|      0|	    }
  196|      0|	} else { /*c == '#'*/
  197|      0|	    tmp.fragment = next;
  198|      0|	}
  199|      0|    }
  200|       |
  201|       |    /* Parse the prefix parameters */
  202|    287|    if(prefix != NULL) {
  ------------------
  |  Branch (202:8): [True: 0, False: 287]
  ------------------
  203|      0|        if(parselist(prefix,params) != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (203:12): [True: 0, False: 0]
  ------------------
  204|      0|            {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  205|      0|    }
  206|       |    /* Parse the fragment parameters into the params list */
  207|    287|    if(tmp.fragment != NULL) {
  ------------------
  |  Branch (207:8): [True: 0, False: 287]
  ------------------
  208|      0|        if(parselist(tmp.fragment,params) != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (208:12): [True: 0, False: 0]
  ------------------
  209|      0|            {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  210|      0|    }
  211|       |    /* Remove duplicates */
  212|    287|    removedups(params);
  213|    287|    tmp.fraglist = params;
  214|    287|    params = NULL;
  215|       |
  216|       |    /* Parse the query */
  217|    287|    if(tmp.query != NULL) {
  ------------------
  |  Branch (217:8): [True: 0, False: 287]
  ------------------
  218|      0|        if(parselist(tmp.query,querylist) != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (218:12): [True: 0, False: 0]
  ------------------
  219|      0|            {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  220|      0|	tmp.querylist = querylist;
  221|      0|	querylist = NULL;
  222|      0|    }
  223|       |
  224|       |    /* Now parse the core of the url */
  225|    287|    p = tmp.uri;
  226|       |
  227|       |    /* Mark the protocol */
  228|    287|    tmp.protocol = p;
  229|    287|    p = strchr(p,':');
  230|    287|    if(!p)
  ------------------
  |  Branch (230:8): [True: 287, False: 0]
  ------------------
  231|    287|	{THROW(NC_EURL);}
  ------------------
  |  |   27|    287|#define THROW(n) {ret=(n); goto done;}
  ------------------
  232|      0|    terminate(p); /*overwrite colon*/
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  233|      0|    p++; /* skip the colon */
  234|      0|    if(strlen(tmp.protocol)==0)
  ------------------
  |  Branch (234:8): [True: 0, False: 0]
  ------------------
  235|      0|	{THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  236|       |    /*
  237|       |       The legal formats for file: urls are a problem since
  238|       |       many variants are often accepted.
  239|       |       By RFC, the proper general format is: file://host/path,
  240|       |       where the 'host' can be omitted and defaults to 'localhost'.
  241|       |       and the path includes the leading '/'.
  242|       |       So, assuming no host, the format is: "file:///path".
  243|       |       Some implementations, however, ignore the host, and allow
  244|       |       the format: file:/path.
  245|       |       We also simplify things by assuming the host part is always empty.
  246|       |       which means we can have file:///path, but not file://..../path.
  247|       |       Note also in all cases, the leading '/' is considered part of the path,
  248|       |       which is then assumed to be an absolute path. But also note that
  249|       |       the windows drive letter has to be taken into account. Our rule is that
  250|       |       if the path looks like D:...,
  251|       |       where D is a single alphabetic letter (a-z or A-Z),
  252|       |       then it is a windows path and can be use in place of a /path.
  253|       |       Note also that it is desirable to support relative paths even
  254|       |       though the RFC technically does not allow this. This will occur
  255|       |       if the form is file://path where path does not start with '/'.
  256|       |       The rules implemented here (for file:) are then as follows
  257|       |       1. file:D:... : assume D: is a windows drive letter and treat D:... as the path
  258|       |       2. file:/X, where X does not start with a slash: treat /X as the path.
  259|       |       3. file://D:... : assume D: is a windows drive letter and treat as the path
  260|       |       4. file:///X, where X does not start with a slash: treat /X as the path.
  261|       |       5. file://X, where X does not start with a slash: treat X as the
  262|       |          relative path.
  263|       |       All other cases are disallowed.
  264|       |    */
  265|       |
  266|      0|    isfile = (strcmp(tmp.protocol,"file")==0);
  267|      0|    if(isfile) {
  ------------------
  |  Branch (267:8): [True: 0, False: 0]
  ------------------
  268|      0|	size_t l = strlen(p); /* to test if we have enough characters */
  269|      0|	hashost = 0; /* always */
  270|      0|	if(l >= 2 && p[1] == ':' && strchr(DRIVELETTERS,p[0]) != NULL) { /* case 1 */
  ------------------
  |  |   39|      0|#define DRIVELETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  ------------------
  |  Branch (270:5): [True: 0, False: 0]
  |  Branch (270:15): [True: 0, False: 0]
  |  Branch (270:30): [True: 0, False: 0]
  ------------------
  271|      0|	    ; /* p points to the start of the path */
  272|      0|        } else if(l >= 2 && p[0] == '/' && p[1] != '/') { /* case 2 */
  ------------------
  |  Branch (272:19): [True: 0, False: 0]
  |  Branch (272:29): [True: 0, False: 0]
  |  Branch (272:44): [True: 0, False: 0]
  ------------------
  273|      0|	    ; /* p points to the start of the path */
  274|      0|	} else if(l >= 4 && p[0] == '/' && p[1] == '/'
  ------------------
  |  Branch (274:12): [True: 0, False: 0]
  |  Branch (274:22): [True: 0, False: 0]
  |  Branch (274:37): [True: 0, False: 0]
  ------------------
  275|      0|		&& p[3] == ':' && strchr(DRIVELETTERS,p[2]) != NULL) { /* case 3 */
  ------------------
  |  |   39|      0|#define DRIVELETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  ------------------
  |  Branch (275:6): [True: 0, False: 0]
  |  Branch (275:21): [True: 0, False: 0]
  ------------------
  276|      0|	    p = p+2; /* points to the start of the windows path */
  277|      0|        } else if(l >= 4 && p[0] == '/' && p[1] == '/' && p[2] == '/' && p[3] != '/') { /* case 4 */
  ------------------
  |  Branch (277:19): [True: 0, False: 0]
  |  Branch (277:29): [True: 0, False: 0]
  |  Branch (277:44): [True: 0, False: 0]
  |  Branch (277:59): [True: 0, False: 0]
  |  Branch (277:74): [True: 0, False: 0]
  ------------------
  278|      0|	    p += 2; /* points to the start of the path */
  279|      0|        } else if(l >= 4 && p[0] == '/' && p[1] == '/' && p[2] != '/') { /* case 5 */
  ------------------
  |  Branch (279:19): [True: 0, False: 0]
  |  Branch (279:29): [True: 0, False: 0]
  |  Branch (279:44): [True: 0, False: 0]
  |  Branch (279:59): [True: 0, False: 0]
  ------------------
  280|      0|	    p += 2; /* points to the start of the path */
  281|      0|        } else /* everything else is illegal */
  282|      0|	    {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  283|      0|    } else {
  284|      0|        if(p[0] != '/' || p[1] != '/') /* must be proto:// */
  ------------------
  |  Branch (284:12): [True: 0, False: 0]
  |  Branch (284:27): [True: 0, False: 0]
  ------------------
  285|      0|	    {THROW(NC_EURL);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  286|      0|	p += 2;
  287|      0|        hashost = 1; /* Assume we have a hostname */
  288|      0|    }
  289|      0|    if(!hashost) {
  ------------------
  |  Branch (289:8): [True: 0, False: 0]
  ------------------
  290|      0|        tmp.path = p;
  291|      0|	pathchar = EOFCHAR;
  ------------------
  |  |   36|      0|#define EOFCHAR '\0'
  ------------------
  292|      0|    } else { /* assume there should be a host section */
  293|       |	/* We already extracted the query and/or fragment sections above,
  294|       |           so locate the end of the host section and therefore the start
  295|       |           of the path.
  296|       |        */
  297|      0|	tmp.host = p;
  298|      0|        p  = nclocate(p,"/");
  299|      0|	if(p == NULL) { /* no path */
  ------------------
  |  Branch (299:5): [True: 0, False: 0]
  ------------------
  300|      0|	    tmp.path = NULL; /* default */
  301|      0|	    pathchar = EOFCHAR;
  ------------------
  |  |   36|      0|#define EOFCHAR '\0'
  ------------------
  302|      0|	} else {
  303|      0|	    tmp.path = p; /* save ptr to rest of the path */
  304|      0|	    pathchar = *p; /* save leading char of the path */
  305|      0|	    terminate(p); /* overwrite the leading char of the path; restored below */
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  306|      0|	}
  307|      0|    }
  308|       |    /* Nullify tmp.host for consistency */
  309|      0|    if(tmp.host != NULL && strlen(tmp.host)==0) {tmp.host = NULL;}
  ------------------
  |  Branch (309:8): [True: 0, False: 0]
  |  Branch (309:28): [True: 0, False: 0]
  ------------------
  310|       |
  311|      0|    if(tmp.host != NULL) {/* Parse the host section */
  ------------------
  |  Branch (311:8): [True: 0, False: 0]
  ------------------
  312|      0|        char* pp;
  313|       |	/* Check for leading user:pwd@ */
  314|      0|        char* newhost = strchr(tmp.host,'@');
  315|      0|        if(newhost != NULL) {
  ------------------
  |  Branch (315:12): [True: 0, False: 0]
  ------------------
  316|      0|	    if(newhost == tmp.host)
  ------------------
  |  Branch (316:9): [True: 0, False: 0]
  ------------------
  317|      0|		{THROW(NC_EURL);} /* we have proto://@ */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  318|      0|	    terminate(newhost); /* overwrite '@' */
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  319|      0|	    newhost++; /* should point past usr+pwd */
  320|      0|	    tmp.user = tmp.host;
  321|       |	    /* Break user+pwd into two pieces */
  322|      0|	    pp = strchr(tmp.user,':');
  323|      0|	    if(pp == NULL)
  ------------------
  |  Branch (323:9): [True: 0, False: 0]
  ------------------
  324|      0|		{THROW(NC_EURL);} /* we have user only */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  325|      0|	    terminate(pp); /* overwrite ':' */
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  326|      0|	    pp++;
  327|      0|	    if(strlen(tmp.user)==0)
  ------------------
  |  Branch (327:9): [True: 0, False: 0]
  ------------------
  328|      0|		{THROW(NC_EURL);} /* we have empty user */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  329|      0|	    if(strlen(pp)==0)
  ------------------
  |  Branch (329:9): [True: 0, False: 0]
  ------------------
  330|      0|		{THROW(NC_EURL);} /* we have empty password */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  331|      0|	    tmp.password = pp;
  332|      0|	    tmp.host = newhost;
  333|      0|	}
  334|       |	/* Breakup host into host + port */
  335|      0|	pp = tmp.host;
  336|      0|        pp = strchr(pp,':');
  337|      0|        if(pp != NULL) { /* there is a port */
  ------------------
  |  Branch (337:12): [True: 0, False: 0]
  ------------------
  338|      0|	    terminate(pp); /* overwrite ':' */
  ------------------
  |  |   53|      0|#define terminate(p) {*(p) = EOFCHAR;}
  |  |  ------------------
  |  |  |  |   36|      0|#define EOFCHAR '\0'
  |  |  ------------------
  ------------------
  339|      0|	    pp++; /* skip colon */
  340|      0|	    if(strlen(tmp.host) == 0)
  ------------------
  |  Branch (340:9): [True: 0, False: 0]
  ------------------
  341|      0|		{THROW(NC_EURL);} /* empty host */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  342|      0|	    if(strlen(pp)==0)
  ------------------
  |  Branch (342:9): [True: 0, False: 0]
  ------------------
  343|      0|		{THROW(NC_EURL);} /* empty port */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  344|      0|	    tmp.port = pp;
  345|       |	    /* The port must look something like a number */
  346|      0|	    for(pp=tmp.port;*pp;pp++) {
  ------------------
  |  Branch (346:22): [True: 0, False: 0]
  ------------------
  347|      0|	        if(strchr("0123456789-",*pp) == NULL)
  ------------------
  |  Branch (347:13): [True: 0, False: 0]
  ------------------
  348|      0|		    {THROW(NC_EURL);}  /* probably not a real port, fail */
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  349|      0|	    }
  350|      0|	} /* else no port */
  351|      0|    }
  352|       |
  353|       |    /* Fill in duri from tmp */
  354|      0|    duri = (NCURI*)calloc(1,sizeof(NCURI));
  355|      0|    if(duri == NULL)
  ------------------
  |  Branch (355:8): [True: 0, False: 0]
  ------------------
  356|      0|      {THROW(NC_ENOMEM);}
  ------------------
  |  |   27|      0|#define THROW(n) {ret=(n); goto done;}
  ------------------
  357|       |    /* save original uri */
  358|      0|    duri->uri = strdup(uri0);
  359|      0|    duri->protocol = nulldup(tmp.protocol);
  ------------------
  |  |  147|      0|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  360|       |    /* before saving, we need to decode the user+pwd */
  361|      0|    duri->user = NULL;
  362|      0|    duri->password = NULL;
  363|      0|    if(tmp.user != NULL)
  ------------------
  |  Branch (363:8): [True: 0, False: 0]
  ------------------
  364|      0|        duri->user = ncuridecode(tmp.user);
  365|      0|    if(tmp.password != NULL)
  ------------------
  |  Branch (365:8): [True: 0, False: 0]
  ------------------
  366|      0|        duri->password = ncuridecode(tmp.password);
  367|      0|    duri->host = nulldup(tmp.host);
  ------------------
  |  |  147|      0|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  368|      0|    duri->port = nulldup(tmp.port);
  ------------------
  |  |  147|      0|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  369|      0|    if(tmp.path != NULL) {
  ------------------
  |  Branch (369:8): [True: 0, False: 0]
  ------------------
  370|       |	/* We need to add back the previously overwritten path lead char (if necessary);
  371|       |           this must be done after all host section related pieces have been captured */
  372|      0|	if(pathchar != EOFCHAR)
  ------------------
  |  |   36|      0|#define EOFCHAR '\0'
  ------------------
  |  Branch (372:5): [True: 0, False: 0]
  ------------------
  373|      0|	    *tmp.path = pathchar;
  374|      0|        duri->path = nulldup(tmp.path);
  ------------------
  |  |  147|      0|#define nulldup(s) ((s)==NULL?s:strdup(s))
  |  |  ------------------
  |  |  |  Branch (147:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  375|      0|    }
  376|      0|    duri->query = NULL; /* let ensurequery fix this */
  377|      0|    duri->fragment = NULL; /* let ensurefrag fix this */
  378|      0|    duri->fraglist = tmp.fraglist; tmp.fraglist = NULL;
  379|      0|    duri->querylist = tmp.querylist; tmp.querylist = NULL;
  380|       |
  381|       |    /* make sure query and fragment strings are defined */
  382|      0|    ensurequerylist(duri);
  383|      0|    ensurefraglist(duri);
  384|       |
  385|      0|    if(durip)
  ------------------
  |  Branch (385:8): [True: 0, False: 0]
  ------------------
  386|      0|      *durip = duri;
  387|      0|    else
  388|      0|      free(duri);
  389|       |
  390|       |#ifdef NCXDEBUG
  391|       |	{
  392|       |        fprintf(stderr,"duri:");
  393|       |	fprintf(stderr," protocol=|%s|",FIX(duri->protocol));
  394|       |	fprintf(stderr," user=|%s|",FIX(duri->user));
  395|       |	fprintf(stderr," password=|%s|",FIX(duri->password));
  396|       |	fprintf(stderr," host=|%s|",FIX(duri->host));
  397|       |	fprintf(stderr," port=|%s|",FIX(duri->port));
  398|       |	fprintf(stderr," path=|%s|",FIX(duri->path));
  399|       |	fprintf(stderr," query=|%s|",FIX(duri->query));
  400|       |	fprintf(stderr," fragment=|%s|",FIX(duri->fragment));
  401|       |        fprintf(stderr,"\n");
  402|       |    }
  403|       |#endif
  404|       |
  405|    287|done:
  406|    287|    if(uri != NULL)
  ------------------
  |  Branch (406:8): [True: 287, False: 0]
  ------------------
  407|    287|      free(uri);
  408|       |
  409|    287|    freestringlist(params);
  410|    287|    freestringlist(querylist);
  411|    287|    if(tmp.fraglist)
  ------------------
  |  Branch (411:8): [True: 287, False: 0]
  ------------------
  412|    287|      nclistfreeall(tmp.fraglist);
  413|    287|    if(tmp.querylist)
  ------------------
  |  Branch (413:8): [True: 0, False: 287]
  ------------------
  414|      0|      nclistfreeall(tmp.querylist);
  415|       |
  416|    287|    return ret;
  417|      0|}
ncurifree:
  446|    287|{
  447|    287|    if(duri == NULL) return;
  ------------------
  |  Branch (447:8): [True: 287, False: 0]
  ------------------
  448|      0|    nullfree(duri->uri);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  449|      0|    nullfree(duri->protocol);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  450|      0|    nullfree(duri->user);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  451|      0|    nullfree(duri->password);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  452|      0|    nullfree(duri->host);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  453|      0|    nullfree(duri->port);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  454|      0|    nullfree(duri->path);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  455|      0|    nullfree(duri->query);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  456|       |    nullfree(duri->fragment);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  457|      0|    nclistfreeall(duri->querylist);
  458|      0|    nclistfreeall(duri->fraglist);
  459|      0|    free(duri);
  460|      0|}
ncuri.c:freestringlist:
  421|    574|{
  422|    574|    if(list != NULL) {
  ------------------
  |  Branch (422:8): [True: 287, False: 287]
  ------------------
  423|    287|	size_t i;
  424|    287|	for(i=0;i<nclistlength(list);i++) {
  ------------------
  |  |   73|    287|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  |  Branch (424:10): [True: 0, False: 287]
  ------------------
  425|      0|	    void* p = nclistget(list,i);
  426|       |	    nullfree(p);
  ------------------
  |  |  155|      0|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  427|      0|	}
  428|    287|        nclistfree(list);
  429|    287|    }
  430|    574|}
ncuri.c:nclocate:
  850|    287|{
  851|  3.73k|    for(;*p;p++) {
  ------------------
  |  Branch (851:10): [True: 3.44k, False: 287]
  ------------------
  852|  3.44k|	if(*p == '\\') p++;
  ------------------
  |  Branch (852:5): [True: 0, False: 3.44k]
  ------------------
  853|  3.44k|	else if(strchr(charlist,*p) != NULL)
  ------------------
  |  Branch (853:10): [True: 0, False: 3.44k]
  ------------------
  854|      0|	    return p;
  855|  3.44k|    }
  856|    287|    return NULL;
  857|    287|}
ncuri.c:removedups:
 1265|    287|{
 1266|    287|    size_t i,j;
 1267|       |
 1268|    287|    if(nclistlength(list) <= 2) return; /* need at least 2 pairs */
  ------------------
  |  |   73|    287|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 287]
  |  |  ------------------
  ------------------
  |  Branch (1268:8): [True: 287, False: 0]
  ------------------
 1269|      0|    for(i=0;i<nclistlength(list);i+=2) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1269:13): [True: 0, False: 0]
  ------------------
 1270|       |	/* look for dups for this entry */
 1271|      0|	for(j=nclistlength(list)-2;j>i;j-=2) {
  ------------------
  |  |   73|      0|#define nclistlength(l)  ((l)==NULL?0:(l)->length)
  |  |  ------------------
  |  |  |  Branch (73:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1271:29): [True: 0, False: 0]
  ------------------
 1272|      0|	    if(strcasecmp(nclistget(list,i),nclistget(list,j))==0
  ------------------
  |  Branch (1272:9): [True: 0, False: 0]
  ------------------
 1273|      0|		&& strcasecmp(nclistget(list,i+1),nclistget(list,j+1))==0) {
  ------------------
  |  Branch (1273:6): [True: 0, False: 0]
  ------------------
 1274|      0|		nclistremove(list,j+1); nclistremove(list,j);
 1275|      0|	    }
 1276|      0|	}
 1277|      0|    }
 1278|      0|}

nc_initialize:
  103|      1|{
  104|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  105|       |
  106|      1|    if(NC_initialized) return NC_NOERR;
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (106:8): [True: 0, False: 1]
  ------------------
  107|      1|    NC_initialized = 1;
  108|      1|    NC_finalized = 0;
  109|       |
  110|       |    /* Do general initialization */
  111|      1|    if((stat = NCDISPATCH_initialize())) goto done;
  ------------------
  |  Branch (111:8): [True: 0, False: 1]
  ------------------
  112|       |
  113|       |    /* Initialize each active protocol */
  114|      1|    if((stat = NC3_initialize())) goto done;
  ------------------
  |  Branch (114:8): [True: 0, False: 1]
  ------------------
  115|       |#ifdef NETCDF_ENABLE_DAP
  116|       |    if((stat = NCD2_initialize())) goto done;
  117|       |#endif
  118|       |#ifdef NETCDF_ENABLE_DAP4
  119|       |    if((stat = NCD4_initialize())) goto done;
  120|       |#endif
  121|       |#ifdef USE_PNETCDF
  122|       |    if((stat = NCP_initialize())) goto done;
  123|       |#endif
  124|      1|#ifdef USE_NETCDF4
  125|      1|    if((stat = NC4_initialize())) goto done;
  ------------------
  |  Branch (125:8): [True: 0, False: 1]
  ------------------
  126|      1|#endif /* USE_NETCDF4 */
  127|       |#ifdef USE_HDF5
  128|       |    if((stat = NC_HDF5_initialize())) goto done;
  129|       |#endif
  130|       |#ifdef USE_HDF4
  131|       |    if((stat = NC_HDF4_initialize())) goto done;
  132|       |#endif
  133|       |#ifdef NETCDF_ENABLE_S3
  134|       |    if((stat = NC_s3sdkinitialize())) goto done;
  135|       |#endif
  136|      1|#ifdef NETCDF_ENABLE_NCZARR
  137|      1|    if((stat = NCZ_initialize())) goto done;
  ------------------
  |  Branch (137:8): [True: 0, False: 1]
  ------------------
  138|      1|#endif
  139|       |
  140|      1|#ifdef NETCDF_ENABLE_ATEXIT_FINALIZE
  141|       |    /* Use atexit() to invoke nc_finalize */
  142|      1|    if(atexit(finalize_atexit))
  ------------------
  |  Branch (142:8): [True: 0, False: 1]
  ------------------
  143|      0|	fprintf(stderr,"atexit failed\n");
  144|      1|#endif
  145|       |
  146|      1|done:
  147|      1|    return stat;
  148|      1|}
nc_finalize:
  171|      1|{
  172|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  173|      1|    int failed = stat;
  174|       |
  175|      1|    if(NC_finalized) goto done;
  ------------------
  |  Branch (175:8): [True: 0, False: 1]
  ------------------
  176|      1|    NC_initialized = 0;
  177|      1|    NC_finalized = 1;
  178|       |
  179|       |    /* Finalize each active protocol */
  180|       |
  181|       |#ifdef NETCDF_ENABLE_DAP2
  182|       |    if((stat = NCD2_finalize())) failed = stat;
  183|       |#endif
  184|       |#ifdef NETCDF_ENABLE_DAP4
  185|       |    if((stat = NCD4_finalize())) failed = stat;
  186|       |#endif
  187|       |
  188|       |#ifdef USE_PNETCDF
  189|       |    if((stat = NCP_finalize())) failed = stat;
  190|       |#endif
  191|       |
  192|       |#ifdef USE_HDF4
  193|       |    if((stat = NC_HDF4_finalize())) failed = stat;
  194|       |#endif /* USE_HDF4 */
  195|       |
  196|      1|#ifdef USE_NETCDF4
  197|      1|    if((stat = NC4_finalize())) failed = stat;
  ------------------
  |  Branch (197:8): [True: 0, False: 1]
  ------------------
  198|      1|#endif /* USE_NETCDF4 */
  199|       |
  200|       |#ifdef USE_HDF5
  201|       |    if((stat = NC_HDF5_finalize())) failed = stat;
  202|       |#endif
  203|       |
  204|      1|#ifdef NETCDF_ENABLE_NCZARR
  205|      1|    if((stat = NCZ_finalize())) failed = stat;
  ------------------
  |  Branch (205:8): [True: 0, False: 1]
  ------------------
  206|      1|#endif
  207|       |
  208|       |#ifdef NETCDF_ENABLE_S3
  209|       |    if((stat = NC_s3sdkfinalize())) failed = stat;
  210|       |#endif
  211|       |
  212|      1|    if((stat = NC3_finalize())) failed = stat;
  ------------------
  |  Branch (212:8): [True: 0, False: 1]
  ------------------
  213|       |
  214|       |    /* Do general finalization */
  215|      1|    if((stat = NCDISPATCH_finalize())) failed = stat;
  ------------------
  |  Branch (215:8): [True: 0, False: 1]
  ------------------
  216|       |
  217|      1|done:
  218|      1|    if(failed) fprintf(stderr,"nc_finalize failed: %d\n",failed);
  ------------------
  |  Branch (218:8): [True: 0, False: 1]
  ------------------
  219|      1|    return failed;
  220|      1|}
nc_initialize.c:finalize_atexit:
   79|      1|{
   80|      1|    (void)nc_finalize();
   81|      1|}

NCZ_get_libversion:
  219|      1|{
  220|      1|    unsigned long m0,m1,m2;
  221|      1|    sscanf(NCZARRVERSION,"%lu.%lu.%lu",&m0,&m1,&m2);
  ------------------
  |  |   19|      1|#define NCZARRVERSION "2.0.0"
  ------------------
  222|      1|    if(majorp) *majorp = m0;
  ------------------
  |  Branch (222:8): [True: 1, False: 0]
  ------------------
  223|      1|    if(minorp) *minorp = m1;
  ------------------
  |  Branch (223:8): [True: 1, False: 0]
  ------------------
  224|      1|    if(releasep) *releasep = m2;
  ------------------
  |  Branch (224:8): [True: 1, False: 0]
  ------------------
  225|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  226|      1|}

NCZ_initialize:
  125|      1|{
  126|      1|    int stat;
  127|      1|    NCZ_dispatch_table = &NCZ_dispatcher;
  128|      1|    if (!ncz_initialized)
  ------------------
  |  Branch (128:9): [True: 1, False: 0]
  ------------------
  129|      1|        NCZ_initialize_internal();
  130|      1|    stat = NCZ_provenance_init();
  131|      1|    if(stat) ncz_initialized = 1;
  ------------------
  |  Branch (131:8): [True: 0, False: 1]
  ------------------
  132|      1|    return stat;
  133|      1|}
NCZ_finalize:
  143|      1|{
  144|      1|    NCZ_finalize_internal();
  145|      1|    NCZ_provenance_finalize();
  146|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  147|      1|}

NCZ_initialize_internal:
   55|      1|{
   56|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   57|      1|    char* dimsep = NULL;
   58|      1|    NCglobalstate* ngs = NULL;
   59|       |
   60|      1|    ncz_initialized = 1;
   61|      1|    ngs = NC_getglobalstate();
   62|      1|    if(ngs != NULL) {
  ------------------
  |  Branch (62:8): [True: 1, False: 0]
  ------------------
   63|       |        /* Defaults */
   64|      1|	ngs->zarr.dimension_separator = DFALT_DIM_SEPARATOR;
  ------------------
  |  |   88|      1|#define DFALT_DIM_SEPARATOR '.'
  ------------------
   65|      1|        dimsep = NC_rclookup("ZARR.DIMENSION_SEPARATOR",NULL,NULL);
   66|      1|        if(dimsep != NULL) {
  ------------------
  |  Branch (66:12): [True: 0, False: 1]
  ------------------
   67|       |            /* Verify its value */
   68|      0|	    if(dimsep != NULL && strlen(dimsep) == 1 && islegaldimsep(dimsep[0]))
  ------------------
  |  |   90|      0|#define islegaldimsep(c) ((c) != '\0' && strchr(LEGAL_DIM_SEPARATORS,(c)) != NULL)
  |  |  ------------------
  |  |  |  |   87|      0|#define LEGAL_DIM_SEPARATORS "./"
  |  |  ------------------
  |  |  |  Branch (90:27): [True: 0, False: 0]
  |  |  |  Branch (90:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (68:9): [True: 0, False: 0]
  |  Branch (68:27): [True: 0, False: 0]
  ------------------
   69|      0|		ngs->zarr.dimension_separator = dimsep[0];
   70|      0|        }    
   71|      1|    }
   72|       |
   73|      1|    return stat;
   74|      1|}
NCZ_finalize_internal:
   82|      1|{
   83|       |    /* Reclaim global resources */
   84|      1|    ncz_initialized = 0;
   85|       |#ifdef NETCDF_ENABLE_NCZARR_FILTERS
   86|       |    NCZ_filter_finalize();
   87|       |#endif
   88|       |#ifdef NETCDF_ENABLE_S3
   89|       |    NCZ_s3finalize();
   90|       |#endif
   91|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   92|      1|}

NCZ_provenance_init:
   50|      1|{
   51|      1|    int stat = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   52|      1|    char* name = NULL;
   53|      1|    char* value = NULL;
   54|      1|    unsigned long major, minor, release;
   55|      1|    NCbytes* buffer = NULL; /* for constructing the global _NCProperties */
   56|      1|    char printbuf[1024];
   57|       |
   58|      1|    if(globalpropinitialized)
  ------------------
  |  Branch (58:8): [True: 0, False: 1]
  ------------------
   59|      0|        return stat;
   60|       |
   61|       |    /* Build _NCProperties info */
   62|       |
   63|       |    /* Initialize globalpropinfo */
   64|      1|    memset((void*)&globalprovenance,0,sizeof(NC4_Provenance));
   65|      1|    globalprovenance.version = NCPROPS_VERSION;
  ------------------
  |  |   35|      1|#define NCPROPS_VERSION (2)
  ------------------
   66|       |
   67|      1|    buffer = ncbytesnew();
   68|       |
   69|       |    /* Insert version as first entry */
   70|      1|    ncbytescat(buffer,NCPVERSION);
  ------------------
  |  |   30|      1|#define NCPVERSION "version" /* Of the properties format */
  ------------------
   71|      1|    ncbytescat(buffer,"=");
   72|       |
   73|      1|    snprintf(printbuf,sizeof(printbuf),"%d",globalprovenance.version);
   74|      1|    ncbytescat(buffer,printbuf);
   75|       |
   76|       |    /* Insert the netcdf version */
   77|      1|    ncbytesappend(buffer,NCPROPSSEP2);
  ------------------
  |  |   38|      1|#define NCPROPSSEP2  ','
  ------------------
   78|      1|    ncbytescat(buffer,NCPNCLIB2);
  ------------------
  |  |   34|      1|#define NCPNCLIB2 "netcdf"
  ------------------
   79|      1|    ncbytescat(buffer,"=");
   80|      1|    ncbytescat(buffer,PACKAGE_VERSION);
  ------------------
  |  |  551|      1|#define PACKAGE_VERSION "4.10.1-development"
  ------------------
   81|       |
   82|       |    /* This should be redundant since netcdf version => zarr format */
   83|       |    /* Insert the ZARR as underlying storage format library */
   84|      1|    ncbytesappend(buffer,NCPROPSSEP2);
  ------------------
  |  |   38|      1|#define NCPROPSSEP2  ','
  ------------------
   85|      1|    ncbytescat(buffer,NCPNCZLIB);
  ------------------
  |  |   25|      1|#define NCPNCZLIB "nczarr"
  ------------------
   86|      1|    ncbytescat(buffer,"=");
   87|      1|    if((stat = NCZ_get_libversion(&major,&minor,&release))) return stat;
  ------------------
  |  Branch (87:8): [True: 0, False: 1]
  ------------------
   88|      1|    snprintf(printbuf,sizeof(printbuf),"%lu.%lu.%lu",major,minor,release);
   89|      1|    ncbytescat(buffer,printbuf);
   90|       |
   91|       |#ifdef NCPROPERTIES_EXTRA
   92|       |    if(NCPROPERTIES_EXTRA != NULL && strlen(NCPROPERTIES_EXTRA) > 0)
   93|       |    {
   94|       |    /* Add any extra fields */
   95|       |    const char* p = NCPROPERTIES_EXTRA;
   96|       |    if(p != NULL && strlen(p) > 0) {
   97|       |        if(p[0] == NCPROPSSEP2) p++; /* If leading separator */
   98|       |        ncbytesappend(buffer,NCPROPSSEP2);
   99|       |        ncbytescat(buffer,p);
  100|       |    }
  101|       |    }
  102|       |#endif
  103|      1|    ncbytesnull(buffer);
  104|      1|    globalprovenance.ncproperties = ncbytesextract(buffer);
  105|       |
  106|      1|    ncbytesfree(buffer);
  107|      1|    if(name != NULL) free(name);
  ------------------
  |  Branch (107:8): [True: 0, False: 1]
  ------------------
  108|      1|    if(value != NULL) free(value);
  ------------------
  |  Branch (108:8): [True: 0, False: 1]
  ------------------
  109|      1|    if(stat == NC_NOERR)
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (109:8): [True: 1, False: 0]
  ------------------
  110|      1|        globalpropinitialized = 1; /* avoid repeating it */
  111|      1|    return stat;
  112|      1|}
NCZ_provenance_finalize:
  122|      1|{
  123|      1|    return NCZ_clear_provenance(&globalprovenance);
  124|      1|}
NCZ_clear_provenance:
  361|      1|{
  362|      1|    LOG((5, "%s", __func__));
  363|       |
  364|      1|    if(prov == NULL) return NC_NOERR;
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (364:8): [True: 0, False: 1]
  ------------------
  365|      1|    nullfree(prov->ncproperties);
  ------------------
  |  |  155|      1|#define nullfree(s) {if((s)!=NULL) {free(s);} else {}}
  |  |  ------------------
  |  |  |  Branch (155:25): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  366|      1|    memset(prov,0,sizeof(NC4_Provenance));
  367|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  368|      1|}

free_NC_dim:
   26|   432k|{
   27|   432k|	if(dimp == NULL)
  ------------------
  |  Branch (27:5): [True: 0, False: 432k]
  ------------------
   28|      0|		return;
   29|   432k|	free_NC_string(dimp->name);
   30|   432k|	free(dimp);
   31|   432k|}
new_x_NC_dim:
   36|   432k|{
   37|   432k|	NC_dim *dimp;
   38|       |
   39|   432k|	dimp = (NC_dim *) malloc(sizeof(NC_dim));
   40|   432k|	if(dimp == NULL)
  ------------------
  |  Branch (40:5): [True: 0, False: 432k]
  ------------------
   41|      0|		return NULL;
   42|       |
   43|   432k|	dimp->name = name;
   44|   432k|	dimp->size = 0;
   45|       |
   46|   432k|	return(dimp);
   47|   432k|}
free_NC_dimarrayV0:
  163|     82|{
  164|     82|	assert(ncap != NULL);
  ------------------
  |  Branch (164:2): [True: 0, False: 82]
  |  Branch (164:2): [True: 82, False: 0]
  ------------------
  165|       |
  166|     82|	if(ncap->nelems == 0)
  ------------------
  |  Branch (166:5): [True: 3, False: 79]
  ------------------
  167|      3|		return;
  168|       |
  169|     82|	assert(ncap->value != NULL);
  ------------------
  |  Branch (169:2): [True: 0, False: 79]
  |  Branch (169:2): [True: 79, False: 0]
  ------------------
  170|       |
  171|     79|	{
  172|     79|		NC_dim **dpp = ncap->value;
  173|     79|		NC_dim *const *const end = &dpp[ncap->nelems];
  174|   432k|		for( /*NADA*/; dpp < end; dpp++)
  ------------------
  |  Branch (174:18): [True: 432k, False: 79]
  ------------------
  175|   432k|		{
  176|   432k|			free_NC_dim(*dpp);
  177|       |			*dpp = NULL;
  178|   432k|		}
  179|     79|	}
  180|     79|	ncap->nelems = 0;
  181|     79|}
free_NC_dimarrayV:
  191|    327|{
  192|    327|	assert(ncap != NULL);
  ------------------
  |  Branch (192:2): [True: 0, False: 327]
  |  Branch (192:2): [True: 327, False: 0]
  ------------------
  193|       |
  194|    327|	if(ncap->nalloc == 0)
  ------------------
  |  Branch (194:5): [True: 245, False: 82]
  ------------------
  195|    245|		return;
  196|       |
  197|     82|	NC_hashmapfree(ncap->hashmap);
  198|     82|	ncap->hashmap = NULL;
  199|       |
  200|     82|	assert(ncap->value != NULL);
  ------------------
  |  Branch (200:2): [True: 0, False: 82]
  |  Branch (200:2): [True: 82, False: 0]
  ------------------
  201|       |
  202|     82|	free_NC_dimarrayV0(ncap);
  203|       |
  204|     82|	free(ncap->value);
  205|       |	ncap->value = NULL;
  206|     82|	ncap->nalloc = 0;
  207|     82|}
elem_NC_dimarray:
  304|      7|{
  305|      7|	assert(ncap != NULL);
  ------------------
  |  Branch (305:2): [True: 0, False: 7]
  |  Branch (305:2): [True: 7, False: 0]
  ------------------
  306|       |		/* cast needed for braindead systems with signed size_t */
  307|      7|	if(ncap->nelems == 0 || (unsigned long) elem >= ncap->nelems)
  ------------------
  |  Branch (307:5): [True: 0, False: 7]
  |  Branch (307:26): [True: 0, False: 7]
  ------------------
  308|      0|		return NULL;
  309|       |
  310|      7|	assert(ncap->value != NULL);
  ------------------
  |  Branch (310:2): [True: 0, False: 7]
  |  Branch (310:2): [True: 7, False: 0]
  ------------------
  311|       |
  312|      7|	return ncap->value[elem];
  313|      7|}

memio_open:
  327|    257|{
  328|    257|    ncio* nciop = NULL;
  329|    257|    int fd = -1;
  330|    257|    int status = NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  331|    257|    size_t sizehint = 0;
  332|    257|    NC_memio meminfo; /* use struct to avoid worrying about free'ing it */
  333|    257|    NCMEMIO* memio = NULL;
  334|    257|    size_t initialsize;
  335|       |    /* Should be the case that diskless => inmemory but not converse */
  336|    257|    int diskless = (fIsSet(ioflags,NC_DISKLESS));
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  ------------------
  337|    257|    int inmemory = fIsSet(ioflags,NC_INMEMORY);
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  ------------------
  338|    257|    int locked = 0;
  339|       |
  340|    257|    assert(inmemory ? !diskless : 1);
  ------------------
  |  Branch (340:5): [True: 0, False: 257]
  |  Branch (340:5): [True: 0, False: 257]
  |  Branch (340:5): [True: 257, False: 0]
  |  Branch (340:5): [True: 257, False: 0]
  ------------------
  341|       |
  342|    257|    if(path == NULL || strlen(path) == 0)
  ------------------
  |  Branch (342:8): [True: 0, False: 257]
  |  Branch (342:24): [True: 0, False: 257]
  ------------------
  343|      0|        return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  344|       |
  345|    257|    assert(sizehintp != NULL);
  ------------------
  |  Branch (345:5): [True: 0, False: 257]
  |  Branch (345:5): [True: 257, False: 0]
  ------------------
  346|       |
  347|    257|    sizehint = *sizehintp;
  348|       |
  349|    257|    memset(&meminfo,0,sizeof(meminfo));
  350|       |
  351|    257|    if(inmemory) { /* parameters provide the memory chunk */
  ------------------
  |  Branch (351:8): [True: 257, False: 0]
  ------------------
  352|    257|	NC_memio* memparams = (NC_memio*)parameters;
  353|    257|        meminfo = *memparams;
  354|    257|        locked = fIsSet(meminfo.flags,NC_MEMIO_LOCKED);
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  ------------------
  355|       |	/* As a safeguard, if !locked and NC_WRITE is set,
  356|       |           then we must take control of the incoming memory */
  357|    257|        if(!locked && fIsSet(ioflags,NC_WRITE)) {
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (357:12): [True: 0, False: 257]
  ------------------
  358|      0|	    memparams->memory = NULL;	    
  359|      0|	}	
  360|    257|    } else { /* read the file into a chunk of memory*/
  361|      0|	assert(diskless);
  ------------------
  |  Branch (361:2): [True: 0, False: 0]
  |  Branch (361:2): [True: 0, False: 0]
  ------------------
  362|      0|	status = readfile(path,&meminfo);
  363|      0|	if(status != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (363:5): [True: 0, False: 0]
  ------------------
  364|      0|	    {goto unwind_open;}
  365|      0|    }
  366|       |
  367|       |    /* Fix up initial size */
  368|    257|    initialsize = meminfo.size;
  369|       |
  370|       |    /* create the NCMEMIO structure */
  371|    257|    status = memio_new(path, ioflags, initialsize, &nciop, &memio);
  372|    257|    if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (372:8): [True: 0, False: 257]
  ------------------
  373|      0|	{goto unwind_open;}
  374|    257|    memio->locked = locked;
  375|       |
  376|       |    /* Initialize the memio memory */
  377|    257|    memio->memory = meminfo.memory;
  378|       |
  379|       |    /* memio_new may have modified the allocated size, in which case,
  380|       |       reallocate the memory unless the memory is locked. */    
  381|    257|    if(memio->alloc > meminfo.size) {
  ------------------
  |  Branch (381:8): [True: 243, False: 14]
  ------------------
  382|    243|	if(memio->locked)
  ------------------
  |  Branch (382:5): [True: 243, False: 0]
  ------------------
  383|    243|	    memio->alloc = meminfo.size; /* force it back to what it was */
  384|      0|	else {
  385|      0|	   void* oldmem = memio->memory;
  386|      0|	   memio->memory = reallocx(oldmem,memio->alloc,meminfo.size);
  ------------------
  |  |   86|      0|#define reallocx(m,new,old) realloc(m,new)
  ------------------
  387|      0|	   if(memio->memory == NULL)
  ------------------
  |  Branch (387:8): [True: 0, False: 0]
  ------------------
  388|      0|	       {status = NC_ENOMEM; goto unwind_open;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  389|      0|	}
  390|    243|    }
  391|       |
  392|       |#ifdef DEBUG
  393|       |fprintf(stderr,"memio_open: initial memory: %lu/%lu\n",(unsigned long)memio->memory,(unsigned long)memio->alloc);
  394|       |#endif
  395|       |
  396|    257|    if(memio->persist) {
  ------------------
  |  Branch (396:8): [True: 0, False: 257]
  ------------------
  397|       |	/* Verify the file is writeable and exists */
  398|      0|	if(!fileexists(path))
  ------------------
  |  Branch (398:5): [True: 0, False: 0]
  ------------------
  399|      0|	    {status = ENOENT; goto unwind_open;}	
  400|      0|	if(!fileiswriteable(path))
  ------------------
  |  Branch (400:5): [True: 0, False: 0]
  ------------------
  401|      0|	    {status = EACCES; goto unwind_open;}	
  402|      0|    }
  403|       |
  404|       |    /* Use half the filesize as the blocksize ; why? */
  405|    257|    sizehint = (size_t)(memio->alloc/2);
  406|       |
  407|       |    /* sizehint must be multiple of 8 */
  408|    257|    sizehint = (sizehint / 8) * 8;
  409|    257|    if(sizehint < 8) sizehint = 8;
  ------------------
  |  Branch (409:8): [True: 0, False: 257]
  ------------------
  410|       |
  411|    257|    fd = nc__pseudofd();
  412|    257|    *((int* )&nciop->fd) = fd;
  413|       |
  414|    257|    if(igetsz != 0)
  ------------------
  |  Branch (414:8): [True: 0, False: 257]
  ------------------
  415|      0|    {
  416|      0|        status = nciop->get(nciop,
  417|      0|                igeto, igetsz,
  418|      0|                0,
  419|      0|                mempp);
  420|      0|        if(status != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (420:12): [True: 0, False: 0]
  ------------------
  421|      0|            goto unwind_open;
  422|      0|    }
  423|       |
  424|    257|    if(sizehintp) *sizehintp = sizehint;
  ------------------
  |  Branch (424:8): [True: 257, False: 0]
  ------------------
  425|    257|    if(nciopp) *nciopp = nciop; else {ncio_close(nciop,0);}
  ------------------
  |  Branch (425:8): [True: 257, False: 0]
  ------------------
  426|    257|    return NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  427|       |
  428|      0|unwind_open:
  429|      0|    if(fd >= 0)
  ------------------
  |  Branch (429:8): [True: 0, False: 0]
  ------------------
  430|      0|      close(fd);
  431|      0|    memio_close(nciop,0);
  432|      0|    return status;
  433|    257|}
memio.c:memio_new:
  136|    257|{
  137|    257|    int status = NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  138|    257|    ncio* nciop = NULL;
  139|    257|    NCMEMIO* memio = NULL;
  140|    257|    size_t minsize = initialsize;
  141|       |
  142|       |    /* Unlike netcdf-4, INMEMORY and DISKLESS share code */
  143|    257|    if(fIsSet(ioflags,NC_DISKLESS))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 257]
  |  |  ------------------
  ------------------
  144|      0|	fSet(ioflags,NC_INMEMORY);    
  ------------------
  |  |   13|      0|#define fSet(t, f)       ((t) |= (f))
  ------------------
  145|       |
  146|       |    /* use asserts because this is an internal function */
  147|    257|    assert(fIsSet(ioflags,NC_INMEMORY));
  ------------------
  |  Branch (147:5): [True: 0, False: 257]
  |  Branch (147:5): [True: 257, False: 0]
  ------------------
  148|    257|    assert(memiop != NULL && nciopp != NULL);
  ------------------
  |  Branch (148:5): [True: 0, False: 257]
  |  Branch (148:5): [True: 0, False: 0]
  |  Branch (148:5): [True: 257, False: 0]
  |  Branch (148:5): [True: 257, False: 0]
  ------------------
  149|    257|    assert(path != NULL);
  ------------------
  |  Branch (149:5): [True: 0, False: 257]
  |  Branch (149:5): [True: 257, False: 0]
  ------------------
  150|       |
  151|    257|    if(pagesize == 0) {
  ------------------
  |  Branch (151:8): [True: 1, False: 256]
  ------------------
  152|       |#if defined (_WIN32) || defined(_WIN64)
  153|       |      SYSTEM_INFO info;
  154|       |      GetSystemInfo (&info);
  155|       |      pagesize = info.dwPageSize;
  156|       |#elif defined HAVE_SYSCONF
  157|       |      long pgval = -1;
  158|      1|      pgval = sysconf(_SC_PAGE_SIZE);
  159|      1|      if(pgval < 0) {
  ------------------
  |  Branch (159:10): [True: 0, False: 1]
  ------------------
  160|      0|          status = NC_EIO;
  ------------------
  |  |  506|      0|#define NC_EIO          (-68)      /**< Generic IO error */
  ------------------
  161|      0|          goto fail;
  162|      0|      }
  163|      1|      pagesize = (size_t)pgval;
  164|       |#elif defined HAVE_GETPAGESIZE
  165|       |      pagesize = (size_t)getpagesize();
  166|       |#else
  167|       |      pagesize = 4096; /* good guess */
  168|       |#endif
  169|      1|    }
  170|       |
  171|    257|    errno = 0;
  172|       |
  173|       |    /* Always force the allocated size to be a multiple of pagesize */
  174|    257|    if(initialsize == 0) initialsize = pagesize;
  ------------------
  |  Branch (174:8): [True: 0, False: 257]
  ------------------
  175|    257|    if((initialsize % pagesize) != 0)
  ------------------
  |  Branch (175:8): [True: 243, False: 14]
  ------------------
  176|    243|	initialsize += (pagesize - (initialsize % pagesize));
  177|       |
  178|    257|    nciop = (ncio* )calloc(1,sizeof(ncio));
  179|    257|    if(nciop == NULL) {status = NC_ENOMEM; goto fail;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (179:8): [True: 0, False: 257]
  ------------------
  180|       |
  181|    257|    nciop->ioflags = ioflags;
  182|    257|    *((int*)&nciop->fd) = -1; /* caller will fix */
  183|       |
  184|    257|    *((ncio_relfunc**)&nciop->rel) = memio_rel;
  185|    257|    *((ncio_getfunc**)&nciop->get) = memio_get;
  186|    257|    *((ncio_movefunc**)&nciop->move) = memio_move;
  187|    257|    *((ncio_syncfunc**)&nciop->sync) = memio_sync;
  188|    257|    *((ncio_filesizefunc**)&nciop->filesize) = memio_filesize;
  189|    257|    *((ncio_pad_lengthfunc**)&nciop->pad_length) = memio_pad_length;
  190|    257|    *((ncio_closefunc**)&nciop->close) = memio_close;
  191|       |
  192|    257|    memio = (NCMEMIO*)calloc(1,sizeof(NCMEMIO));
  193|    257|    if(memio == NULL) {status = NC_ENOMEM; goto fail;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (193:8): [True: 0, False: 257]
  ------------------
  194|    257|    *((void* *)&nciop->pvt) = memio;
  195|       |
  196|    257|    *((char**)&nciop->path) = strdup(path);
  197|    257|    if(nciop->path == NULL) {status = NC_ENOMEM; goto fail;}
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (197:8): [True: 0, False: 257]
  ------------------
  198|       |
  199|    257|    if(memiop && memio) *memiop = memio; else free(memio);
  ------------------
  |  Branch (199:8): [True: 257, False: 0]
  |  Branch (199:18): [True: 257, False: 0]
  ------------------
  200|    257|    if(nciopp && nciop) *nciopp = nciop;
  ------------------
  |  Branch (200:8): [True: 257, False: 0]
  |  Branch (200:18): [True: 257, False: 0]
  ------------------
  201|      0|    else {
  202|      0|        if(nciop->path != NULL) free((char*)nciop->path);
  ------------------
  |  Branch (202:12): [True: 0, False: 0]
  ------------------
  203|       |	/* Fix 38699 */
  204|      0|	nciop->path = NULL;
  205|      0|        free(nciop);
  206|      0|    }
  207|    257|    memio->alloc = initialsize;
  208|    257|    memio->pos = 0;
  209|    257|    memio->size = minsize;
  210|    257|    memio->memory = NULL; /* filled in by caller */
  211|       |
  212|    257|    if(fIsSet(ioflags,NC_DISKLESS))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 257]
  |  |  ------------------
  ------------------
  213|      0|	memio->diskless = 1;
  214|    257|    if(fIsSet(ioflags,NC_INMEMORY))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 257, False: 0]
  |  |  ------------------
  ------------------
  215|    257|	memio->inmemory = 1;
  216|    257|    if(fIsSet(ioflags,NC_PERSIST))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 257]
  |  |  ------------------
  ------------------
  217|      0|	memio->persist = 1;
  218|       |
  219|    257|done:
  220|    257|    return status;
  221|       |
  222|      0|fail:
  223|      0|    if(memio != NULL) free(memio);
  ------------------
  |  Branch (223:8): [True: 0, False: 0]
  ------------------
  224|      0|    if(nciop != NULL) {
  ------------------
  |  Branch (224:8): [True: 0, False: 0]
  ------------------
  225|      0|        if(nciop->path != NULL) free((char*)nciop->path);
  ------------------
  |  Branch (225:12): [True: 0, False: 0]
  ------------------
  226|       |	/* Fix 38699 */
  227|       |	nciop->path = NULL;
  228|      0|        free(nciop);
  229|      0|    }
  230|      0|    goto done;
  231|    257|}
memio.c:memio_rel:
  631|  5.39k|{
  632|  5.39k|    NCMEMIO* memio;
  633|  5.39k|    if(nciop == NULL || nciop->pvt == NULL) return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (633:8): [True: 0, False: 5.39k]
  |  Branch (633:25): [True: 0, False: 5.39k]
  ------------------
  634|  5.39k|    memio = (NCMEMIO*)nciop->pvt;
  635|  5.39k|    memio->locked--;
  636|  5.39k|    return NC_NOERR; /* do nothing */
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  637|  5.39k|}
memio.c:memio_get:
  563|  5.57k|{
  564|  5.57k|    int status = NC_NOERR;
  ------------------
  |  |  417|  5.57k|#define NC_NOERR        0          /**< No Error */
  ------------------
  565|  5.57k|    NCMEMIO* memio;
  566|  5.57k|    if(nciop == NULL || nciop->pvt == NULL) return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (566:8): [True: 0, False: 5.57k]
  |  Branch (566:25): [True: 0, False: 5.57k]
  ------------------
  567|  5.57k|    memio = (NCMEMIO*)nciop->pvt;
  568|  5.57k|    status = guarantee(nciop, offset+(off_t)extent);
  569|  5.57k|    memio->locked++;
  570|  5.57k|    if(status != NC_NOERR) return status;
  ------------------
  |  |  417|  5.57k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (570:8): [True: 175, False: 5.39k]
  ------------------
  571|  5.39k|    if(vpp) *vpp = memio->memory+offset;
  ------------------
  |  Branch (571:8): [True: 5.39k, False: 0]
  ------------------
  572|  5.39k|    return NC_NOERR;
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  573|  5.57k|}
memio.c:guarantee:
  545|  5.57k|{
  546|  5.57k|    NCMEMIO* memio = (NCMEMIO*)nciop->pvt;
  547|  5.57k|    if(endpoint0 > memio->alloc) {
  ------------------
  |  Branch (547:8): [True: 175, False: 5.39k]
  ------------------
  548|       |	/* extend the allocated memory and size */
  549|    175|	int status = memio_pad_length(nciop,endpoint0);
  550|    175|	if(status != NC_NOERR) return status;
  ------------------
  |  |  417|    175|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (550:5): [True: 175, False: 0]
  ------------------
  551|    175|    }
  552|  5.39k|    if(memio->size < endpoint0)
  ------------------
  |  Branch (552:8): [True: 0, False: 5.39k]
  ------------------
  553|      0|	memio->size = (size_t)endpoint0;
  554|  5.39k|    return NC_NOERR;
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  555|  5.57k|}
memio.c:memio_sync:
  645|    257|{
  646|    257|    return NC_NOERR; /* do nothing */
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  647|    257|}
memio.c:memio_filesize:
  440|    273|{
  441|    273|    NCMEMIO* memio;
  442|    273|    if(nciop == NULL || nciop->pvt == NULL) return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (442:8): [True: 0, False: 273]
  |  Branch (442:25): [True: 0, False: 273]
  ------------------
  443|    273|    memio = (NCMEMIO*)nciop->pvt;
  444|    273|    if(filesizep != NULL) *filesizep = (off_t)memio->size;
  ------------------
  |  Branch (444:8): [True: 273, False: 0]
  ------------------
  445|    273|    return NC_NOERR;
  ------------------
  |  |  417|    273|#define NC_NOERR        0          /**< No Error */
  ------------------
  446|    273|}
memio.c:memio_pad_length:
  457|    175|{
  458|    175|    NCMEMIO* memio;
  459|    175|    size_t len = (size_t)length;
  460|    175|    if(nciop == NULL || nciop->pvt == NULL) return NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  |  Branch (460:8): [True: 0, False: 175]
  |  Branch (460:25): [True: 0, False: 175]
  ------------------
  461|    175|    memio = (NCMEMIO*)nciop->pvt;
  462|       |
  463|    175|    if(!fIsSet(nciop->ioflags,NC_WRITE))
  ------------------
  |  |   15|    175|#define fIsSet(t, f)     ((t) & (f))
  ------------------
  |  Branch (463:8): [True: 175, False: 0]
  ------------------
  464|    175|        return EPERM; /* attempt to write readonly file*/
  465|      0|    if(memio->locked)
  ------------------
  |  Branch (465:8): [True: 0, False: 0]
  ------------------
  466|      0|	return NC_EINMEMORY;
  ------------------
  |  |  565|      0|#define NC_EINMEMORY     (-135)    /**< In-memory file error */
  ------------------
  467|       |
  468|      0|    if(len > memio->alloc) {
  ------------------
  |  Branch (468:8): [True: 0, False: 0]
  ------------------
  469|       |        /* Realloc the allocated memory to a multiple of the pagesize*/
  470|      0|	size_t newsize = (size_t)len;
  471|      0|	void* newmem = NULL;
  472|       |	/* Round to a multiple of pagesize */
  473|      0|	if((newsize % pagesize) != 0)
  ------------------
  |  Branch (473:5): [True: 0, False: 0]
  ------------------
  474|      0|	    newsize += (pagesize - (newsize % pagesize));
  475|       |
  476|      0|        newmem = (char*)reallocx(memio->memory,newsize,memio->alloc);
  ------------------
  |  |   86|      0|#define reallocx(m,new,old) realloc(m,new)
  ------------------
  477|      0|        if(newmem == NULL) return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  |  Branch (477:12): [True: 0, False: 0]
  ------------------
  478|       |	/* If not copy is set, then fail if the newmem address is different
  479|       |           from old address */
  480|      0|	if(newmem != memio->memory) {
  ------------------
  |  Branch (480:5): [True: 0, False: 0]
  ------------------
  481|      0|	    memio->modified++;
  482|      0|	    if(memio->locked) {
  ------------------
  |  Branch (482:9): [True: 0, False: 0]
  ------------------
  483|      0|		free(newmem);
  484|      0|		return NC_EINMEMORY;
  ------------------
  |  |  565|      0|#define NC_EINMEMORY     (-135)    /**< In-memory file error */
  ------------------
  485|      0|	    }
  486|      0|        }
  487|       |	/* zero out the extra memory */
  488|      0|        memset((void*)((char*)newmem+memio->alloc),0,(size_t)(newsize - memio->alloc));
  489|       |
  490|       |#ifdef DEBUG
  491|       |fprintf(stderr,"realloc: %lu/%lu -> %lu/%lu\n",
  492|       |(unsigned long)memio->memory,(unsigned long)memio->alloc,
  493|       |(unsigned long)newmem,(unsigned long)newsize);
  494|       |#endif
  495|      0|	memio->memory = newmem;
  496|      0|	memio->alloc = newsize;
  497|      0|	memio->modified = 1;
  498|      0|    }
  499|      0|    memio->size = len;
  500|      0|    return NC_NOERR;
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  501|      0|}
memio.c:memio_close:
  515|    257|{
  516|    257|    int status = NC_NOERR;
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  517|    257|    NCMEMIO* memio ;
  518|       |
  519|    257|    if(nciop == NULL || nciop->pvt == NULL) return NC_NOERR;
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (519:8): [True: 0, False: 257]
  |  Branch (519:25): [True: 0, False: 257]
  ------------------
  520|       |
  521|    257|    memio = (NCMEMIO*)nciop->pvt;
  522|    257|    assert(memio != NULL);
  ------------------
  |  Branch (522:5): [True: 0, False: 257]
  |  Branch (522:5): [True: 257, False: 0]
  ------------------
  523|       |
  524|       |    /* See if the user wants the contents persisted to a file */
  525|    257|    if(memio->persist && memio->memory != NULL) {
  ------------------
  |  Branch (525:8): [True: 0, False: 257]
  |  Branch (525:26): [True: 0, False: 0]
  ------------------
  526|      0|	status = writefile(nciop->path,memio);		
  527|      0|    }
  528|       |
  529|       |    /* We only free the memio memory if file is not locked or has been modified */
  530|    257|    if(memio->memory != NULL && (!memio->locked || memio->modified)) {
  ------------------
  |  Branch (530:8): [True: 257, False: 0]
  |  Branch (530:34): [True: 0, False: 257]
  |  Branch (530:52): [True: 0, False: 257]
  ------------------
  531|      0|	free(memio->memory);
  532|      0|	memio->memory = NULL;
  533|      0|    }
  534|       |    /* do cleanup  */
  535|    257|    if(memio != NULL) free(memio);
  ------------------
  |  Branch (535:8): [True: 257, False: 0]
  ------------------
  536|    257|    if(nciop->path != NULL) free((char*)nciop->path);
  ------------------
  |  Branch (536:8): [True: 257, False: 0]
  ------------------
  537|       |    /* Fix 38699 */
  538|       |    nciop->path = NULL;
  539|    257|    free(nciop);
  540|    257|    return status;
  541|    257|}

NC3_initialize:
  180|      1|{
  181|      1|    NC3_dispatch_table = &NC3_dispatcher;
  182|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  183|      1|}
NC3_finalize:
  187|      1|{
  188|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  189|      1|}

NC_check_vlens:
  704|     18|{
  705|     18|    NC_var **vpp;
  706|       |    /* maximum permitted variable size (or size of one record's worth
  707|       |       of a record variable) in bytes.  This is different for format 1
  708|       |       and format 2. */
  709|     18|    long long vlen_max;
  710|     18|    size_t ii;
  711|     18|    size_t large_vars_count;
  712|     18|    size_t rec_vars_count;
  713|     18|    int last = 0;
  714|       |
  715|     18|    if(ncp->vars.nelems == 0)
  ------------------
  |  Branch (715:8): [True: 15, False: 3]
  ------------------
  716|     15|	return NC_NOERR;
  ------------------
  |  |  417|     15|#define NC_NOERR        0          /**< No Error */
  ------------------
  717|       |
  718|      3|    if (fIsSet(ncp->flags,NC_64BIT_DATA)) /* CDF-5 */
  ------------------
  |  |   15|      3|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 2, False: 1]
  |  |  ------------------
  ------------------
  719|      2|	vlen_max = X_INT64_MAX - 3; /* "- 3" handles rounded-up size */
  ------------------
  |  |  107|      2|#define X_INT64_MAX	9223372036854775807LL
  ------------------
  720|      1|    else if (fIsSet(ncp->flags,NC_64BIT_OFFSET) && sizeof(off_t) > 4)
  ------------------
  |  |   15|      2|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (720:52): [True: 0, Folded]
  ------------------
  721|       |	/* CDF2 format and LFS */
  722|      0|	vlen_max = X_UINT_MAX - 3; /* "- 3" handles rounded-up size */
  ------------------
  |  |  105|      0|#define X_UINT_MAX	4294967295U
  ------------------
  723|      1|    else /* CDF1 format */
  724|      1|	vlen_max = X_INT_MAX - 3;
  ------------------
  |  |  104|      1|#define X_INT_MAX	2147483647
  ------------------
  725|       |
  726|       |    /* Loop through vars, first pass is for non-record variables.   */
  727|      3|    large_vars_count = 0;
  728|      3|    rec_vars_count = 0;
  729|      3|    vpp = ncp->vars.value;
  730|    267|    for (ii = 0; ii < ncp->vars.nelems; ii++, vpp++) {
  ------------------
  |  Branch (730:18): [True: 264, False: 3]
  ------------------
  731|    264|	assert(vpp != NULL && *vpp != NULL);
  ------------------
  |  Branch (731:2): [True: 0, False: 264]
  |  Branch (731:2): [True: 0, False: 0]
  |  Branch (731:2): [True: 264, False: 0]
  |  Branch (731:2): [True: 264, False: 0]
  ------------------
  732|    264|	if( !IS_RECVAR(*vpp) ) {
  ------------------
  |  |  221|    264|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:6): [True: 2, False: 262]
  |  |  ------------------
  ------------------
  |  Branch (732:6): [True: 262, False: 2]
  ------------------
  733|    262|	    last = 0;
  734|    262|	    if( NC_check_vlen(*vpp, vlen_max) == 0 ) {
  ------------------
  |  Branch (734:10): [True: 0, False: 262]
  ------------------
  735|      0|                if (fIsSet(ncp->flags,NC_64BIT_DATA)) /* too big for CDF-5 */
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  736|      0|                    return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  737|      0|		large_vars_count++;
  738|      0|		last = 1;
  739|      0|	    }
  740|    262|	} else {
  741|      2|	  rec_vars_count++;
  742|      2|	}
  743|    264|    }
  744|       |    /* OK if last non-record variable size too large, since not used to
  745|       |       compute an offset */
  746|      3|    if( large_vars_count > 1) { /* only one "too-large" variable allowed */
  ------------------
  |  Branch (746:9): [True: 0, False: 3]
  ------------------
  747|      0|      return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  748|      0|    }
  749|       |    /* and it has to be the last one */
  750|      3|    if( large_vars_count == 1 && last == 0) {
  ------------------
  |  Branch (750:9): [True: 0, False: 3]
  |  Branch (750:34): [True: 0, False: 0]
  ------------------
  751|      0|      return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  752|      0|    }
  753|      3|    if( rec_vars_count > 0 ) {
  ------------------
  |  Branch (753:9): [True: 1, False: 2]
  ------------------
  754|       |	/* and if it's the last one, there can't be any record variables */
  755|      1|	if( large_vars_count == 1 && last == 1) {
  ------------------
  |  Branch (755:6): [True: 0, False: 1]
  |  Branch (755:31): [True: 0, False: 0]
  ------------------
  756|      0|	    return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  757|      0|	}
  758|       |	/* Loop through vars, second pass is for record variables.   */
  759|      1|	large_vars_count = 0;
  760|      1|	vpp = ncp->vars.value;
  761|      3|	for (ii = 0; ii < ncp->vars.nelems; ii++, vpp++) {
  ------------------
  |  Branch (761:15): [True: 2, False: 1]
  ------------------
  762|      2|	    if( IS_RECVAR(*vpp) ) {
  ------------------
  |  |  221|      2|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:5): [True: 2, False: 0]
  |  |  |  Branch (221:6): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  763|      2|		last = 0;
  764|      2|		if( NC_check_vlen(*vpp, vlen_max) == 0 ) {
  ------------------
  |  Branch (764:7): [True: 1, False: 1]
  ------------------
  765|      1|                    if (fIsSet(ncp->flags,NC_64BIT_DATA)) /* too big for CDF-5 */
  ------------------
  |  |   15|      1|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  766|      0|                        return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  767|      1|		    large_vars_count++;
  768|      1|		    last = 1;
  769|      1|		}
  770|      2|	    }
  771|      2|	}
  772|       |	/* OK if last record variable size too large, since not used to
  773|       |	   compute an offset */
  774|      1|	if( large_vars_count > 1) { /* only one "too-large" variable allowed */
  ------------------
  |  Branch (774:6): [True: 0, False: 1]
  ------------------
  775|      0|	    return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  776|      0|	}
  777|       |	/* and it has to be the last one */
  778|      1|	if( large_vars_count == 1 && last == 0) {
  ------------------
  |  Branch (778:6): [True: 1, False: 0]
  |  Branch (778:31): [True: 0, False: 1]
  ------------------
  779|      0|	    return NC_EVARSIZE;
  ------------------
  |  |  498|      0|#define NC_EVARSIZE     (-62)      /**< One or more variable sizes violate format constraints */
  ------------------
  780|      0|	}
  781|      1|    }
  782|      3|    return NC_NOERR;
  ------------------
  |  |  417|      3|#define NC_NOERR        0          /**< No Error */
  ------------------
  783|      3|}
NC_check_voffs:
  792|     18|{
  793|     18|    size_t i;
  794|     18|    off_t prev_off;
  795|     18|    NC_var *varp;
  796|       |
  797|     18|    if (ncp->vars.nelems == 0) return NC_NOERR;
  ------------------
  |  |  417|     15|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (797:9): [True: 15, False: 3]
  ------------------
  798|       |
  799|       |    /* Loop through vars, first pass is for non-record variables */
  800|      3|    prev_off = ncp->begin_var;
  801|      8|    for (i=0; i<ncp->vars.nelems; i++) {
  ------------------
  |  Branch (801:15): [True: 7, False: 1]
  ------------------
  802|      7|        varp = ncp->vars.value[i];
  803|      7|        if (IS_RECVAR(varp)) continue;
  ------------------
  |  |  221|      7|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:5): [True: 2, False: 5]
  |  |  |  Branch (221:6): [True: 2, False: 5]
  |  |  ------------------
  ------------------
  804|       |
  805|      5|        if (varp->begin < prev_off) {
  ------------------
  |  Branch (805:13): [True: 2, False: 3]
  ------------------
  806|       |#if 0
  807|       |            fprintf(stderr,"Variable \"%s\" begin offset (%lld) is less than previous variable end offset (%lld)\n", varp->name->cp, varp->begin, prev_off);
  808|       |#endif
  809|      2|            return NC_ENOTNC;
  ------------------
  |  |  473|      2|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
  810|      2|        }
  811|      3|        prev_off = varp->begin + varp->len;
  812|      3|    }
  813|       |
  814|      1|    if (ncp->begin_rec < prev_off) {
  ------------------
  |  Branch (814:9): [True: 0, False: 1]
  ------------------
  815|       |#if 0
  816|       |        fprintf(stderr,"Record variable section begin offset (%lld) is less than fix-sized variable section end offset (%lld)\n", varp->begin, prev_off);
  817|       |#endif
  818|      0|        return NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
  819|      0|    }
  820|       |
  821|       |    /* Loop through vars, second pass is for record variables */
  822|      1|    prev_off = ncp->begin_rec;
  823|      3|    for (i=0; i<ncp->vars.nelems; i++) {
  ------------------
  |  Branch (823:15): [True: 2, False: 1]
  ------------------
  824|      2|        varp = ncp->vars.value[i];
  825|      2|        if (!IS_RECVAR(varp)) continue;
  ------------------
  |  |  221|      2|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:6): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (825:13): [True: 0, False: 2]
  ------------------
  826|       |
  827|      2|        if (varp->begin < prev_off) {
  ------------------
  |  Branch (827:13): [True: 0, False: 2]
  ------------------
  828|       |#if 0
  829|       |            fprintf(stderr,"Variable \"%s\" begin offset (%lld) is less than previous variable end offset (%lld)\n", varp->name->cp, varp->begin, prev_off);
  830|       |#endif
  831|      0|            return NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
  832|      0|        }
  833|      2|        prev_off = varp->begin + varp->len;
  834|      2|    }
  835|       |
  836|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  837|      1|}
NC_calcsize:
  952|     16|{
  953|     16|	NC_var **vpp = (NC_var **)ncp->vars.value;
  954|     16|	NC_var *last_fix = NULL;	/* last "non-record" var */
  955|     16|	int numrecvars = 0;	/* number of record variables */
  956|       |
  957|     16|	if(ncp->vars.nelems == 0) { /* no non-record variables and
  ------------------
  |  Branch (957:5): [True: 15, False: 1]
  ------------------
  958|       |				       no record variables */
  959|     15|	    *calcsizep = (off_t)ncp->xsz; /* size of header */
  960|     15|	    return NC_NOERR;
  ------------------
  |  |  417|     15|#define NC_NOERR        0          /**< No Error */
  ------------------
  961|     15|	}
  962|       |
  963|      1|	if (vpp)
  ------------------
  |  Branch (963:6): [True: 1, False: 0]
  ------------------
  964|      1|	{
  965|      1|		NC_var *const *const end = &vpp[ncp->vars.nelems];
  966|      3|		for( /*NADA*/; vpp < end; vpp++) {
  ------------------
  |  Branch (966:18): [True: 2, False: 1]
  ------------------
  967|      2|		    if(IS_RECVAR(*vpp)) {
  ------------------
  |  |  221|      2|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:5): [True: 2, False: 0]
  |  |  |  Branch (221:6): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  968|      2|			numrecvars++;
  969|      2|		    } else {
  970|      0|			last_fix = *vpp;
  971|      0|		    }
  972|      2|		}
  973|      1|	}
  974|       |
  975|      1|	if(numrecvars == 0) {
  ------------------
  |  Branch (975:5): [True: 0, False: 1]
  ------------------
  976|      0|	    off_t varsize;
  977|      0|	    assert(last_fix != NULL);
  ------------------
  |  Branch (977:6): [True: 0, False: 0]
  |  Branch (977:6): [True: 0, False: 0]
  ------------------
  978|      0|	    varsize = last_fix->len;
  979|      0|	    if(last_fix->len == X_UINT_MAX) { /* huge last fixed var */
  ------------------
  |  |  105|      0|#define X_UINT_MAX	4294967295U
  ------------------
  |  Branch (979:9): [True: 0, False: 0]
  ------------------
  980|      0|		varsize = 1;
  981|      0|		for(size_t i = 0; i < last_fix->ndims; i++ ) {
  ------------------
  |  Branch (981:21): [True: 0, False: 0]
  ------------------
  982|      0|		    varsize *= (last_fix->shape ? last_fix->shape[i] : 1);
  ------------------
  |  Branch (982:19): [True: 0, False: 0]
  ------------------
  983|      0|		}
  984|      0|	    }
  985|      0|	    *calcsizep = last_fix->begin + varsize;
  986|       |	    /*last_var = last_fix;*/
  987|      1|	} else {       /* we have at least one record variable */
  988|      1|	    *calcsizep = ncp->begin_rec + (off_t)(ncp->numrecs * ncp->recsize);
  989|      1|	}
  990|       |
  991|      1|	return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
  992|      1|}
NC3_open:
 1151|    257|{
 1152|    257|	int status;
 1153|    257|	NC3_INFO* nc3 = NULL;
 1154|    257|        NC *nc;
 1155|       |
 1156|       |        /* Find NC struct for this file. */
 1157|    257|        if ((status = NC_check_id(ncid, &nc)))
  ------------------
  |  Branch (1157:13): [True: 0, False: 257]
  ------------------
 1158|      0|            return status;
 1159|       |
 1160|       |	/* Create our specific NC3_INFO instance */
 1161|    257|	nc3 = new_NC3INFO(chunksizehintp);
 1162|       |
 1163|       |#if ALWAYS_NC_SHARE /* DEBUG */
 1164|       |	fSet(ioflags, NC_SHARE);
 1165|       |#endif
 1166|       |
 1167|       |	/*
 1168|       |	 * Only pe 0 is valid.
 1169|       |	 */
 1170|    257|	if(basepe != 0) {
  ------------------
  |  Branch (1170:5): [True: 0, False: 257]
  ------------------
 1171|      0|            if(nc3) {
  ------------------
  |  Branch (1171:16): [True: 0, False: 0]
  ------------------
 1172|      0|                free(nc3);
 1173|      0|                nc3 = NULL;
 1174|      0|            }
 1175|      0|            status = NC_EINVAL;
  ------------------
  |  |  427|      0|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
 1176|      0|            goto unwind_alloc;
 1177|      0|        }
 1178|       |
 1179|    257|        status = ncio_open(path, ioflags, 0, 0, &nc3->chunk, parameters,
 1180|    257|			       &nc3->nciop, NULL);
 1181|    257|	if(status)
  ------------------
  |  Branch (1181:5): [True: 0, False: 257]
  ------------------
 1182|      0|		goto unwind_alloc;
 1183|       |
 1184|    257|	assert(nc3->state == 0);
  ------------------
  |  Branch (1184:2): [True: 0, False: 257]
  |  Branch (1184:2): [True: 257, False: 0]
  ------------------
 1185|       |
 1186|    257|	if(fIsSet(nc3->nciop->ioflags, NC_SHARE))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 257]
  |  |  ------------------
  ------------------
 1187|      0|	{
 1188|       |		/*
 1189|       |		 * NC_SHARE implies sync up the number of records as well.
 1190|       |		 * (File format version one.)
 1191|       |		 * Note that other header changes are not shared
 1192|       |		 * automatically.  Some sort of IPC (external to this package)
 1193|       |		 * would be used to trigger a call to nc_sync().
 1194|       |		 */
 1195|      0|		fSet(nc3->state, NC_NSYNC);
  ------------------
  |  |   13|      0|#define fSet(t, f)       ((t) |= (f))
  ------------------
 1196|      0|	}
 1197|       |
 1198|    257|	status = nc_get_NC(nc3);
 1199|    257|	if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1199:5): [True: 241, False: 16]
  ------------------
 1200|    241|		goto unwind_ioc;
 1201|       |
 1202|     16|	if(chunksizehintp != NULL)
  ------------------
  |  Branch (1202:5): [True: 0, False: 16]
  ------------------
 1203|      0|		*chunksizehintp = nc3->chunk;
 1204|       |
 1205|       |	/* Link nc3 and nc */
 1206|     16|        NC3_DATA_SET(nc,nc3);
  ------------------
  |  |  361|     16|#define NC3_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
  ------------------
 1207|     16|	nc->int_ncid = nc3->nciop->fd;
 1208|       |
 1209|     16|	return NC_NOERR;
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
 1210|       |
 1211|    241|unwind_ioc:
 1212|    241|	if(nc3) {
  ------------------
  |  Branch (1212:5): [True: 241, False: 0]
  ------------------
 1213|    241|    	    (void) ncio_close(nc3->nciop, 0);
 1214|    241|	    nc3->nciop = NULL;
 1215|    241|	}
 1216|       |	/*FALLTHRU*/
 1217|    241|unwind_alloc:
 1218|    241|	free_NC3INFO(nc3);
 1219|    241|	if(nc)
  ------------------
  |  Branch (1219:5): [True: 241, False: 0]
  ------------------
 1220|    241|            NC3_DATA_SET(nc,NULL);
  ------------------
  |  |  361|    241|#define NC3_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
  ------------------
 1221|    241|	return status;
 1222|    241|}
NC3_close:
 1293|     16|{
 1294|     16|	int status = NC_NOERR;
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
 1295|     16|	NC *nc;
 1296|     16|	NC3_INFO* nc3;
 1297|       |
 1298|     16|	status = NC_check_id(ncid, &nc);
 1299|     16|	if(status != NC_NOERR)
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1299:5): [True: 0, False: 16]
  ------------------
 1300|      0|	    return status;
 1301|     16|	nc3 = NC3_DATA(nc);
  ------------------
  |  |  360|     16|#define NC3_DATA(nc) ((NC3_INFO*)(nc)->dispatchdata)
  ------------------
 1302|       |
 1303|     16|	if(NC_indef(nc3))
  ------------------
  |  |  266|     16|    (NC_IsNew(ncp) || fIsSet((ncp)->state, NC_INDEF))
  |  |  ------------------
  |  |  |  |  263|     16|    fIsSet((ncp)->state, NC_CREAT)
  |  |  |  |  ------------------
  |  |  |  |  |  |   15|     32|#define fIsSet(t, f)     ((t) & (f))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (15:26): [True: 0, False: 16]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (NC_IsNew(ncp) || fIsSet((ncp)->state, NC_INDEF))
  |  |  ------------------
  |  |  |  |   15|     16|#define fIsSet(t, f)     ((t) & (f))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (15:26): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1304|      0|	{
 1305|      0|		status = NC_endef(nc3, 0, 1, 0, 1); /* TODO: defaults */
 1306|      0|		if(status != NC_NOERR )
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1306:6): [True: 0, False: 0]
  ------------------
 1307|      0|		{
 1308|      0|			(void) NC3_abort(ncid);
 1309|      0|			return status;
 1310|      0|		}
 1311|      0|	}
 1312|     16|	else if(!NC_readonly(nc3))
  ------------------
  |  |  257|     16|    (!fIsSet((ncp)->nciop->ioflags, NC_WRITE))
  |  |  ------------------
  |  |  |  |   15|     16|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  ------------------
  |  Branch (1312:10): [True: 0, False: 16]
  ------------------
 1313|      0|	{
 1314|      0|		status = NC_sync(nc3);
 1315|       |		/* flush buffers before any filesize comparisons */
 1316|      0|		(void) ncio_sync(nc3->nciop);
 1317|      0|	}
 1318|       |
 1319|       |	/*
 1320|       |	 * If file opened for writing and filesize is less than
 1321|       |	 * what it should be (due to previous use of NOFILL mode),
 1322|       |	 * pad it to correct size, as reported by NC_calcsize().
 1323|       |	 */
 1324|     16|	if (status == NC_NOERR) {
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1324:6): [True: 16, False: 0]
  ------------------
 1325|     16|	    off_t filesize; 	/* current size of open file */
 1326|     16|	    off_t calcsize;	/* calculated file size, from header */
 1327|     16|	    status = ncio_filesize(nc3->nciop, &filesize);
 1328|     16|	    if(status != NC_NOERR)
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1328:9): [True: 0, False: 16]
  ------------------
 1329|      0|		return status;
 1330|     16|	    status = NC_calcsize(nc3, &calcsize);
 1331|     16|	    if(status != NC_NOERR)
  ------------------
  |  |  417|     16|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1331:9): [True: 0, False: 16]
  ------------------
 1332|      0|		return status;
 1333|     16|	    if(filesize < calcsize && !NC_readonly(nc3)) {
  ------------------
  |  |  257|      1|    (!fIsSet((ncp)->nciop->ioflags, NC_WRITE))
  |  |  ------------------
  |  |  |  |   15|      1|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  ------------------
  |  Branch (1333:9): [True: 1, False: 15]
  |  Branch (1333:32): [True: 0, False: 1]
  ------------------
 1334|      0|		status = ncio_pad_length(nc3->nciop, calcsize);
 1335|      0|		if(status != NC_NOERR)
  ------------------
  |  |  417|      0|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1335:6): [True: 0, False: 0]
  ------------------
 1336|      0|		    return status;
 1337|      0|	    }
 1338|     16|	}
 1339|       |
 1340|     16|	if(params != NULL && (nc->mode & NC_INMEMORY) != 0) {
  ------------------
  |  |  189|      0|#define NC_INMEMORY      0x8000  /**< Read from memory. Mode flag for nc_open() or nc_create() */
  ------------------
  |  Branch (1340:5): [True: 0, False: 16]
  |  Branch (1340:23): [True: 0, False: 0]
  ------------------
 1341|      0|	    NC_memio* memio = (NC_memio*)params;
 1342|       |            /* Extract the final memory size &/or contents */
 1343|      0|            status = memio_extract(nc3->nciop,&memio->size,&memio->memory);
 1344|      0|        }
 1345|       |
 1346|     16|	(void) ncio_close(nc3->nciop, 0);
 1347|     16|	nc3->nciop = NULL;
 1348|       |
 1349|     16|	free_NC3INFO(nc3);
 1350|     16|        NC3_DATA_SET(nc,NULL);
  ------------------
  |  |  361|     16|#define NC3_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
  ------------------
 1351|       |
 1352|     16|	return status;
 1353|     16|}
nc3internal.c:new_NC3INFO:
   53|    257|{
   54|    257|	NC3_INFO *ncp;
   55|    257|	ncp = (NC3_INFO*)calloc(1,sizeof(NC3_INFO));
   56|    257|	if(ncp == NULL) return ncp;
  ------------------
  |  Branch (56:5): [True: 0, False: 257]
  ------------------
   57|    257|        ncp->chunk = chunkp != NULL ? *chunkp : NC_SIZEHINT_DEFAULT;
  ------------------
  |  |  294|    514|#define NC_SIZEHINT_DEFAULT 0
  ------------------
  |  Branch (57:22): [True: 0, False: 257]
  ------------------
   58|       |	/* Note that ncp->xsz is not set yet because we do not know the file format */
   59|    257|	return ncp;
   60|    257|}
nc3internal.c:free_NC3INFO:
   42|    257|{
   43|    257|	if(nc3 == NULL)
  ------------------
  |  Branch (43:5): [True: 0, False: 257]
  ------------------
   44|      0|		return;
   45|    257|	free_NC_dimarrayV(&nc3->dims);
   46|    257|	free_NC_attrarrayV(&nc3->attrs);
   47|    257|	free_NC_vararrayV(&nc3->vars);
   48|    257|	free(nc3);
   49|    257|}

ncio_open:
   88|    257|{
   89|       |#ifdef NETCDF_ENABLE_BYTERANGE
   90|       |    int modetest = urlmodetest(path);
   91|       |#endif
   92|       |
   93|       |    /* Diskless open has the following constraints:
   94|       |       1. file must be classic version 1 or 2 or 5
   95|       |     */
   96|    257|    if(fIsSet(ioflags,NC_DISKLESS)) {
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 257]
  |  |  ------------------
  ------------------
   97|      0|        return memio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
   98|      0|    }
   99|    257|    if(fIsSet(ioflags,NC_INMEMORY)) {
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 257, False: 0]
  |  |  ------------------
  ------------------
  100|    257|        return memio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  101|    257|    }
  102|      0|#  ifdef USE_MMAP
  103|      0|    if(fIsSet(ioflags,NC_MMAP)) {
  ------------------
  |  |   15|      0|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  104|      0|        return mmapio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  105|      0|    }
  106|      0|#  endif /*USE_MMAP*/
  107|       |#  ifdef NETCDF_ENABLE_BYTERANGE
  108|       |   if(modetest == NC_HTTP) {
  109|       |        return httpio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  110|       |   }
  111|       |#  ifdef NETCDF_ENABLE_S3
  112|       |   if(modetest == NC_S3SDK) {
  113|       |       return s3io_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  114|       |   }
  115|       |#  endif
  116|       |#  endif /*NETCDF_ENABLE_BYTERANGE*/
  117|       |
  118|       |#ifdef USE_STDIO
  119|       |    return stdio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  120|       |#elif defined(USE_FFIO)
  121|       |    return ffio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  122|       |#else
  123|      0|    return posixio_open(path,ioflags,igeto,igetsz,sizehintp,parameters,iopp,mempp);
  124|      0|#endif
  125|      0|}
ncio_rel:
  132|  5.39k|{
  133|  5.39k|    return nciop->rel(nciop,offset,rflags);
  134|  5.39k|}
ncio_get:
  139|  5.57k|{
  140|  5.57k|    return nciop->get(nciop,offset,extent,rflags,vpp);
  141|  5.57k|}
ncio_sync:
  151|    257|{
  152|    257|    return nciop->sync(nciop);
  153|    257|}
ncio_filesize:
  157|    273|{
  158|    273|    return nciop->filesize(nciop,filesizep);
  159|    273|}
ncio_close:
  169|    257|{
  170|       |    /* close and release all resources associated
  171|       |       with nciop, including nciop
  172|       |    */
  173|    257|    int status = nciop->close(nciop,doUnlink);
  174|    257|    return status;
  175|    257|}

ncx_len_NC:
 1318|     23|{
 1319|     23|	int version=1;
 1320|     23|	size_t xlen = sizeof(ncmagic);
 1321|       |
 1322|     23|	assert(ncp != NULL);
  ------------------
  |  Branch (1322:2): [True: 0, False: 23]
  |  Branch (1322:2): [True: 23, False: 0]
  ------------------
 1323|     23|	if (fIsSet(ncp->flags, NC_64BIT_DATA)) /* CDF-5 */
  ------------------
  |  |   15|     23|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 5, False: 18]
  |  |  ------------------
  ------------------
 1324|      5|		version = 5;
 1325|     18|    	else if (fIsSet(ncp->flags, NC_64BIT_OFFSET)) /* CDF-2 */
  ------------------
  |  |   15|     18|#define fIsSet(t, f)     ((t) & (f))
  |  |  ------------------
  |  |  |  Branch (15:26): [True: 4, False: 14]
  |  |  ------------------
  ------------------
 1326|      4|		version = 2;
 1327|       |
 1328|     23|	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* numrecs */
  ------------------
  |  |   78|      5|#define X_SIZEOF_INT64		8
  ------------------
              	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* numrecs */
  ------------------
  |  |   89|     18|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|     41|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (1328:10): [True: 5, False: 18]
  ------------------
 1329|     23|	xlen += ncx_len_NC_dimarray(&ncp->dims, version);
 1330|     23|	xlen += ncx_len_NC_attrarray(&ncp->attrs, version);
 1331|     23|	xlen += ncx_len_NC_vararray(&ncp->vars, sizeof_off_t, version);
 1332|       |
 1333|     23|	return xlen;
 1334|     23|}
nc_get_NC:
 1439|    257|{
 1440|    257|	int status;
 1441|    257|	v1hs gs; /* the get stream */
 1442|       |
 1443|    257|	assert(ncp != NULL);
  ------------------
  |  Branch (1443:2): [True: 0, False: 257]
  |  Branch (1443:2): [True: 257, False: 0]
  ------------------
 1444|       |
 1445|       |	/* Initialize stream gs */
 1446|       |
 1447|    257|	gs.nciop = ncp->nciop;
 1448|    257|	gs.offset = 0; /* beginning of file */
 1449|    257|	gs.extent = 0;
 1450|    257|	gs.flags = 0;
 1451|    257|	gs.version = 0;
 1452|    257|	gs.base = NULL;
 1453|    257|	gs.pos = gs.base;
 1454|       |
 1455|    257|	{
 1456|       |		/*
 1457|       |		 * Come up with a reasonable stream read size.
 1458|       |		 */
 1459|    257|	        off_t filesize;
 1460|    257|		size_t extent = ncp->xsz;
 1461|       |
 1462|    257|		if(extent <= ((fIsSet(ncp->flags, NC_64BIT_DATA))?MIN_NC5_XSZ:MIN_NC3_XSZ))
  ------------------
  |  |   15|    257|#define fIsSet(t, f)     ((t) & (f))
  ------------------
              		if(extent <= ((fIsSet(ncp->flags, NC_64BIT_DATA))?MIN_NC5_XSZ:MIN_NC3_XSZ))
  ------------------
  |  |   40|      0|#define MIN_NC5_XSZ 48
  ------------------
              		if(extent <= ((fIsSet(ncp->flags, NC_64BIT_DATA))?MIN_NC5_XSZ:MIN_NC3_XSZ))
  ------------------
  |  |   38|    257|#define MIN_NC3_XSZ 32
  ------------------
  |  Branch (1462:6): [True: 257, False: 0]
  |  Branch (1462:17): [True: 0, False: 257]
  ------------------
 1463|    257|		{
 1464|    257|		        status = ncio_filesize(ncp->nciop, &filesize);
 1465|    257|			if(status)
  ------------------
  |  Branch (1465:7): [True: 0, False: 257]
  ------------------
 1466|      0|			    return status;
 1467|    257|			if(filesize < sizeof(ncmagic)) { /* too small, not netcdf */
  ------------------
  |  Branch (1467:7): [True: 0, False: 257]
  ------------------
 1468|       |
 1469|      0|			    status = NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1470|      0|			    return status;
 1471|      0|			}
 1472|       |			/* first time read */
 1473|    257|			extent = ncp->chunk;
 1474|       |			/* Protection for when ncp->chunk is huge;
 1475|       |			 * no need to read hugely. */
 1476|    257|	      		if(extent > 4096)
  ------------------
  |  Branch (1476:13): [True: 222, False: 35]
  ------------------
 1477|    222|				extent = 4096;
 1478|    257|			if(extent > filesize)
  ------------------
  |  Branch (1478:7): [True: 0, False: 257]
  ------------------
 1479|      0|			        extent = (size_t)filesize;
 1480|    257|		}
 1481|      0|		else if(extent > ncp->chunk)
  ------------------
  |  Branch (1481:11): [True: 0, False: 0]
  ------------------
 1482|      0|		    extent = ncp->chunk;
 1483|       |
 1484|       |		/*
 1485|       |		 * Invalidate the I/O buffers to force a read of the header
 1486|       |		 * region.
 1487|       |		 */
 1488|    257|		status = ncio_sync(gs.nciop);
 1489|    257|		if(status)
  ------------------
  |  Branch (1489:6): [True: 0, False: 257]
  ------------------
 1490|      0|			return status;
 1491|       |
 1492|    257|		status = fault_v1hs(&gs, extent);
 1493|    257|		if(status)
  ------------------
  |  Branch (1493:6): [True: 0, False: 257]
  ------------------
 1494|      0|			return status;
 1495|    257|	}
 1496|       |
 1497|       |	/* get the header from the stream gs */
 1498|       |
 1499|    257|	{
 1500|       |		/* Get & check magic number */
 1501|    257|		schar magic[sizeof(ncmagic)];
 1502|    257|		(void) memset(magic, 0, sizeof(magic));
 1503|       |
 1504|    257|		status = ncx_getn_schar_schar(
 1505|    257|			(const void **)(&gs.pos), sizeof(magic), magic);
 1506|    257|        if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1506:12): [True: 0, False: 257]
  ------------------
 1507|      0|			goto unwind_get;
 1508|       |
 1509|    257|		if(memcmp(magic, ncmagic, sizeof(ncmagic)-1) != 0)
  ------------------
  |  Branch (1509:6): [True: 0, False: 257]
  ------------------
 1510|      0|		{
 1511|      0|			status = NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1512|      0|			goto unwind_get;
 1513|      0|		}
 1514|       |		/* Check version number in last byte of magic */
 1515|    257|		if (magic[sizeof(ncmagic)-1] == 0x1) {
  ------------------
  |  Branch (1515:7): [True: 80, False: 177]
  ------------------
 1516|     80|		  gs.version = 1;
 1517|    177|		} else if (magic[sizeof(ncmagic)-1] == 0x2) {
  ------------------
  |  Branch (1517:14): [True: 93, False: 84]
  ------------------
 1518|     93|		  gs.version = 2;
 1519|     93|		  fSet(ncp->flags, NC_64BIT_OFFSET);
  ------------------
  |  |   13|     93|#define fSet(t, f)       ((t) |= (f))
  ------------------
 1520|       |		  /* Now we support version 2 file access on non-LFS systems -- rkr */
 1521|       |#if 0
 1522|       |		  if (sizeof(off_t) != 8) {
 1523|       |		    fprintf(stderr, "NETCDF WARNING: Version 2 file on 32-bit system.\n");
 1524|       |		  }
 1525|       |#endif
 1526|     93|		} else if (magic[sizeof(ncmagic)-1] == 0x5) {
  ------------------
  |  Branch (1526:14): [True: 84, False: 0]
  ------------------
 1527|     84|		  gs.version = 5;
 1528|     84|		  fSet(ncp->flags, NC_64BIT_DATA);
  ------------------
  |  |   13|     84|#define fSet(t, f)       ((t) |= (f))
  ------------------
 1529|     84|		} else {
 1530|      0|			status = NC_ENOTNC;
  ------------------
  |  |  473|      0|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1531|      0|			goto unwind_get;
 1532|      0|		}
 1533|    257|	}
 1534|       |
 1535|    257|	{
 1536|    257|	size_t nrecs = 0;
 1537|    257|       	if (gs.version == 5) {
  ------------------
  |  Branch (1537:13): [True: 84, False: 173]
  ------------------
 1538|     84|		unsigned long long tmp = 0;
 1539|     84|		status = ncx_get_uint64((const void **)(&gs.pos), &tmp);
 1540|     84|		nrecs = (size_t)tmp;
 1541|     84|       	}
 1542|    173|       	else
 1543|    173|	    status = ncx_get_size_t((const void **)(&gs.pos), &nrecs);
 1544|    257|    if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1544:8): [True: 0, False: 257]
  ------------------
 1545|      0|		goto unwind_get;
 1546|    257|	NC_set_numrecs(ncp, nrecs);
  ------------------
  |  |  293|    257|    {(nc3i)->numrecs = (nrecs);}
  ------------------
 1547|    257|	}
 1548|       |
 1549|    257|	assert((char *)gs.pos < (char *)gs.end);
  ------------------
  |  Branch (1549:2): [True: 0, False: 257]
  |  Branch (1549:2): [True: 257, False: 0]
  ------------------
 1550|       |
 1551|    257|	status = v1h_get_NC_dimarray(&gs, &ncp->dims);
 1552|    257|    if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1552:8): [True: 78, False: 179]
  ------------------
 1553|     78|		goto unwind_get;
 1554|       |
 1555|    179|	status = v1h_get_NC_attrarray(&gs, &ncp->attrs);
 1556|    179|    if(status != NC_NOERR)
  ------------------
  |  |  417|    179|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1556:8): [True: 86, False: 93]
  ------------------
 1557|     86|		goto unwind_get;
 1558|       |
 1559|     93|	status = v1h_get_NC_vararray(&gs, &ncp->vars);
 1560|     93|    if(status != NC_NOERR)
  ------------------
  |  |  417|     93|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1560:8): [True: 70, False: 23]
  ------------------
 1561|     70|		goto unwind_get;
 1562|       |
 1563|     23|	ncp->xsz = ncx_len_NC(ncp, (gs.version == 1) ? 4 : 8);
  ------------------
  |  Branch (1563:29): [True: 14, False: 9]
  ------------------
 1564|       |
 1565|     23|	status = NC_computeshapes(ncp);
 1566|     23|    if(status != NC_NOERR)
  ------------------
  |  |  417|     23|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1566:8): [True: 5, False: 18]
  ------------------
 1567|      5|		goto unwind_get;
 1568|       |
 1569|     18|	status = NC_check_vlens(ncp);
 1570|     18|    if(status != NC_NOERR)
  ------------------
  |  |  417|     18|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1570:8): [True: 0, False: 18]
  ------------------
 1571|      0|		goto unwind_get;
 1572|       |
 1573|     18|	status = NC_check_voffs(ncp);
 1574|     18|    if(status != NC_NOERR)
  ------------------
  |  |  417|     18|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1574:8): [True: 2, False: 16]
  ------------------
 1575|      2|		goto unwind_get;
 1576|       |
 1577|    257|unwind_get:
 1578|    257|	(void) rel_v1hs(&gs);
 1579|    257|	return status;
 1580|     18|}
v1hpg.c:ncx_len_NC_dimarray:
  443|     23|{
  444|     23|	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
  ------------------
  |  |  225|     23|#define X_SIZEOF_NCTYPE X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|     23|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  445|     23|	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   78|      5|#define X_SIZEOF_INT64		8
  ------------------
              	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   89|     18|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|     41|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (445:10): [True: 5, False: 18]
  ------------------
  446|     23|	if(ncap == NULL)
  ------------------
  |  Branch (446:5): [True: 0, False: 23]
  ------------------
  447|      0|		return xlen;
  448|       |	/* else */
  449|     23|	{
  450|     23|		const NC_dim **dpp = (const NC_dim **)ncap->value;
  451|     23|		if (dpp)
  ------------------
  |  Branch (451:7): [True: 6, False: 17]
  ------------------
  452|      6|		{
  453|      6|			const NC_dim *const *const end = &dpp[ncap->nelems];
  454|    885|			for(  /*NADA*/; dpp < end; dpp++)
  ------------------
  |  Branch (454:20): [True: 879, False: 6]
  ------------------
  455|    879|			{
  456|    879|				xlen += ncx_len_NC_dim(*dpp,version);
  457|    879|			}
  458|      6|		}
  459|     23|	}
  460|     23|	return xlen;
  461|     23|}
v1hpg.c:ncx_len_NC_dim:
  375|    879|{
  376|    879|	size_t sz;
  377|       |
  378|    879|	assert(dimp != NULL);
  ------------------
  |  Branch (378:2): [True: 0, False: 879]
  |  Branch (378:2): [True: 879, False: 0]
  ------------------
  379|       |
  380|    879|	sz = ncx_len_NC_string(dimp->name, version);
  381|    879|	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T;
  ------------------
  |  |   78|      0|#define X_SIZEOF_INT64		8
  ------------------
              	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T;
  ------------------
  |  |   89|    879|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|  1.75k|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (381:8): [True: 0, False: 879]
  ------------------
  382|       |
  383|    879|	return(sz);
  384|    879|}
v1hpg.c:ncx_len_NC_string:
  262|  1.70k|{
  263|  1.70k|	size_t sz = (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_INT; /* nchars */
  ------------------
  |  |   78|    577|#define X_SIZEOF_INT64		8
  ------------------
              	size_t sz = (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_INT; /* nchars */
  ------------------
  |  |   65|  2.83k|#define X_SIZEOF_INT		4	/* xdr_int */
  ------------------
  |  Branch (263:14): [True: 577, False: 1.12k]
  ------------------
  264|       |
  265|  1.70k|	assert(ncstrp != NULL);
  ------------------
  |  Branch (265:2): [True: 0, False: 1.70k]
  |  Branch (265:2): [True: 1.70k, False: 0]
  ------------------
  266|       |
  267|  1.70k|	if(ncstrp->nchars != 0)
  ------------------
  |  Branch (267:5): [True: 243, False: 1.46k]
  ------------------
  268|    243|	{
  269|       |#if 0
  270|       |		assert(ncstrp->nchars % X_ALIGN == 0);
  271|       |		sz += ncstrp->nchars;
  272|       |#else
  273|    243|		sz += _RNDUP(ncstrp->nchars, X_ALIGN);
  ------------------
  |  |   14|    243|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |   15|    243|	* (unit))
  ------------------
  274|    243|#endif
  275|    243|	}
  276|  1.70k|	return sz;
  277|  1.70k|}
v1hpg.c:ncx_len_NC_attrarray:
  794|    849|{
  795|    849|	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
  ------------------
  |  |  225|    849|#define X_SIZEOF_NCTYPE X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|    849|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  796|    849|	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   78|    582|#define X_SIZEOF_INT64		8
  ------------------
              	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   89|    267|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|  1.11k|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (796:10): [True: 582, False: 267]
  ------------------
  797|    849|	if(ncap == NULL)
  ------------------
  |  Branch (797:5): [True: 0, False: 849]
  ------------------
  798|      0|		return xlen;
  799|       |	/* else */
  800|    849|	{
  801|    849|		const NC_attr **app = (const NC_attr **)ncap->value;
  802|    849|		if (app)
  ------------------
  |  Branch (802:7): [True: 0, False: 849]
  ------------------
  803|      0|		{
  804|      0|			const NC_attr *const *const end = &app[ncap->nelems];
  805|      0|			for( /*NADA*/; app < end; app++)
  ------------------
  |  Branch (805:19): [True: 0, False: 0]
  ------------------
  806|      0|			{
  807|      0|				xlen += ncx_len_NC_attr(*app,version);
  808|      0|			}
  809|      0|		}
  810|    849|	}
  811|    849|	return xlen;
  812|    849|}
v1hpg.c:ncx_len_NC_vararray:
 1097|     23|{
 1098|     23|	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
  ------------------
  |  |  225|     23|#define X_SIZEOF_NCTYPE X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|     23|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
 1099|     23|	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   78|      5|#define X_SIZEOF_INT64		8
  ------------------
              	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
  ------------------
  |  |   89|     18|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|     41|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (1099:10): [True: 5, False: 18]
  ------------------
 1100|     23|	if(ncap == NULL)
  ------------------
  |  Branch (1100:5): [True: 0, False: 23]
  ------------------
 1101|      0|		return xlen;
 1102|       |	/* else */
 1103|     23|	{
 1104|     23|		const NC_var **vpp = (const NC_var **)ncap->value;
 1105|     23|		if (vpp)
  ------------------
  |  Branch (1105:7): [True: 8, False: 15]
  ------------------
 1106|      8|		{
 1107|      8|			const NC_var *const *const end = &vpp[ncap->nelems];
 1108|    834|			for( /*NADA*/; vpp < end; vpp++)
  ------------------
  |  Branch (1108:19): [True: 826, False: 8]
  ------------------
 1109|    826|			{
 1110|    826|				xlen += ncx_len_NC_var(*vpp, sizeof_off_t, version);
 1111|    826|			}
 1112|      8|		}
 1113|     23|	}
 1114|     23|	return xlen;
 1115|     23|}
v1hpg.c:ncx_len_NC_var:
  927|    826|{
  928|    826|	size_t sz;
  929|       |
  930|    826|	assert(varp != NULL);
  ------------------
  |  Branch (930:2): [True: 0, False: 826]
  |  Branch (930:2): [True: 826, False: 0]
  ------------------
  931|    826|	assert(sizeof_off_t != 0);
  ------------------
  |  Branch (931:2): [True: 0, False: 826]
  |  Branch (931:2): [True: 826, False: 0]
  ------------------
  932|       |
  933|    826|	sz = ncx_len_NC_string(varp->name, version);
  934|    826|        if (version == 5) {
  ------------------
  |  Branch (934:13): [True: 577, False: 249]
  ------------------
  935|    577|	    sz += X_SIZEOF_INT64; /* ndims */
  ------------------
  |  |   78|    577|#define X_SIZEOF_INT64		8
  ------------------
  936|    577|	    sz += ncx_len_int64(varp->ndims); /* dimids */
  ------------------
  |  |  163|    577|	((nelems) * X_SIZEOF_INT64)
  |  |  ------------------
  |  |  |  |   78|    577|#define X_SIZEOF_INT64		8
  |  |  ------------------
  ------------------
  937|    577|        }
  938|    249|        else {
  939|    249|	    sz += X_SIZEOF_SIZE_T; /* ndims */
  ------------------
  |  |   89|    249|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|    249|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  940|    249|	    sz += ncx_len_int(varp->ndims); /* dimids */
  ------------------
  |  |  142|    249|	((nelems) * X_SIZEOF_INT)
  |  |  ------------------
  |  |  |  |   65|    249|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  941|    249|	}
  942|    826|	sz += ncx_len_NC_attrarray(&varp->attrs, version);
  943|    826|	sz += X_SIZEOF_NC_TYPE; /* nc_type */
  ------------------
  |  |  176|    826|#define X_SIZEOF_NC_TYPE X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|    826|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  944|    826|	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* vsize */
  ------------------
  |  |   78|    577|#define X_SIZEOF_INT64		8
  ------------------
              	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* vsize */
  ------------------
  |  |   89|    249|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|  1.07k|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  |  Branch (944:8): [True: 577, False: 249]
  ------------------
  945|    826|	sz += sizeof_off_t; /* begin */
  946|       |
  947|    826|	return(sz);
  948|    826|}
v1hpg.c:fault_v1hs:
   86|  5.57k|{
   87|  5.57k|	int status;
   88|       |
   89|  5.57k|	if(gsp->base != NULL)
  ------------------
  |  Branch (89:5): [True: 5.31k, False: 257]
  ------------------
   90|  5.31k|	{
   91|  5.31k|		const ptrdiff_t incr = (char *)gsp->pos - (char *)gsp->base;
   92|  5.31k|		status = rel_v1hs(gsp);
   93|  5.31k|		if(status)
  ------------------
  |  Branch (93:6): [True: 0, False: 5.31k]
  ------------------
   94|      0|			return status;
   95|  5.31k|		gsp->offset += incr;
   96|  5.31k|	}
   97|       |
   98|  5.57k|	if(extent > gsp->extent)
  ------------------
  |  Branch (98:5): [True: 323, False: 5.24k]
  ------------------
   99|    323|		gsp->extent = extent;
  100|       |
  101|  5.57k|	status = ncio_get(gsp->nciop,
  102|  5.57k|		 	gsp->offset, gsp->extent,
  103|  5.57k|			gsp->flags, &gsp->base);
  104|  5.57k|	if(status)
  ------------------
  |  Branch (104:5): [True: 175, False: 5.39k]
  ------------------
  105|    175|		return status;
  106|       |
  107|  5.39k|	gsp->pos = gsp->base;
  108|       |
  109|  5.39k|	gsp->end = (char *)gsp->base + gsp->extent;
  110|  5.39k|    return NC_NOERR;
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  111|  5.57k|}
v1hpg.c:check_v1hs:
  119|  3.54M|{
  120|       |
  121|       |#if 0 /* DEBUG */
  122|       |fprintf(stderr, "nextread %lu, remaining %lu\n",
  123|       |	(unsigned long)nextread,
  124|       |	(unsigned long)((char *)gsp->end - (char *)gsp->pos));
  125|       |#endif
  126|  3.54M|    if((char *)gsp->pos + nextread <= (char *)gsp->end)
  ------------------
  |  Branch (126:8): [True: 3.53M, False: 5.31k]
  ------------------
  127|  3.53M|	return NC_NOERR;
  ------------------
  |  |  417|  3.53M|#define NC_NOERR        0          /**< No Error */
  ------------------
  128|       |
  129|  5.31k|    return fault_v1hs(gsp, nextread);
  130|  3.54M|}
v1hpg.c:rel_v1hs:
   67|  5.57k|{
   68|  5.57k|	int status;
   69|  5.57k|	if(gsp->offset == OFF_NONE || gsp->base == NULL)
  ------------------
  |  |   23|  11.1k|#define OFF_NONE  ((off_t)(-1))
  ------------------
  |  Branch (69:5): [True: 0, False: 5.57k]
  |  Branch (69:32): [True: 175, False: 5.39k]
  ------------------
   70|    175|        return NC_NOERR;
  ------------------
  |  |  417|    175|#define NC_NOERR        0          /**< No Error */
  ------------------
   71|  5.39k|	status = ncio_rel(gsp->nciop, gsp->offset,
   72|  5.39k|			 gsp->flags == RGN_WRITE ? RGN_MODIFIED : 0);
  ------------------
  |  |   35|  5.39k|#define RGN_WRITE	0x4	/* we intend to modify, else read only */
  ------------------
              			 gsp->flags == RGN_WRITE ? RGN_MODIFIED : 0);
  ------------------
  |  |   37|      0|#define RGN_MODIFIED	0x8	/* we did modify, else, discard */
  ------------------
  |  Branch (72:5): [True: 0, False: 5.39k]
  ------------------
   73|  5.39k|	gsp->end = NULL;
   74|  5.39k|	gsp->pos = NULL;
   75|       |	gsp->base = NULL;
   76|  5.39k|	return status;
   77|  5.57k|}
v1hpg.c:v1h_get_NC_dimarray:
  522|    257|{
  523|    257|	int status;
  524|    257|	NCtype type = NC_UNSPECIFIED;
  525|       |
  526|    257|	assert(gsp != NULL && gsp->pos != NULL);
  ------------------
  |  Branch (526:2): [True: 0, False: 257]
  |  Branch (526:2): [True: 0, False: 0]
  |  Branch (526:2): [True: 257, False: 0]
  |  Branch (526:2): [True: 257, False: 0]
  ------------------
  527|    257|	assert(ncap != NULL);
  ------------------
  |  Branch (527:2): [True: 0, False: 257]
  |  Branch (527:2): [True: 257, False: 0]
  ------------------
  528|    257|	assert(ncap->value == NULL);
  ------------------
  |  Branch (528:2): [True: 0, False: 257]
  |  Branch (528:2): [True: 257, False: 0]
  ------------------
  529|       |
  530|    257|	status = v1h_get_NCtype(gsp, &type);
  531|    257|    if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (531:8): [True: 0, False: 257]
  ------------------
  532|      0|		return status;
  533|       |
  534|    257|	status = v1h_get_size_t(gsp, &ncap->nelems);
  535|    257|    if(status != NC_NOERR)
  ------------------
  |  |  417|    257|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (535:8): [True: 0, False: 257]
  ------------------
  536|      0|		return status;
  537|       |
  538|    257|	if(ncap->nelems == 0)
  ------------------
  |  Branch (538:5): [True: 167, False: 90]
  ------------------
  539|    167|        return NC_NOERR;
  ------------------
  |  |  417|    167|#define NC_NOERR        0          /**< No Error */
  ------------------
  540|       |	/* else */
  541|     90|	if(type != NC_DIMENSION)
  ------------------
  |  Branch (541:5): [True: 8, False: 82]
  ------------------
  542|      8|		return EINVAL;
  543|       |
  544|     82|	if (ncap->nelems > SIZE_MAX / sizeof(NC_dim *))
  ------------------
  |  Branch (544:6): [True: 0, False: 82]
  ------------------
  545|      0|		return NC_ERANGE;
  ------------------
  |  |  496|      0|#define NC_ERANGE       (-60)
  ------------------
  546|     82|	ncap->value = (NC_dim **) calloc(1,ncap->nelems * sizeof(NC_dim *));
  547|     82|	if(ncap->value == NULL)
  ------------------
  |  Branch (547:5): [True: 0, False: 82]
  ------------------
  548|      0|		return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  549|     82|	ncap->nalloc = ncap->nelems;
  550|       |
  551|     82|	ncap->hashmap = NC_hashmapnew(ncap->nelems);
  552|       |
  553|     82|	{
  554|     82|		NC_dim **dpp = ncap->value;
  555|     82|		NC_dim *const *const end = &dpp[ncap->nelems];
  556|   432k|		for( /*NADA*/; dpp < end; dpp++)
  ------------------
  |  Branch (556:18): [True: 432k, False: 12]
  ------------------
  557|   432k|		{
  558|   432k|			status = v1h_get_NC_dim(gsp, dpp);
  559|   432k|			if(status)
  ------------------
  |  Branch (559:7): [True: 70, False: 432k]
  ------------------
  560|     70|			{
  561|     70|				ncap->nelems = (size_t)(dpp - ncap->value);
  562|     70|				free_NC_dimarrayV(ncap);
  563|     70|				return status;
  564|     70|			}
  565|   432k|			{
  566|   432k|			  uintptr_t dimid = (uintptr_t)(dpp - ncap->value);
  567|   432k|			  NC_hashmapadd(ncap->hashmap, dimid, (*dpp)->name->cp, strlen((*dpp)->name->cp));
  568|   432k|			}
  569|   432k|		}
  570|     82|	}
  571|       |
  572|     12|    return NC_NOERR;
  ------------------
  |  |  417|     12|#define NC_NOERR        0          /**< No Error */
  ------------------
  573|     82|}
v1hpg.c:v1h_get_NCtype:
  241|   153k|{
  242|   153k|    unsigned int type = 0;
  243|   153k|    int status = check_v1hs(gsp, X_SIZEOF_INT);
  ------------------
  |  |   65|   153k|#define X_SIZEOF_INT		4	/* xdr_int */
  ------------------
  244|   153k|    if(status != NC_NOERR) return status;
  ------------------
  |  |  417|   153k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (244:8): [True: 7, False: 153k]
  ------------------
  245|   153k|    status =  ncx_get_uint32((const void**)(&gsp->pos), &type);
  246|   153k|    if(status != NC_NOERR) return status;
  ------------------
  |  |  417|   153k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (246:8): [True: 0, False: 153k]
  ------------------
  247|       |    /* else */
  248|   153k|    *typep = (NCtype) type;
  249|   153k|    return NC_NOERR;
  ------------------
  |  |  417|   153k|#define NC_NOERR        0          /**< No Error */
  ------------------
  250|   153k|}
v1hpg.c:v1h_get_size_t:
  156|  1.82M|{
  157|  1.82M|	int status;
  158|  1.82M|	if (gsp->version == 5) /* all integers in CDF-5 are 64 bits */
  ------------------
  |  Branch (158:6): [True: 235k, False: 1.58M]
  ------------------
  159|   235k|		status = check_v1hs(gsp, X_SIZEOF_INT64);
  ------------------
  |  |   78|   235k|#define X_SIZEOF_INT64		8
  ------------------
  160|  1.58M|	else
  161|  1.58M|		status = check_v1hs(gsp, X_SIZEOF_SIZE_T);
  ------------------
  |  |   89|  1.58M|#define X_SIZEOF_SIZE_T		X_SIZEOF_INT
  |  |  ------------------
  |  |  |  |   65|  1.58M|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
  162|  1.82M|	if(status != NC_NOERR)
  ------------------
  |  |  417|  1.82M|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (162:5): [True: 67, False: 1.82M]
  ------------------
  163|     67|		return status;
  164|  1.82M|        if (gsp->version == 5) {
  ------------------
  |  Branch (164:13): [True: 234k, False: 1.58M]
  ------------------
  165|   234k|		unsigned long long tmp=0;
  166|   234k|		status = ncx_get_uint64((const void **)(&gsp->pos), &tmp);
  167|   234k|		*sp = (size_t)tmp;
  168|   234k|		return status;
  169|   234k|        }
  170|  1.58M|        else
  171|  1.58M|	    return ncx_get_size_t((const void **)(&gsp->pos), sp);
  172|  1.82M|}
v1hpg.c:v1h_get_NC_dim:
  407|   432k|{
  408|   432k|	int status;
  409|   432k|	NC_string *ncstrp;
  410|   432k|	NC_dim *dimp;
  411|       |
  412|   432k|	status = v1h_get_NC_string(gsp, &ncstrp);
  413|   432k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   432k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (413:8): [True: 54, False: 432k]
  ------------------
  414|     54|		return status;
  415|       |
  416|   432k|	dimp = new_x_NC_dim(ncstrp);
  417|   432k|	if(dimp == NULL)
  ------------------
  |  Branch (417:5): [True: 0, False: 432k]
  ------------------
  418|      0|	{
  419|      0|		status = NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  420|      0|		goto unwind_name;
  421|      0|	}
  422|       |
  423|   432k|	status = v1h_get_size_t(gsp, &dimp->size);
  424|   432k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   432k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (424:8): [True: 16, False: 432k]
  ------------------
  425|     16|	{
  426|     16|		free_NC_dim(dimp); /* frees name */
  427|     16|		return status;
  428|     16|	}
  429|       |
  430|   432k|	*dimpp = dimp;
  431|       |
  432|   432k|    return NC_NOERR;
  ------------------
  |  |  417|   432k|#define NC_NOERR        0          /**< No Error */
  ------------------
  433|       |
  434|      0|unwind_name:
  435|      0|	free_NC_string(ncstrp);
  436|      0|	return status;
  437|   432k|}
v1hpg.c:v1h_get_NC_string:
  307|   759k|{
  308|   759k|	int status = 0;
  309|   759k|	size_t nchars = 0;
  310|   759k|	NC_string *ncstrp = NULL;
  311|       |#if USE_STRICT_NULL_BYTE_HEADER_PADDING
  312|       |        size_t padding = 0;        
  313|       |#endif /* USE_STRICT_NULL_BYTE_HEADER_PADDING */
  314|       |
  315|   759k|	status = v1h_get_size_t(gsp, &nchars);
  316|   759k|	if(status != NC_NOERR)
  ------------------
  |  |  417|   759k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (316:5): [True: 21, False: 759k]
  ------------------
  317|     21|		return status;
  318|       |
  319|   759k|	ncstrp = new_NC_string(nchars, NULL);
  320|   759k|	if(ncstrp == NULL)
  ------------------
  |  Branch (320:5): [True: 9, False: 759k]
  ------------------
  321|      9|	{
  322|      9|		return NC_ENOMEM;
  ------------------
  |  |  497|      9|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  323|      9|	}
  324|       |
  325|       |#if 0
  326|       |/* assert(ncstrp->nchars == nchars || ncstrp->nchars - nchars < X_ALIGN); */
  327|       |	assert(ncstrp->nchars % X_ALIGN == 0);
  328|       |	status = check_v1hs(gsp, ncstrp->nchars);
  329|       |#else
  330|       |
  331|   759k|	status = check_v1hs(gsp, _RNDUP(ncstrp->nchars, X_ALIGN));
  ------------------
  |  |   14|   759k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |   15|   759k|	* (unit))
  ------------------
  332|   759k|#endif
  333|   759k|	if(status != NC_NOERR)
  ------------------
  |  |  417|   759k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (333:5): [True: 43, False: 759k]
  ------------------
  334|     43|		goto unwind_alloc;
  335|       |
  336|   759k|	status = ncx_pad_getn_text((const void **)(&gsp->pos),
  337|   759k|		 nchars, ncstrp->cp);
  338|   759k|	if(status != NC_NOERR)
  ------------------
  |  |  417|   759k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (338:5): [True: 0, False: 759k]
  ------------------
  339|      0|		goto unwind_alloc;
  340|       |
  341|       |#if USE_STRICT_NULL_BYTE_HEADER_PADDING
  342|       |	padding = _RNDUP(X_SIZEOF_CHAR * ncstrp->nchars, X_ALIGN)
  343|       |		- X_SIZEOF_CHAR * ncstrp->nchars;
  344|       |
  345|       |	if (padding > 0) {
  346|       |		/* CDF specification: Header padding uses null (\x00) bytes. */
  347|       |		char pad[X_ALIGN-1];
  348|       |		memset(pad, 0, X_ALIGN-1);
  349|       |		if (memcmp((char*)gsp->pos-padding, pad, padding) != 0) {
  350|       |			free_NC_string(ncstrp);
  351|       |			return NC_ENULLPAD;
  352|       |		}
  353|       |	}
  354|       |#endif
  355|       |
  356|   759k|	*ncstrpp = ncstrp;
  357|       |
  358|   759k|	return NC_NOERR;
  ------------------
  |  |  417|   759k|#define NC_NOERR        0          /**< No Error */
  ------------------
  359|       |
  360|     43|unwind_alloc:
  361|     43|	free_NC_string(ncstrp);
  362|     43|	return status;
  363|   759k|}
v1hpg.c:v1h_get_NC_attrarray:
  873|   152k|{
  874|   152k|	int status;
  875|   152k|	NCtype type = NC_UNSPECIFIED;
  876|       |
  877|   152k|	assert(gsp != NULL && gsp->pos != NULL);
  ------------------
  |  Branch (877:2): [True: 0, False: 152k]
  |  Branch (877:2): [True: 0, False: 0]
  |  Branch (877:2): [True: 152k, False: 0]
  |  Branch (877:2): [True: 152k, False: 0]
  ------------------
  878|   152k|	assert(ncap != NULL);
  ------------------
  |  Branch (878:2): [True: 0, False: 152k]
  |  Branch (878:2): [True: 152k, False: 0]
  ------------------
  879|   152k|	assert(ncap->value == NULL);
  ------------------
  |  Branch (879:2): [True: 0, False: 152k]
  |  Branch (879:2): [True: 152k, False: 0]
  ------------------
  880|       |
  881|   152k|	status = v1h_get_NCtype(gsp, &type);
  882|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (882:8): [True: 7, False: 152k]
  ------------------
  883|      7|		return status;
  884|   152k|	status = v1h_get_size_t(gsp, &ncap->nelems);
  885|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (885:8): [True: 5, False: 152k]
  ------------------
  886|      5|		return status;
  887|       |
  888|   152k|	if(ncap->nelems == 0)
  ------------------
  |  Branch (888:5): [True: 152k, False: 224]
  ------------------
  889|   152k|        return NC_NOERR;
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  890|       |	/* else */
  891|    224|	if(type != NC_ATTRIBUTE)
  ------------------
  |  Branch (891:5): [True: 10, False: 214]
  ------------------
  892|     10|		return EINVAL;
  893|       |
  894|    214|	ncap->value = (NC_attr **) malloc(ncap->nelems * sizeof(NC_attr *));
  895|    214|	if(ncap->value == NULL)
  ------------------
  |  Branch (895:5): [True: 0, False: 214]
  ------------------
  896|      0|		return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  897|    214|	ncap->nalloc = ncap->nelems;
  898|       |
  899|    214|	{
  900|    214|		NC_attr **app = ncap->value;
  901|    214|		NC_attr *const *const end = &app[ncap->nelems];
  902|   174k|		for( /*NADA*/; app < end; app++)
  ------------------
  |  Branch (902:18): [True: 173k, False: 131]
  ------------------
  903|   173k|		{
  904|   173k|			status = v1h_get_NC_attr(gsp, app);
  905|   173k|			if(status)
  ------------------
  |  Branch (905:7): [True: 83, False: 173k]
  ------------------
  906|     83|			{
  907|     83|				ncap->nelems = (size_t)(app - ncap->value);
  908|     83|				free_NC_attrarrayV(ncap);
  909|     83|				return status;
  910|     83|			}
  911|   173k|		}
  912|    214|	}
  913|       |
  914|    131|    return NC_NOERR;
  ------------------
  |  |  417|    131|#define NC_NOERR        0          /**< No Error */
  ------------------
  915|    214|}
v1hpg.c:v1h_get_NC_attr:
  748|   173k|{
  749|   173k|	NC_string *strp;
  750|   173k|	int status;
  751|   173k|	nc_type type;
  752|   173k|	size_t nelems;
  753|   173k|	NC_attr *attrp;
  754|       |
  755|   173k|	status = v1h_get_NC_string(gsp, &strp);
  756|   173k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (756:8): [True: 11, False: 173k]
  ------------------
  757|     11|		return status;
  758|       |
  759|   173k|	status = v1h_get_nc_type(gsp, &type);
  760|   173k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (760:8): [True: 25, False: 173k]
  ------------------
  761|     25|		goto unwind_name;
  762|       |
  763|   173k|	status = v1h_get_size_t(gsp, &nelems);
  764|   173k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (764:8): [True: 7, False: 173k]
  ------------------
  765|      7|		goto unwind_name;
  766|       |
  767|   173k|	attrp = new_x_NC_attr(strp, type, nelems);
  768|   173k|	if(attrp == NULL)
  ------------------
  |  Branch (768:5): [True: 6, False: 173k]
  ------------------
  769|      6|	{
  770|      6|		status = NC_ENOMEM;
  ------------------
  |  |  497|      6|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
  771|      6|		goto unwind_name;
  772|      6|	}
  773|       |
  774|   173k|	status = v1h_get_NC_attrV(gsp, attrp);
  775|   173k|        if(status != NC_NOERR)
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (775:12): [True: 34, False: 173k]
  ------------------
  776|     34|	{
  777|     34|		free_NC_attr(attrp); /* frees strp */
  778|     34|		return status;
  779|     34|	}
  780|       |
  781|   173k|	*attrpp = attrp;
  782|       |
  783|   173k|    return NC_NOERR;
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  784|       |
  785|     38|unwind_name:
  786|     38|	free_NC_string(strp);
  787|     38|	return status;
  788|   173k|}
v1hpg.c:v1h_get_nc_type:
  193|   326k|{
  194|   326k|    unsigned int type = 0;
  195|   326k|    int status = check_v1hs(gsp, X_SIZEOF_INT);
  ------------------
  |  |   65|   326k|#define X_SIZEOF_INT		4	/* xdr_int */
  ------------------
  196|   326k|    if(status != NC_NOERR) return status;
  ------------------
  |  |  417|   326k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (196:8): [True: 12, False: 326k]
  ------------------
  197|   326k|    status =  ncx_get_uint32((const void**)(&gsp->pos), &type);
  198|   326k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   326k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (198:8): [True: 0, False: 326k]
  ------------------
  199|      0|		return status;
  200|       |/* Fix 35382
  201|       |	assert(type == NC_BYTE
  202|       |		|| type == NC_CHAR
  203|       |		|| type == NC_SHORT
  204|       |		|| type == NC_INT
  205|       |		|| type == NC_FLOAT
  206|       |		|| type == NC_DOUBLE
  207|       |		|| type == NC_UBYTE
  208|       |		|| type == NC_USHORT
  209|       |		|| type == NC_UINT
  210|       |		|| type == NC_INT64
  211|       |		|| type == NC_UINT64
  212|       |		|| type == NC_STRING);
  213|       |*/
  214|   326k|    if(type == NC_NAT || type > NC_MAX_ATOMIC_TYPE)
  ------------------
  |  |   34|   653k|#define NC_NAT          0       /**< Not A Type */
  ------------------
                  if(type == NC_NAT || type > NC_MAX_ATOMIC_TYPE)
  ------------------
  |  |   49|   326k|#define NC_MAX_ATOMIC_TYPE NC_STRING /**< @internal Largest atomic type. */
  |  |  ------------------
  |  |  |  |   47|   326k|#define NC_STRING       12      /**< string */
  |  |  ------------------
  ------------------
  |  Branch (214:8): [True: 10, False: 326k]
  |  Branch (214:26): [True: 12, False: 326k]
  ------------------
  215|     22|        return NC_EINVAL;
  ------------------
  |  |  427|     22|#define	NC_EINVAL	(-36)	   /**< Invalid Argument */
  ------------------
  216|   326k|    else
  217|   326k|	*typep = (nc_type) type;
  218|       |
  219|   326k|    return NC_NOERR;
  ------------------
  |  |  417|   326k|#define NC_NOERR        0          /**< No Error */
  ------------------
  220|   326k|}
v1hpg.c:v1h_get_NC_attrV:
  702|   173k|{
  703|   173k|	int status;
  704|   173k|	const size_t perchunk =  gsp->extent;
  705|   173k|	size_t remaining = attrp->xsz;
  706|   173k|	void *value = attrp->xvalue;
  707|   173k|	size_t nget;
  708|       |#if USE_STRICT_NULL_BYTE_HEADER_PADDING
  709|       |	size_t padding;
  710|       |#endif /* USE_STRICT_NULL_BYTE_HEADER_PADDING */
  711|       |
  712|   175k|	do {
  713|   175k|		nget = MIN(perchunk, remaining);
  ------------------
  |  |  602|   175k|#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
  |  |  ------------------
  |  |  |  Branch (602:21): [True: 1.36k, False: 173k]
  |  |  ------------------
  ------------------
  714|       |
  715|   175k|		status = check_v1hs(gsp, nget);
  716|   175k|		if(status != NC_NOERR)
  ------------------
  |  |  417|   175k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (716:6): [True: 34, False: 175k]
  ------------------
  717|     34|			return status;
  718|       |
  719|   175k|		if (value) {
  ------------------
  |  Branch (719:7): [True: 3.49k, False: 171k]
  ------------------
  720|  3.49k|			(void) memcpy(value, gsp->pos, nget);
  721|  3.49k|			value = (void *)((signed char *)value + nget);
  722|  3.49k|		}
  723|       |		
  724|   175k|		gsp->pos = (void*)((unsigned char *)gsp->pos + nget);
  725|       |
  726|   175k|		remaining -= nget;
  727|       |
  728|   175k|	} while(remaining != 0);
  ------------------
  |  Branch (728:10): [True: 1.33k, False: 173k]
  ------------------
  729|       |
  730|       |#if USE_STRICT_NULL_BYTE_HEADER_PADDING
  731|       |	padding = attrp->xsz - ncmpix_len_nctype(attrp->type) * attrp->nelems;
  732|       |	if (padding > 0) {
  733|       |		/* CDF specification: Header padding uses null (\x00) bytes. */
  734|       |		char pad[X_ALIGN-1];
  735|       |		memset(pad, 0, X_ALIGN-1);
  736|       |		if (memcmp((char*)gsp->pos-padding, pad, (size_t)padding) != 0)
  737|       |			return NC_ENULLPAD;
  738|       |	}
  739|       |#endif
  740|       |
  741|   173k|	return NC_NOERR;
  ------------------
  |  |  417|   173k|#define NC_NOERR        0          /**< No Error */
  ------------------
  742|   173k|}
v1hpg.c:v1h_get_NC_vararray:
 1176|     93|{
 1177|     93|	int status;
 1178|     93|	NCtype type = NC_UNSPECIFIED;
 1179|       |
 1180|     93|	assert(gsp != NULL && gsp->pos != NULL);
  ------------------
  |  Branch (1180:2): [True: 0, False: 93]
  |  Branch (1180:2): [True: 0, False: 0]
  |  Branch (1180:2): [True: 93, False: 0]
  |  Branch (1180:2): [True: 93, False: 0]
  ------------------
 1181|     93|	assert(ncap != NULL);
  ------------------
  |  Branch (1181:2): [True: 0, False: 93]
  |  Branch (1181:2): [True: 93, False: 0]
  ------------------
 1182|     93|	assert(ncap->value == NULL);
  ------------------
  |  Branch (1182:2): [True: 0, False: 93]
  |  Branch (1182:2): [True: 93, False: 0]
  ------------------
 1183|       |
 1184|     93|	status = v1h_get_NCtype(gsp, &type);
 1185|     93|    if(status != NC_NOERR)
  ------------------
  |  |  417|     93|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1185:8): [True: 0, False: 93]
  ------------------
 1186|      0|		return status;
 1187|       |
 1188|     93|	status = v1h_get_size_t(gsp, &ncap->nelems);
 1189|     93|    if(status != NC_NOERR)
  ------------------
  |  |  417|     93|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1189:8): [True: 0, False: 93]
  ------------------
 1190|      0|		return status;
 1191|       |
 1192|     93|	if(ncap->nelems == 0)
  ------------------
  |  Branch (1192:5): [True: 15, False: 78]
  ------------------
 1193|     15|        return NC_NOERR;
  ------------------
  |  |  417|     15|#define NC_NOERR        0          /**< No Error */
  ------------------
 1194|       |	/* else */
 1195|     78|	if(type != NC_VARIABLE)
  ------------------
  |  Branch (1195:5): [True: 1, False: 77]
  ------------------
 1196|      1|		return EINVAL;
 1197|       |	
 1198|     77|	if (ncap->nelems > SIZE_MAX / sizeof(NC_var *))
  ------------------
  |  Branch (1198:6): [True: 3, False: 74]
  ------------------
 1199|      3|		return NC_ERANGE;
  ------------------
  |  |  496|      3|#define NC_ERANGE       (-60)
  ------------------
 1200|     74|	ncap->value = (NC_var **) calloc(1,ncap->nelems * sizeof(NC_var *));
 1201|     74|	if(ncap->value == NULL)
  ------------------
  |  Branch (1201:5): [True: 0, False: 74]
  ------------------
 1202|      0|		return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
 1203|     74|	ncap->nalloc = ncap->nelems;
 1204|       |
 1205|     74|	ncap->hashmap = NC_hashmapnew(ncap->nelems);
 1206|     74|	if (ncap->hashmap == NULL)
  ------------------
  |  Branch (1206:6): [True: 0, False: 74]
  ------------------
 1207|      0|		return NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
 1208|     74|	{
 1209|     74|		NC_var **vpp = ncap->value;
 1210|     74|		NC_var *const *const end = &vpp[ncap->nelems];
 1211|   152k|		for( /*NADA*/; vpp < end; vpp++)
  ------------------
  |  Branch (1211:18): [True: 152k, False: 8]
  ------------------
 1212|   152k|		{
 1213|   152k|			status = v1h_get_NC_var(gsp, vpp);
 1214|   152k|			if(status)
  ------------------
  |  Branch (1214:7): [True: 66, False: 152k]
  ------------------
 1215|     66|			{
 1216|     66|				ncap->nelems = (size_t)(vpp - ncap->value);
 1217|     66|				free_NC_vararrayV(ncap);
 1218|     66|				return status;
 1219|     66|			}
 1220|   152k|			{
 1221|   152k|			  uintptr_t varid = (uintptr_t)(vpp - ncap->value);
 1222|   152k|			  NC_hashmapadd(ncap->hashmap, varid, (*vpp)->name->cp, strlen((*vpp)->name->cp));
 1223|   152k|			}
 1224|   152k|		}
 1225|     74|	}
 1226|       |
 1227|      8|    return NC_NOERR;
  ------------------
  |  |  417|      8|#define NC_NOERR        0          /**< No Error */
  ------------------
 1228|     74|}
v1hpg.c:v1h_get_NC_var:
 1021|   152k|{
 1022|   152k|	NC_string *strp;
 1023|   152k|	int status;
 1024|   152k|	size_t ndims;
 1025|   152k|	NC_var *varp;
 1026|       |
 1027|   152k|	status = v1h_get_NC_string(gsp, &strp);
 1028|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1028:8): [True: 8, False: 152k]
  ------------------
 1029|      8|		return status;
 1030|       |
 1031|   152k|	status = v1h_get_size_t(gsp, &ndims);
 1032|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1032:8): [True: 10, False: 152k]
  ------------------
 1033|     10|		goto unwind_name;
 1034|       |
 1035|   152k|	varp = new_x_NC_var(strp, ndims);
 1036|   152k|	if(varp == NULL)
  ------------------
  |  Branch (1036:5): [True: 0, False: 152k]
  ------------------
 1037|      0|	{
 1038|      0|		status = NC_ENOMEM;
  ------------------
  |  |  497|      0|#define NC_ENOMEM       (-61)      /**< Memory allocation (malloc) failure */
  ------------------
 1039|      0|		goto unwind_name;
 1040|      0|	}
 1041|       |
 1042|   152k|	if (gsp->version == 5) {
  ------------------
  |  Branch (1042:6): [True: 5.39k, False: 147k]
  ------------------
 1043|  5.39k|		status = check_v1hs(gsp, ncx_len_int64(ndims));
  ------------------
  |  |  163|  5.39k|	((nelems) * X_SIZEOF_INT64)
  |  |  ------------------
  |  |  |  |   78|  5.39k|#define X_SIZEOF_INT64		8
  |  |  ------------------
  ------------------
 1044|  5.39k|        if(status != NC_NOERR)
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1044:12): [True: 0, False: 5.39k]
  ------------------
 1045|      0|			goto unwind_alloc;
 1046|  5.39k|		status = ncx_getn_longlong_int((const void **)(&gsp->pos),
 1047|  5.39k|				ndims, varp->dimids);
 1048|  5.39k|        if(status != NC_NOERR)
  ------------------
  |  |  417|  5.39k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1048:12): [True: 0, False: 5.39k]
  ------------------
 1049|      0|			goto unwind_alloc;
 1050|  5.39k|	}
 1051|   147k|	else {
 1052|   147k|	    status = check_v1hs(gsp, ncx_len_int(ndims));
  ------------------
  |  |  142|   147k|	((nelems) * X_SIZEOF_INT)
  |  |  ------------------
  |  |  |  |   65|   147k|#define X_SIZEOF_INT		4	/* xdr_int */
  |  |  ------------------
  ------------------
 1053|   147k|        if(status != NC_NOERR)
  ------------------
  |  |  417|   147k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1053:12): [True: 6, False: 147k]
  ------------------
 1054|      6|		goto unwind_alloc;
 1055|   147k|	    status = ncx_getn_int_int((const void **)(&gsp->pos),
 1056|   147k|			ndims, varp->dimids);
 1057|   147k|        if(status != NC_NOERR)
  ------------------
  |  |  417|   147k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1057:12): [True: 0, False: 147k]
  ------------------
 1058|      0|		goto unwind_alloc;
 1059|   147k|	}
 1060|   152k|	status = v1h_get_NC_attrarray(gsp, &varp->attrs);
 1061|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1061:8): [True: 19, False: 152k]
  ------------------
 1062|     19|		goto unwind_alloc;
 1063|   152k|	status = v1h_get_nc_type(gsp, &varp->type);
 1064|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1064:8): [True: 9, False: 152k]
  ------------------
 1065|      9|		 goto unwind_alloc;
 1066|       |
 1067|   152k|    size_t tmp;
 1068|   152k|    status = v1h_get_size_t(gsp, &tmp);
 1069|   152k|    varp->len = tmp;
 1070|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1070:8): [True: 8, False: 152k]
  ------------------
 1071|      8|		 goto unwind_alloc;
 1072|       |
 1073|   152k|	status = check_v1hs(gsp, gsp->version == 1 ? 4 : 8);
  ------------------
  |  Branch (1073:27): [True: 373, False: 152k]
  ------------------
 1074|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1074:8): [True: 6, False: 152k]
  ------------------
 1075|      6|		 goto unwind_alloc;
 1076|   152k|	status = ncx_get_off_t((const void **)&gsp->pos,
 1077|   152k|			       &varp->begin, gsp->version == 1 ? 4 : 8);
  ------------------
  |  Branch (1077:25): [True: 373, False: 152k]
  ------------------
 1078|   152k|    if(status != NC_NOERR)
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1078:8): [True: 0, False: 152k]
  ------------------
 1079|      0|		 goto unwind_alloc;
 1080|       |
 1081|   152k|	*varpp = varp;
 1082|   152k|    return NC_NOERR;
  ------------------
  |  |  417|   152k|#define NC_NOERR        0          /**< No Error */
  ------------------
 1083|       |
 1084|     48|unwind_alloc:
 1085|     48|	free_NC_var(varp); /* frees name */
 1086|     48|	return status;
 1087|       |
 1088|     10|unwind_name:
 1089|     10|	free_NC_string(strp);
 1090|     10|	return status;
 1091|   152k|}
v1hpg.c:NC_computeshapes:
 1244|     23|{
 1245|     23|	NC_var **vpp = (NC_var **)ncp->vars.value;
 1246|     23|	NC_var *first_var = NULL;	/* first "non-record" var */
 1247|     23|	NC_var *first_rec = NULL;	/* first "record" var */
 1248|     23|	int status;
 1249|       |
 1250|     23|	ncp->begin_var = (off_t) ncp->xsz;
 1251|     23|	ncp->begin_rec = (off_t) ncp->xsz;
 1252|     23|	ncp->recsize = 0;
 1253|       |
 1254|     23|	if(ncp->vars.nelems == 0)
  ------------------
  |  Branch (1254:5): [True: 15, False: 8]
  ------------------
 1255|     15|		return(0);
 1256|       |
 1257|      8|	if (vpp)
  ------------------
  |  Branch (1257:6): [True: 8, False: 0]
  ------------------
 1258|      8|	{
 1259|      8|		NC_var *const *const end = &vpp[ncp->vars.nelems];
 1260|    745|		for( /*NADA*/; vpp < end; vpp++)
  ------------------
  |  Branch (1260:18): [True: 738, False: 7]
  ------------------
 1261|    738|		{
 1262|    738|			status = NC_var_shape(*vpp, &ncp->dims);
 1263|    738|		        if(status != NC_NOERR)
  ------------------
  |  |  417|    738|#define NC_NOERR        0          /**< No Error */
  ------------------
  |  Branch (1263:14): [True: 1, False: 737]
  ------------------
 1264|      1|				return(status);
 1265|       |
 1266|    737|		  	if(IS_RECVAR(*vpp))
  ------------------
  |  |  221|    737|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      3|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:5): [True: 3, False: 734]
  |  |  |  Branch (221:6): [True: 3, False: 734]
  |  |  ------------------
  ------------------
 1267|      3|			{
 1268|      3|		  		if(first_rec == NULL)
  ------------------
  |  Branch (1268:10): [True: 2, False: 1]
  ------------------
 1269|      2|					first_rec = *vpp;
 1270|      3|				ncp->recsize += (*vpp)->len;
 1271|      3|			}
 1272|    734|			else
 1273|    734|			{
 1274|    734|		            if(first_var == NULL)
  ------------------
  |  Branch (1274:18): [True: 7, False: 727]
  ------------------
 1275|      7|			        first_var = *vpp;
 1276|       |			    /*
 1277|       |			     * Overwritten each time thru.
 1278|       |			     * Usually overwritten in first_rec != NULL clause below.
 1279|       |			     */
 1280|    734|			    ncp->begin_rec = (*vpp)->begin + (off_t)(*vpp)->len;
 1281|    734|			}
 1282|    737|		}
 1283|      8|	}
 1284|       |
 1285|      7|	if(first_rec != NULL)
  ------------------
  |  Branch (1285:5): [True: 2, False: 5]
  ------------------
 1286|      2|	{
 1287|      2|		if(ncp->begin_rec > first_rec->begin)
  ------------------
  |  Branch (1287:6): [True: 1, False: 1]
  ------------------
 1288|      1|		    return(NC_ENOTNC); /* not a netCDF file or corrupted */
  ------------------
  |  |  473|      1|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1289|      1|		ncp->begin_rec = first_rec->begin;
 1290|       |		/*
 1291|       |	 	 * for special case of exactly one record variable, pack value
 1292|       |	 	 */
 1293|      1|		if(ncp->recsize == first_rec->len)
  ------------------
  |  Branch (1293:6): [True: 0, False: 1]
  ------------------
 1294|      0|			ncp->recsize = *first_rec->dsizes * first_rec->xsz;
 1295|      1|	}
 1296|       |
 1297|      6|	if(first_var != NULL)
  ------------------
  |  Branch (1297:5): [True: 5, False: 1]
  ------------------
 1298|      5|	{
 1299|      5|		ncp->begin_var = first_var->begin;
 1300|      5|	}
 1301|      1|	else
 1302|      1|	{
 1303|      1|		ncp->begin_var = ncp->begin_rec;
 1304|      1|	}
 1305|       |
 1306|      6|	if(ncp->begin_var <= 0 ||
  ------------------
  |  Branch (1306:5): [True: 1, False: 5]
  ------------------
 1307|      5|	   ncp->xsz > (size_t)ncp->begin_var ||
  ------------------
  |  Branch (1307:5): [True: 1, False: 4]
  ------------------
 1308|      4|	   ncp->begin_rec <= 0 ||
  ------------------
  |  Branch (1308:5): [True: 0, False: 4]
  ------------------
 1309|      4|	   ncp->begin_var > ncp->begin_rec)
  ------------------
  |  Branch (1309:5): [True: 1, False: 3]
  ------------------
 1310|      3|	    return(NC_ENOTNC); /* not a netCDF file or corrupted */
  ------------------
  |  |  473|      3|#define NC_ENOTNC	(-51)	   /**< Not a netcdf file */
  ------------------
 1311|       |
 1312|      3|    return(NC_NOERR);
  ------------------
  |  |  417|      3|#define NC_NOERR        0          /**< No Error */
  ------------------
 1313|      6|}

free_NC_var:
   51|   152k|{
   52|   152k|	if(varp == NULL)
  ------------------
  |  Branch (52:5): [True: 0, False: 152k]
  ------------------
   53|      0|		return;
   54|   152k|	free_NC_attrarrayV(&varp->attrs);
   55|   152k|	free_NC_string(varp->name);
   56|   152k|#ifndef MALLOCHACK
   57|   152k|	if(varp->dimids != NULL) free(varp->dimids);
  ------------------
  |  Branch (57:5): [True: 2.12k, False: 150k]
  ------------------
   58|   152k|	if(varp->shape != NULL) free(varp->shape);
  ------------------
  |  Branch (58:5): [True: 2.12k, False: 150k]
  ------------------
   59|   152k|	if(varp->dsizes != NULL) free(varp->dsizes);
  ------------------
  |  Branch (59:5): [True: 2.12k, False: 150k]
  ------------------
   60|   152k|#endif /*!MALLOCHACK*/
   61|   152k|	free(varp);
   62|   152k|}
new_x_NC_var:
   73|   152k|{
   74|   152k|	NC_var *varp;
   75|       |
   76|   152k|	if (ndims > SIZE_MAX / sizeof(int))
  ------------------
  |  Branch (76:6): [True: 0, False: 152k]
  ------------------
   77|      0|		return NULL;
   78|   152k|	const size_t o1 = M_RNDUP(ndims * sizeof(int));
  ------------------
  |  |   19|   152k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   152k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   152k|	* (unit))
  |  |  ------------------
  ------------------
   79|       |
   80|   152k|	if (ndims > SIZE_MAX / sizeof(size_t))
  ------------------
  |  Branch (80:6): [True: 0, False: 152k]
  ------------------
   81|      0|		return NULL;
   82|   152k|	const size_t o2 = M_RNDUP(ndims * sizeof(size_t));
  ------------------
  |  |   19|   152k|#define	M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
  |  |  ------------------
  |  |  |  |   14|   152k|#define	_RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) \
  |  |  |  |   15|   152k|	* (unit))
  |  |  ------------------
  ------------------
   83|       |
   84|       |#ifdef MALLOCHACK
   85|       |	const size_t sz =  M_RNDUP(sizeof(NC_var)) +
   86|       |		 o1 + o2 + ndims * sizeof(off_t);
   87|       |#else /*!MALLOCHACK*/
   88|   152k|	if (ndims > SIZE_MAX / sizeof(off_t))
  ------------------
  |  Branch (88:6): [True: 0, False: 152k]
  ------------------
   89|      0|		return NULL;
   90|   152k|	const size_t o3 = ndims * sizeof(off_t);
   91|   152k|	const size_t sz = sizeof(NC_var);
   92|   152k|#endif /*!MALLOCHACK*/
   93|       |
   94|   152k|	varp = (NC_var *) malloc(sz);
   95|   152k|	if(varp == NULL )
  ------------------
  |  Branch (95:5): [True: 0, False: 152k]
  ------------------
   96|      0|		return NULL;
   97|   152k|	(void) memset(varp, 0, sz);
   98|   152k|	varp->name = strp;
   99|   152k|	varp->ndims = ndims;
  100|       |
  101|   152k|	if(ndims != 0)
  ------------------
  |  Branch (101:5): [True: 2.12k, False: 150k]
  ------------------
  102|  2.12k|	{
  103|       |#ifdef MALLOCHACK
  104|       |	  /*
  105|       |	   * NOTE: lint may complain about the next 3 lines:
  106|       |	   * "pointer cast may result in improper alignment".
  107|       |	   * We use the M_RNDUP() macro to get the proper alignment.
  108|       |	   */
  109|       |	  varp->dimids = (int *)((char *)varp + M_RNDUP(sizeof(NC_var)));
  110|       |	  varp->shape = (size_t *)((char *)varp->dimids + o1);
  111|       |	  varp->dsizes = (off_t *)((char *)varp->shape + o2);
  112|       |#else /*!MALLOCHACK*/
  113|  2.12k|	  varp->dimids = (int*)malloc(o1);
  114|  2.12k|	  varp->shape = (size_t*)malloc(o2);
  115|  2.12k|	  varp->dsizes = (off_t*)malloc(o3);
  116|  2.12k|#endif /*!MALLOCHACK*/
  117|   150k|	} else {
  118|   150k|	  varp->dimids = NULL;
  119|   150k|	  varp->shape = NULL;
  120|   150k|	  varp->dsizes=NULL;
  121|   150k|	}
  122|       |
  123|       |
  124|   152k|	varp->xsz = 0;
  125|   152k|	varp->len = 0;
  126|   152k|	varp->begin = 0;
  127|       |
  128|   152k|	return varp;
  129|   152k|}
free_NC_vararrayV0:
  210|     74|{
  211|     74|	assert(ncap != NULL);
  ------------------
  |  Branch (211:2): [True: 0, False: 74]
  |  Branch (211:2): [True: 74, False: 0]
  ------------------
  212|       |
  213|     74|	if(ncap->nelems == 0)
  ------------------
  |  Branch (213:5): [True: 0, False: 74]
  ------------------
  214|      0|		return;
  215|       |
  216|     74|	assert(ncap->value != NULL);
  ------------------
  |  Branch (216:2): [True: 0, False: 74]
  |  Branch (216:2): [True: 74, False: 0]
  ------------------
  217|       |
  218|     74|	{
  219|     74|		NC_var **vpp = ncap->value;
  220|     74|		NC_var *const *const end = &vpp[ncap->nelems];
  221|   152k|		for( /*NADA*/; vpp < end; vpp++)
  ------------------
  |  Branch (221:18): [True: 152k, False: 74]
  ------------------
  222|   152k|		{
  223|   152k|			free_NC_var(*vpp);
  224|       |			*vpp = NULL;
  225|   152k|		}
  226|     74|	}
  227|     74|	ncap->nelems = 0;
  228|     74|}
free_NC_vararrayV:
  238|    323|{
  239|    323|	assert(ncap != NULL);
  ------------------
  |  Branch (239:2): [True: 0, False: 323]
  |  Branch (239:2): [True: 323, False: 0]
  ------------------
  240|       |
  241|    323|	if(ncap->nalloc == 0)
  ------------------
  |  Branch (241:5): [True: 249, False: 74]
  ------------------
  242|    249|		return;
  243|       |
  244|     74|	NC_hashmapfree(ncap->hashmap);
  245|     74|	ncap->hashmap = NULL;
  246|       |
  247|     74|	assert(ncap->value != NULL);
  ------------------
  |  Branch (247:2): [True: 0, False: 74]
  |  Branch (247:2): [True: 74, False: 0]
  ------------------
  248|       |
  249|     74|	free_NC_vararrayV0(ncap);
  250|       |
  251|     74|	free(ncap->value);
  252|       |	ncap->value = NULL;
  253|     74|	ncap->nalloc = 0;
  254|     74|}
ncx_szof:
  409|    738|{
  410|    738|	switch(type){
  411|      2|	case NC_BYTE:
  ------------------
  |  |   35|      2|#define NC_BYTE         1       /**< signed 1 byte integer */
  ------------------
  |  Branch (411:2): [True: 2, False: 736]
  ------------------
  412|      2|	case NC_CHAR:
  ------------------
  |  |   36|      2|#define NC_CHAR         2       /**< ISO/ASCII character */
  ------------------
  |  Branch (412:2): [True: 0, False: 738]
  ------------------
  413|      3|	case NC_UBYTE:
  ------------------
  |  |   42|      3|#define NC_UBYTE        7       /**< unsigned 1 byte int */
  ------------------
  |  Branch (413:2): [True: 1, False: 737]
  ------------------
  414|      3|		return(1);
  415|      0|	case NC_SHORT :
  ------------------
  |  |   37|      0|#define NC_SHORT        3       /**< signed 2 byte integer */
  ------------------
  |  Branch (415:2): [True: 0, False: 738]
  ------------------
  416|      0|		return(2);
  417|      1|	case NC_INT:
  ------------------
  |  |   38|      1|#define NC_INT          4       /**< signed 4 byte integer */
  ------------------
  |  Branch (417:2): [True: 1, False: 737]
  ------------------
  418|      1|		return X_SIZEOF_INT;
  ------------------
  |  |   65|      1|#define X_SIZEOF_INT		4	/* xdr_int */
  ------------------
  419|      0|	case NC_FLOAT:
  ------------------
  |  |   40|      0|#define NC_FLOAT        5       /**< single precision floating point number */
  ------------------
  |  Branch (419:2): [True: 0, False: 738]
  ------------------
  420|      0|		return X_SIZEOF_FLOAT;
  ------------------
  |  |   69|      0|#define X_SIZEOF_FLOAT		4
  ------------------
  421|      0|	case NC_DOUBLE :
  ------------------
  |  |   41|      0|#define NC_DOUBLE       6       /**< double precision floating point number */
  ------------------
  |  Branch (421:2): [True: 0, False: 738]
  ------------------
  422|      0|		return X_SIZEOF_DOUBLE;
  ------------------
  |  |   70|      0|#define X_SIZEOF_DOUBLE		8
  ------------------
  423|      0|	case NC_USHORT :
  ------------------
  |  |   43|      0|#define NC_USHORT       8       /**< unsigned 2-byte int */
  ------------------
  |  Branch (423:2): [True: 0, False: 738]
  ------------------
  424|      0|		return X_SIZEOF_USHORT;
  ------------------
  |  |   74|      0|#define X_SIZEOF_USHORT		2
  ------------------
  425|      1|	case NC_UINT :
  ------------------
  |  |   44|      1|#define NC_UINT         9       /**< unsigned 4-byte int */
  ------------------
  |  Branch (425:2): [True: 1, False: 737]
  ------------------
  426|      1|		return X_SIZEOF_UINT;
  ------------------
  |  |   75|      1|#define X_SIZEOF_UINT		4
  ------------------
  427|    499|	case NC_INT64 :
  ------------------
  |  |   45|    499|#define NC_INT64        10      /**< signed 8-byte int */
  ------------------
  |  Branch (427:2): [True: 499, False: 239]
  ------------------
  428|    499|		return X_SIZEOF_INT64;
  ------------------
  |  |   78|    499|#define X_SIZEOF_INT64		8
  ------------------
  429|    234|	case NC_UINT64 :
  ------------------
  |  |   46|    234|#define NC_UINT64       11      /**< unsigned 8-byte int */
  ------------------
  |  Branch (429:2): [True: 234, False: 504]
  ------------------
  430|    234|		return X_SIZEOF_UINT64;
  ------------------
  |  |   79|    234|#define X_SIZEOF_UINT64		8
  ------------------
  431|      0|	default:
  ------------------
  |  Branch (431:2): [True: 0, False: 738]
  ------------------
  432|       |		/* 37824 Ignore */
  433|      0|	        assert("ncx_szof invalid type" == 0);
  ------------------
  |  Branch (433:10): [Folded, False: 0]
  |  Branch (433:10): [Folded, False: 0]
  ------------------
  434|      0|	        return 0;
  435|    738|	}
  436|    738|}
NC_var_shape:
  446|    738|{
  447|    738|	size_t *shp, *op;
  448|    738|	off_t *dsp;
  449|    738|	int *ip = NULL;
  450|    738|	const NC_dim *dimp;
  451|    738|	off_t product = 1;
  452|       |
  453|    738|	varp->xsz = ncx_szof(varp->type);
  454|       |
  455|    738|	if(varp->ndims == 0 || varp->dimids == NULL)
  ------------------
  |  Branch (455:5): [True: 734, False: 4]
  |  Branch (455:25): [True: 0, False: 4]
  ------------------
  456|    734|	{
  457|    734|		goto out;
  458|    734|	}
  459|       |
  460|       |	/*
  461|       |	 * use the user supplied dimension indices
  462|       |	 * to determine the shape
  463|       |	 */
  464|      4|	for(ip = varp->dimids, op = varp->shape
  465|     11|          ; ip < &varp->dimids[varp->ndims]; ip++, op++)
  ------------------
  |  Branch (465:13): [True: 8, False: 3]
  ------------------
  466|      8|	{
  467|      8|		if(*ip < 0 || (size_t) (*ip) >= ((dims != NULL) ? dims->nelems : 1) )
  ------------------
  |  Branch (467:6): [True: 0, False: 8]
  |  Branch (467:17): [True: 1, False: 7]
  |  Branch (467:36): [True: 8, False: 0]
  ------------------
  468|      1|			return NC_EBADDIM;
  ------------------
  |  |  460|      1|#define NC_EBADDIM	(-46)	   /**< Invalid dimension id or name */
  ------------------
  469|       |
  470|      7|		dimp = elem_NC_dimarray(dims, (size_t)*ip);
  471|      7|		*op = dimp->size;
  472|      7|		if(*op == NC_UNLIMITED && ip != varp->dimids)
  ------------------
  |  |  300|     14|#define NC_UNLIMITED 0L
  ------------------
  |  Branch (472:6): [True: 3, False: 4]
  |  Branch (472:29): [True: 0, False: 3]
  ------------------
  473|      0|			return NC_EUNLIMPOS;
  ------------------
  |  |  461|      0|#define NC_EUNLIMPOS	(-47)	   /**< NC_UNLIMITED in the wrong index */
  ------------------
  474|      7|	}
  475|       |
  476|       |	/*
  477|       |	 * Compute the dsizes
  478|       |	 */
  479|       |				/* ndims is > 0 here */
  480|      3|	for(shp = varp->shape + varp->ndims -1,
  481|      3|				dsp = varp->dsizes + varp->ndims -1;
  482|     10| 			shp >= varp->shape;
  ------------------
  |  Branch (482:5): [True: 7, False: 3]
  ------------------
  483|      7|			shp--, dsp--)
  484|      7|	{
  485|       |      /*if(!(shp == varp->shape && IS_RECVAR(varp)))*/
  486|      7|      if( shp != NULL && (shp != varp->shape || !IS_RECVAR(varp)))
  ------------------
  |  |  221|      3|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      3|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:6): [True: 3, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (486:11): [True: 7, False: 0]
  |  Branch (486:27): [True: 4, False: 3]
  |  Branch (486:49): [True: 0, False: 3]
  ------------------
  487|      4|		{
  488|      4|          if(product <= 0)
  ------------------
  |  Branch (488:14): [True: 0, False: 4]
  ------------------
  489|      0|            return NC_ERANGE;
  ------------------
  |  |  496|      0|#define NC_ERANGE       (-60)
  ------------------
  490|      4|          if( ((off_t)(*shp)) <= OFF_T_MAX / product )
  ------------------
  |  |   41|      4|#define OFF_T_MAX MAX_INT_VAL(off_t)
  |  |  ------------------
  |  |  |  |   36|      4|    ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|      4|    ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
  |  |  |  |  ------------------
  |  |  |  |                   ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|      4|    ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (490:15): [True: 3, False: 1]
  ------------------
  491|      3|			{
  492|      3|              product *= (*shp > 0 ? (off_t)*shp : 1);
  ------------------
  |  Branch (492:27): [True: 3, False: 0]
  ------------------
  493|      3|			} else
  494|      1|			{
  495|      1|              product = OFF_T_MAX ;
  ------------------
  |  |   41|      1|#define OFF_T_MAX MAX_INT_VAL(off_t)
  |  |  ------------------
  |  |  |  |   36|      1|    ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|      1|    ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
  |  |  |  |  ------------------
  |  |  |  |                   ((MAX_INT_VAL_STEP(t) - 1) + MAX_INT_VAL_STEP(t))
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|      1|    ((t) 1 << (CHAR_BIT * sizeof(t) - 1 - ((t) -1 < 1)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  496|      1|			}
  497|      4|		}
  498|      7|      *dsp = product;
  499|      7|	}
  500|       |
  501|       |
  502|    737|out :
  503|       |
  504|       |    /*
  505|       |     * For CDF-1 and CDF-2 formats, the total number of array elements
  506|       |     * cannot exceed 2^32, unless this variable is the last fixed-size
  507|       |     * variable, there is no record variable, and the file starting
  508|       |     * offset of this variable is less than 2GiB.
  509|       |     * This will be checked in NC_check_vlens() during NC_endef()
  510|       |     */
  511|    737|    varp->len = product * (off_t)varp->xsz;
  512|    737|    if (varp->len % 4 > 0)
  ------------------
  |  Branch (512:9): [True: 2, False: 735]
  ------------------
  513|      2|        varp->len += 4 - varp->len % 4; /* round up */
  514|       |
  515|       |#if 0
  516|       |	arrayp("\tshape", varp->ndims, varp->shape);
  517|       |	arrayp("\tdsizes", varp->ndims, varp->dsizes);
  518|       |#endif
  519|    737|	return NC_NOERR;
  ------------------
  |  |  417|    737|#define NC_NOERR        0          /**< No Error */
  ------------------
  520|      3|}
NC_check_vlen:
  530|    264|NC_check_vlen(NC_var *varp, long long vlen_max) {
  531|    264|    size_t ii;
  532|    264|    long long prod = (long long)varp->xsz;	/* product of xsz and dimensions so far */
  533|       |
  534|    264|    assert(varp != NULL);
  ------------------
  |  Branch (534:5): [True: 0, False: 264]
  |  Branch (534:5): [True: 264, False: 0]
  ------------------
  535|    265|    for(ii = IS_RECVAR(varp) ? 1 : 0; ii < varp->ndims; ii++) {
  ------------------
  |  |  221|    264|    ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
  |  |  ------------------
  |  |  |  |  300|      2|#define NC_UNLIMITED 0L
  |  |  ------------------
  |  |  |  Branch (221:5): [True: 2, False: 262]
  |  |  |  Branch (221:6): [True: 2, False: 262]
  |  |  ------------------
  ------------------
  |  Branch (535:39): [True: 2, False: 263]
  ------------------
  536|      2|      if(!varp->shape)
  ------------------
  |  Branch (536:10): [True: 0, False: 2]
  ------------------
  537|      0|        return 0; /* Shape is undefined/NULL. */
  538|      2|      if(prod <= 0)
  ------------------
  |  Branch (538:10): [True: 0, False: 2]
  ------------------
  539|      0|	    return 0; /* Multiplication operations may result in overflow */
  540|      2|      if ((long long)varp->shape[ii] > vlen_max / prod) {
  ------------------
  |  Branch (540:11): [True: 1, False: 1]
  ------------------
  541|      1|        return 0;		/* size in bytes won't fit in a 32-bit int */
  542|      1|      }
  543|      1|      prod *= (long long)varp->shape[ii];
  544|      1|    }
  545|    263|    return 1;			/* OK */
  546|    264|}

NC4_initialize:
   41|      1|{
   42|      1|    int ret = NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   43|       |
   44|       |#ifdef USE_UDF0
   45|       |    /* If user-defined format 0 was specified during configure, set up
   46|       |     * it's dispatch table. */
   47|       |    if ((ret = nc_def_user_format(NC_UDF0, UDF0_DISPATCH_FUNC, NULL)))
   48|       |        return ret;
   49|       |#endif /* USE_UDF0 */
   50|       |
   51|       |#ifdef USE_UDF1
   52|       |    /* If user-defined format 0 was specified during configure, set up
   53|       |     * it's dispatch table. */
   54|       |    if ((ret = nc_def_user_format(NC_UDF1F, &UDF1_DISPATCH_FUNC, NULL)))
   55|       |        return ret;
   56|       |#endif /* USE_UDF0 */
   57|       |
   58|       |#ifdef LOGGING
   59|       |    if(getenv(NCLOGLEVELENV) != NULL) {
   60|       |        char* slevel = getenv(NCLOGLEVELENV);
   61|       |        long level = atol(slevel);
   62|       |#ifdef USE_NETCDF4
   63|       |        if(level >= 0) {
   64|       |            nc_set_log_level((int)level);
   65|       |        }
   66|       |    }
   67|       |#endif
   68|       |#endif
   69|       |
   70|      1|#if defined(USE_HDF5) || defined(NETCDF_ENABLE_NCZARR)
   71|      1|    nc_plugin_path_initialize();
   72|      1|#endif
   73|       |
   74|       |    /* Load UDF plugins from RC file configuration */
   75|      1|    if ((ret = NC_udf_load_plugins()))
  ------------------
  |  Branch (75:9): [True: 0, False: 1]
  ------------------
   76|      0|        return ret;
   77|       |
   78|      1|    NC_initialize_reserved();
   79|      1|    return ret;
   80|      1|}
NC4_finalize:
   90|      1|{
   91|      1|#if defined(USE_HDF5) || defined(NETCDF_ENABLE_NCZARR)
   92|      1|    nc_plugin_path_finalize();
   93|      1|#endif
   94|      1|    return NC_NOERR;
  ------------------
  |  |  417|      1|#define NC_NOERR        0          /**< No Error */
  ------------------
   95|      1|}

NC_initialize_reserved:
 2106|      1|{
 2107|       |    /* Guarantee the reserved attribute list is sorted */
 2108|      1|    qsort((void*)NC_reserved,NRESERVED,sizeof(NC_reservedatt),sortcmp);
  ------------------
  |  |   62|      1|#define NRESERVED (sizeof(NC_reserved) / sizeof(NC_reservedatt))  /*|NC_reservedatt*/
  ------------------
 2109|      1|}
nc4internal.c:sortcmp:
 2090|     35|{
 2091|     35|    NC_reservedatt* r1 = (NC_reservedatt*)arg1;
 2092|     35|    NC_reservedatt* r2 = (NC_reservedatt*)arg2;
 2093|     35|    return strcmp(r1->name,r2->name);
 2094|     35|}

