[petsc-dev] Format warning

Satish Balay balay at mcs.anl.gov
Tue Jun 14 11:35:06 CDT 2016


On Tue, 14 Jun 2016, Lisandro Dalcin wrote:

> Satish, I'm setting up Pipelines in a private repo
> petsc/setup-pilelines before putting the stuff in petsc/petsc. I got
> the following warning (configured with 64 bits integers).
> 
> /opt/atlassian/bitbucketci/agent/build/petsc/src/sys/classes/viewer/impls/ascii/filev.c:
> In function 'PetscErrorCode PetscViewerASCIIRead(PetscViewer, void*,
> PetscInt, PetscInt*, PetscDataType)':
> /opt/atlassian/bitbucketci/agent/build/petsc/src/sys/classes/viewer/impls/ascii/filev.c:1054:86:
> warning: format '%ld' expects argument of type 'long int*', but
> argument 3 has type 'PetscInt* {aka long long int*}' [-Wformat=]
>      else if (dtype == PETSC_INT)     ret = fscanf(fd, "%ld",
> &(((PetscInt*)data)[i]));

Perhaps the following fix [or something better].. We have to somehow sync petsc datatypes with printf/scanf format..
[if no objections - I schedule it for maint and merge to next]

Satish..

----------
$ git diff |cat
diff --git a/src/sys/classes/viewer/impls/ascii/filev.c b/src/sys/classes/viewer/impls/ascii/filev.c
index 6c4163e..55af525 100644
--- a/src/sys/classes/viewer/impls/ascii/filev.c
+++ b/src/sys/classes/viewer/impls/ascii/filev.c
@@ -1050,10 +1050,12 @@ PetscErrorCode PetscViewerASCIIRead(PetscViewer viewer,void *data,PetscInt num,P
     if (dtype == PETSC_CHAR)         ret = fscanf(fd, "%c",  &(((char*)data)[i]));
     else if (dtype == PETSC_STRING)  ret = fscanf(fd, "%s",  &(((char*)data)[i]));
 #if PETSC_USE_64BIT_INDICES
-#if (PETSC_SIZEOF_LONG_LONG == 8)
+#if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_MPI_INT64_T)
     else if (dtype == PETSC_INT)     ret = fscanf(fd, "%ld",  &(((PetscInt*)data)[i]));
-#else
+#elif (PETSC_SIZEOF_LONG_LONG == 8)
     else if (dtype == PETSC_INT)     ret = fscanf(fd, "%lld",  &(((PetscInt*)data)[i]));
+#elif defined(PETSC_HAVE___INT64)
+    else if (dtype == PETSC_INT)     ret = fscanf(fd, "%ld",  &(((PetscInt*)data)[i]));
 #endif
 #else
     else if (dtype == PETSC_INT)     ret = fscanf(fd, "%d",  &(((PetscInt*)data)[i]));




More information about the petsc-dev mailing list