mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Fix some conversion warnings in ncgen3 generated files
This commit is contained in:
parent
e0622c8a3a
commit
317d2bfd08
@ -142,8 +142,8 @@ data:|DATA: {return (DATA);}
|
||||
yyerror("netCDF name required");
|
||||
return (DATA); /* generate syntax error */
|
||||
}
|
||||
netcdfname = (char *) emalloc(t-s+1);
|
||||
(void) strncpy(netcdfname, s, t-s);
|
||||
netcdfname = (char *) emalloc((size_t)(t-s+1));
|
||||
(void) strncpy(netcdfname, s, (size_t)(t-s));
|
||||
netcdfname[t-s] = '\0';
|
||||
deescapify(netcdfname); /* so "\5foo" becomes "5foo", for example */
|
||||
return (NETCDF);
|
||||
@ -184,7 +184,7 @@ FloatInf|-?Inff { /* missing value (pre-2.4 backward compatibility) */
|
||||
snprintf(errstr, sizeof(errstr),"bad byte constant: %s",(char*)yytext);
|
||||
yyerror(errstr);
|
||||
}
|
||||
byte_val = ii;
|
||||
byte_val = (signed char)ii;
|
||||
if (ii != (int)byte_val) {
|
||||
snprintf(errstr, sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)yytext);
|
||||
yyerror(errstr);
|
||||
|
@ -142,7 +142,7 @@ dimdecline: dimdecl
|
||||
dimdecl: dimd '=' INT_CONST
|
||||
{ if (int_val <= 0)
|
||||
derror("dimension length must be positive");
|
||||
dims[ndims].size = int_val;
|
||||
dims[ndims].size = (size_t)int_val;
|
||||
ndims++;
|
||||
}
|
||||
| dimd '=' DOUBLE_CONST
|
||||
@ -629,10 +629,10 @@ const: CHAR_CONST
|
||||
atype_code = NC_SHORT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = short_val;
|
||||
*char_valp++ = (char)short_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = short_val;
|
||||
*byte_valp++ = (signed char)short_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = short_val;
|
||||
@ -655,19 +655,19 @@ const: CHAR_CONST
|
||||
atype_code = NC_INT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = int_val;
|
||||
*char_valp++ = (char)int_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = int_val;
|
||||
*byte_valp++ = (signed char)int_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = int_val;
|
||||
*short_valp++ = (short)int_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = int_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
*float_valp++ = int_val;
|
||||
*float_valp++ = (float)int_val;
|
||||
break;
|
||||
case NC_DOUBLE:
|
||||
*double_valp++ = int_val;
|
||||
@ -681,16 +681,16 @@ const: CHAR_CONST
|
||||
atype_code = NC_FLOAT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = float_val;
|
||||
*char_valp++ = (char)float_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = float_val;
|
||||
*byte_valp++ = (signed char)float_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = float_val;
|
||||
*short_valp++ = (short)float_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = float_val;
|
||||
*int_valp++ = (int)float_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
*float_valp++ = float_val;
|
||||
@ -707,22 +707,22 @@ const: CHAR_CONST
|
||||
atype_code = NC_DOUBLE;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = double_val;
|
||||
*char_valp++ = (char)double_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = double_val;
|
||||
*byte_valp++ = (signed char)double_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = double_val;
|
||||
*short_valp++ = (short)double_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = double_val;
|
||||
*int_valp++ = (int)double_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
if (double_val == NC_FILL_DOUBLE)
|
||||
*float_valp++ = NC_FILL_FLOAT;
|
||||
else
|
||||
*float_valp++ = double_val;
|
||||
*float_valp++ = (float)double_val;
|
||||
break;
|
||||
case NC_DOUBLE:
|
||||
*double_valp++ = double_val;
|
||||
|
@ -1505,8 +1505,8 @@ YY_RULE_SETUP
|
||||
yyerror("netCDF name required");
|
||||
return (DATA); /* generate syntax error */
|
||||
}
|
||||
netcdfname = (char *) emalloc(t-s+1);
|
||||
(void) strncpy(netcdfname, s, t-s);
|
||||
netcdfname = (char *) emalloc((size_t)(t-s+1));
|
||||
(void) strncpy(netcdfname, s, (size_t)(t-s));
|
||||
netcdfname[t-s] = '\0';
|
||||
deescapify(netcdfname); /* so "\5foo" becomes "5foo", for example */
|
||||
return (NETCDF);
|
||||
@ -1566,7 +1566,7 @@ YY_RULE_SETUP
|
||||
snprintf(errstr, sizeof(errstr),"bad byte constant: %s",(char*)yytext);
|
||||
yyerror(errstr);
|
||||
}
|
||||
byte_val = ii;
|
||||
byte_val = (signed char)ii;
|
||||
if (ii != (int)byte_val) {
|
||||
snprintf(errstr, sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)yytext);
|
||||
yyerror(errstr);
|
||||
|
@ -1310,7 +1310,7 @@ yyreduce:
|
||||
#line 143 "ncgen3/ncgen.y"
|
||||
{ if (int_val <= 0)
|
||||
derror("dimension length must be positive");
|
||||
dims[ndims].size = int_val;
|
||||
dims[ndims].size = (size_t)int_val;
|
||||
ndims++;
|
||||
}
|
||||
#line 1317 "ncgeny.c"
|
||||
@ -1881,10 +1881,10 @@ yyreduce:
|
||||
atype_code = NC_SHORT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = short_val;
|
||||
*char_valp++ = (char)short_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = short_val;
|
||||
*byte_valp++ = (signed char)short_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = short_val;
|
||||
@ -1911,19 +1911,19 @@ yyreduce:
|
||||
atype_code = NC_INT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = int_val;
|
||||
*char_valp++ = (char)int_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = int_val;
|
||||
*byte_valp++ = (signed char)int_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = int_val;
|
||||
*short_valp++ = (short)int_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = int_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
*float_valp++ = int_val;
|
||||
*float_valp++ = (float)int_val;
|
||||
break;
|
||||
case NC_DOUBLE:
|
||||
*double_valp++ = int_val;
|
||||
@ -1941,16 +1941,16 @@ yyreduce:
|
||||
atype_code = NC_FLOAT;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = float_val;
|
||||
*char_valp++ = (char)float_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = float_val;
|
||||
*byte_valp++ = (signed char)float_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = float_val;
|
||||
*short_valp++ = (short)float_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = float_val;
|
||||
*int_valp++ = (int)float_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
*float_valp++ = float_val;
|
||||
@ -1971,22 +1971,22 @@ yyreduce:
|
||||
atype_code = NC_DOUBLE;
|
||||
switch (valtype) {
|
||||
case NC_CHAR:
|
||||
*char_valp++ = double_val;
|
||||
*char_valp++ = (char)double_val;
|
||||
break;
|
||||
case NC_BYTE:
|
||||
*byte_valp++ = double_val;
|
||||
*byte_valp++ = (signed char)double_val;
|
||||
break;
|
||||
case NC_SHORT:
|
||||
*short_valp++ = double_val;
|
||||
*short_valp++ = (short)double_val;
|
||||
break;
|
||||
case NC_INT:
|
||||
*int_valp++ = double_val;
|
||||
*int_valp++ = (int)double_val;
|
||||
break;
|
||||
case NC_FLOAT:
|
||||
if (double_val == NC_FILL_DOUBLE)
|
||||
*float_valp++ = NC_FILL_FLOAT;
|
||||
else
|
||||
*float_valp++ = double_val;
|
||||
*float_valp++ = (float)double_val;
|
||||
break;
|
||||
case NC_DOUBLE:
|
||||
*double_valp++ = double_val;
|
||||
|
Loading…
Reference in New Issue
Block a user