Skip to content

Commit 6c1afaf

Browse files
committed
test/nc_test/tst_small.c compile warning -Wstringop-truncation
1 parent 773caa0 commit 6c1afaf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

test/nc_test/tst_small.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,27 @@
2525
#define NUM_FORMATS 3
2626

2727
#define ATT_NAME "Atom"
28-
#define MAX_LEN 7
28+
#define MAX_LEN 16
2929

3030
#define ERR {if (err != NC_NOERR) {printf("Error at %s line %d: %s\n",__func__,__LINE__,ncmpi_strerror(err)); return 1;}}
3131

3232
static int
3333
test_small_atts(const char *testfile, int cmode)
3434
{
3535
int ncid, err;
36-
char att[MAX_LEN + 1], att_in[MAX_LEN + 1], source[MAX_LEN + 1] = "0123456";
36+
char att[MAX_LEN], att_in[MAX_LEN], source[MAX_LEN]="0123456";
3737
int ndims, nvars, natts, unlimdimid;
3838
MPI_Offset len_in;
39-
int t, f;
39+
size_t t, f, src_len;
40+
41+
src_len = strlen(source);
4042

4143
/* Run this with and without fill mode. */
4244
for (f = 0; f < 2; f++)
4345
{
4446
/* Create small files with an attribute that grows by one each
4547
* time. */
46-
for (t = 1; t < MAX_LEN; t++)
48+
for (t = 1; t < src_len; t++)
4749
{
4850
/* Create null-terminated text string of correct length. */
4951
strncpy(att, source, t);

0 commit comments

Comments
 (0)