mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-31 17:50:26 +08:00
Fix Coverity complaint about passing big parameter by value
This commit is contained in:
parent
685e1bf66a
commit
4d6f11288b
@ -261,8 +261,8 @@ typedef short int shmem_t;
|
||||
|
||||
/* Warning: fields from BEGIN COMMON to END COMMON must be same for:
|
||||
1. NCcommon (include/ncdispatch.h)
|
||||
2. NC (libsrc/nc.h)
|
||||
3. NC_FILE_INFO (libsrc4/nc4internal.h)
|
||||
2. NC (include/nc.h)
|
||||
3. NC_FILE_INFO (include/nc4internal.h)
|
||||
4. whatever libdiskless uses
|
||||
*/
|
||||
struct NC {
|
||||
|
@ -769,7 +769,7 @@ NC_endef(NC *ncp,
|
||||
return status;
|
||||
|
||||
}
|
||||
else if(ncp->vars.nelems > ncp->old->vars.nelems)
|
||||
else if(ncp->old && (ncp->vars.nelems > ncp->old->vars.nelems))
|
||||
{
|
||||
status = fill_added(ncp, ncp->old);
|
||||
if(status != NC_NOERR)
|
||||
|
@ -639,7 +639,7 @@ pr_att(
|
||||
/* Prints text after semicolon and before final newline.
|
||||
* Prints nothing if not qualified for time interpretation.
|
||||
* Will include line breaks for longer lists. */
|
||||
print_att_times(ncid, varid, att);
|
||||
print_att_times(ncid, varid, &att);
|
||||
if(is_bounds_att(&att)) {
|
||||
insert_bounds_info(ncid, varid, &att);
|
||||
}
|
||||
|
@ -273,10 +273,10 @@ void
|
||||
print_att_times(
|
||||
int ncid,
|
||||
int varid, /* parent var ID */
|
||||
ncatt_t att /* attribute structure */
|
||||
const ncatt_t *att /* attribute structure */
|
||||
)
|
||||
{
|
||||
nc_type type = att.type; /* local copy */
|
||||
nc_type type = att->type; /* local copy */
|
||||
boolean wrap;
|
||||
boolean first_item;
|
||||
|
||||
@ -291,7 +291,7 @@ print_att_times(
|
||||
if (varid == NC_GLOBAL) /* time units not defined for global atts */
|
||||
return;
|
||||
|
||||
assert (att.len > 0); /* should already be eliminated by caller */
|
||||
assert (att->len > 0); /* should already be eliminated by caller */
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
assert ( type == NC_BYTE || type == NC_SHORT || type == NC_INT
|
||||
@ -313,7 +313,7 @@ print_att_times(
|
||||
/* Convert each value to ISO date/time string, and print. */
|
||||
|
||||
size_t iel; /* attrib index */
|
||||
const char *valp = (const char *)att.valgp; /* attrib value pointer */
|
||||
const char *valp = (const char *)att->valgp; /* attrib value pointer */
|
||||
safebuf_t *sb = sbuf_new(); /* allocate new string buffer */
|
||||
#ifdef NOTUSED
|
||||
int func; /* line wrap control */
|
||||
@ -322,17 +322,17 @@ print_att_times(
|
||||
separator = 'T';
|
||||
#endif
|
||||
|
||||
var.type = att.type; /* insert attrib type into fake var */
|
||||
var.type = att->type; /* insert attrib type into fake var */
|
||||
|
||||
for (iel = 0; iel < att.len; iel++) {
|
||||
for (iel = 0; iel < att->len; iel++) {
|
||||
nctime_val_tostring(&var, sb, (void *)valp); /* convert to str. */
|
||||
valp += att.tinfo->size; /* increment value pointer, by type */
|
||||
if (iel < att.len - 1) /* add comma, except for final value */
|
||||
valp += att->tinfo->size; /* increment value pointer, by type */
|
||||
if (iel < att->len - 1) /* add comma, except for final value */
|
||||
sbuf_cat(sb, ",");
|
||||
|
||||
first_item = (iel == 0); /* identify start of list */
|
||||
|
||||
wrap = (att.len > 2); /* specify line wrap variations: */
|
||||
wrap = (att->len > 2); /* specify line wrap variations: */
|
||||
/* 1 or 2 values: keep on same line, */
|
||||
/* more than 2: enable line wrap */
|
||||
|
||||
|
@ -11,4 +11,4 @@ extern void insert_bounds_info(int ncid, int varid, ncatt_t *attp);
|
||||
extern int is_valid_time_unit(const char *units);
|
||||
extern int is_bounds_att(ncatt_t *attp);
|
||||
extern void get_timeinfo(int ncid, int varid, ncvar_t *vp);
|
||||
extern void print_att_times(int ncid, int varid, ncatt_t att);
|
||||
extern void print_att_times(int ncid, int varid, const ncatt_t *att);
|
||||
|
Loading…
x
Reference in New Issue
Block a user