Skip to content

Commit

Permalink
Merge pull request ESMCI#1367 from NCAR/ejh_warnings
Browse files Browse the repository at this point in the history
fixed fscan warnings in pioc_support.c
  • Loading branch information
edhartnett authored Mar 21, 2019
2 parents 38e16a2 + 48a4923 commit 13c1bc1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,8 @@ int PIOc_readmap(const char *file, int *ndims, int **gdims, PIO_Offset *fmaplen,
if (!fp)
pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);

fscanf(fp,"version %d npes %d ndims %d\n",&rversno, &rnpes, ndims);

if (fscanf(fp,"version %d npes %d ndims %d\n", &rversno, &rnpes, ndims) != 3)
pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);
if (rversno != VERSNO)
return pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);

Expand All @@ -895,20 +895,23 @@ int PIOc_readmap(const char *file, int *ndims, int **gdims, PIO_Offset *fmaplen,
if (!(tdims = calloc(*ndims, sizeof(int))))
return pio_err(NULL, NULL, PIO_ENOMEM, __FILE__, __LINE__);
for (int i = 0; i < *ndims; i++)
fscanf(fp,"%d ", tdims + i);
if (fscanf(fp,"%d ", tdims + i) != 1)
pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);

if ((mpierr = MPI_Bcast(tdims, *ndims, MPI_INT, 0, comm)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);

for (int i = 0; i < rnpes; i++)
{
fscanf(fp, "%d %lld", &j, &maplen);
if (fscanf(fp, "%d %lld", &j, &maplen) != 2)
pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);
if (j != i) // Not sure how this could be possible
return pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);
if (!(tmap = malloc(maplen * sizeof(PIO_Offset))))
return pio_err(NULL, NULL, PIO_ENOMEM, __FILE__, __LINE__);
for (j = 0; j < maplen; j++)
fscanf(fp, "%lld ", tmap+j);
if (fscanf(fp, "%lld ", tmap + j) != 1)
pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);

if (i > 0)
{
Expand Down

0 comments on commit 13c1bc1

Please sign in to comment.