Merge pull request #2028 from Unidata/gh2027.wif

Fix in support of https://github.com/Unidata/netcdf-c/issues/2027
This commit is contained in:
Ward Fisher 2021-07-06 12:14:36 -06:00 committed by GitHub
commit 2ba84ea2b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@
#define ATTNAME "TextAttribute"
#define ATTVAL "This is a text attribute used for testing."
#define ATTVAL_LEN 43
/*! Main function for tst_fill_attr_vanish.c
*
@ -78,10 +78,13 @@ int main()
/* Query existing attribute. */
{
char *attval = malloc(sizeof(char) * strlen(ATTVAL));
char *attval = (char*)malloc(1+(sizeof(char) * strlen(ATTVAL)));
memset(attval,'\0',(1+(sizeof(char) * strlen(ATTVAL))));
printf("**** Checking that attribute still exists:\t");
if(nc_get_att_text(ncid,test_id,ATTNAME,attval)) {printf("Fail\n"); ERR;}
else {printf("%s\n",attval);}
if(nc_get_att_text(ncid,test_id,ATTNAME,attval))
{printf("Fail\n"); ERR;}
else
{printf("%42s\n",attval);}
free(attval);
}
@ -98,7 +101,8 @@ int main()
/* Query existing attribute. */
{
char *attval = malloc(sizeof(char) * strlen(ATTVAL));
char *attval = (char*)malloc(1+(sizeof(char) * strlen(ATTVAL)));
memset(attval,'\0',(1+(sizeof(char) * strlen(ATTVAL))));
printf("**** Checking that attribute still exists, pre-write:\t");
if(nc_get_att_text(ncid,test_id,ATTNAME,attval)) {printf("Fail\n"); ERR;}
else {printf("%s\n",attval);}
@ -118,7 +122,8 @@ int main()
/* Query existing attribute. */
{
char *attval = malloc(sizeof(char) * strlen(ATTVAL));
char *attval = (char*)malloc(1+(sizeof(char) * strnlen(ATTVAL,ATTVAL_LEN)));
memset(attval,'\0',(1+(sizeof(char) * strlen(ATTVAL))));
printf("**** Checking that attribute still exists:\t");
if(nc_get_att_text(ncid,test_id,ATTNAME,attval)) {printf("Fail\n"); ERR;}
else {printf("%s\n",attval);}