[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #RUF-772159]: group name as const char* in nc_def_grp



Huaiyu,

> Similar bugs are actually quite common although not necessarily for
> strings. For example, in
> =================================================
> int nc_def_var (int ncid, const char *name, nc_type xtype,
> int ndims, const int dimids[], int *varidp);
> =================================================
> one does not expect "ncid", "xtype" or "ndims" to be changed. Will you
> change them, too?

No, those aren't pointer types, so the values of the arguments can't
be changed by the called function.  C uses "copy by value" semantics,
so in this case the called function just gets a local copy of the argument,
and changing it has no effect on the original value in the calling
context.  But when addresses are passed to the called function, the
function gets a copy of the address and can use that to actually change
the value in the calling context.

--Russ

> 
> On Nov 25, 2009, at 1:15 PM, Unidata netCDF Support wrote:
> 
> > Hi Huaiyu,
> >
> >> It is to my surprise that, in NetCDF 4, the group name in function
> >> nc_def_grp() of the C interface is defined as char* instead of const
> >> char*. Will it be changed during the function call?
> >
> > No, the call does not change the name string.
> >
> > It is a mistake in the interface that this is not declared to be of
> > type
> > "const char*" instead of "char *".  Thank you for making us aware of
> > this
> > bug.
> >
> > Checking the other library interfaces, it appears that there are ten
> > other functions that have the same problem, with arguments declared
> > "char *" that should actually be "const char *".  I will try to make
> > sure these bugs are fixed before the 4.1 release.
> >
> > This was an important bug, so thanks again for reporting it!
> >
> > --Russ
> >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                     http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: RUF-772159
> > Department: Support netCDF
> > Priority: High
> > Status: Closed
> >
> 
> 

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: RUF-772159
Department: Support netCDF
Priority: High
Status: Closed