Commit daa393a2 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Fix gcc warnings.

parent eff0dc4f
......@@ -368,14 +368,14 @@ void printShortinfo(int streamID, int vlistID, int vardis)
// institute info
const char *instptr = institutInqNamePtr(vlistInqVarInstitut(vlistID, varID));
strcpy(tmpname, "unknown");
if ( instptr ) strncpy(tmpname, instptr, CDI_MAX_NAME);
if ( instptr ) strncpy(tmpname, instptr, CDI_MAX_NAME-1);
limit_string_length(tmpname, CDI_MAX_NAME);
fprintf(stdout, "%-8s ", tmpname);
// source info
const char *modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID));
strcpy(tmpname, "unknown");
if ( modelptr ) strncpy(tmpname, modelptr, CDI_MAX_NAME);
if ( modelptr ) strncpy(tmpname, modelptr, CDI_MAX_NAME-1);
limit_string_length(tmpname, CDI_MAX_NAME);
fprintf(stdout, "%-8s ", tmpname);
......
......@@ -266,7 +266,7 @@ static inline
void gridSetString(char *gridstrname, const char *name, size_t len)
{
if ( len > CDI_MAX_NAME ) len = CDI_MAX_NAME;
strncpy(gridstrname, name, len);
strncpy(gridstrname, name, len - 1);
gridstrname[len - 1] = 0;
}
......
......@@ -332,17 +332,17 @@ static inline
void zaxisSetString(char *zaxisstrname, const char *name, size_t len)
{
if ( len > CDI_MAX_NAME ) len = CDI_MAX_NAME;
strncpy(zaxisstrname, name, len);
strncpy(zaxisstrname, name, len - 1);
zaxisstrname[len-1] = 0;
}
static inline
void zaxisGetString(char *name, const char *zaxisstrname, size_t len)
{
size_t slen = strlen(zaxisstrname)+1;
size_t slen = strlen(zaxisstrname) + 1;
if ( slen > len ) slen = len;
if ( slen > CDI_MAX_NAME ) slen = CDI_MAX_NAME;
strncpy(name, zaxisstrname, slen);
strncpy(name, zaxisstrname, slen - 1);
name[slen-1] = 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment