Skip to content
Snippets Groups Projects
Commit 8a8788c2 authored by Mathieu Westphal (Kitware)'s avatar Mathieu Westphal (Kitware) :zap:
Browse files

Fix a type warning on sprintf in IO/Legacy/vtkDataWriter

This commit fox a warning in vtkDataWriter
for a incorrect usage of sprintf with vtkIdType
parent d2903559
No related branches found
No related tags found
No related merge requests found
......@@ -326,12 +326,14 @@ typedef long long vtkIdType;
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
# define VTK_ID_MIN VTK_LONG_LONG_MIN
# define VTK_ID_MAX VTK_LONG_LONG_MAX
# define VTK_ID_TYPE_PRId "lld"
# elif VTK_SIZEOF_LONG == 8
typedef long vtkIdType;
# define VTK_ID_TYPE_IMPL VTK_LONG
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
# define VTK_ID_MIN VTK_LONG_MIN
# define VTK_ID_MAX VTK_LONG_MAX
# define VTK_ID_TYPE_PRId "ld"
# else
# error "VTK_USE_64BIT_IDS is ON but no 64-bit integer type is available."
# endif
......@@ -341,6 +343,7 @@ typedef int vtkIdType;
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
# define VTK_ID_MIN VTK_INT_MIN
# define VTK_ID_MAX VTK_INT_MAX
# define VTK_ID_TYPE_PRId "d"
#endif
/*--------------------------------------------------------------------------*/
......
......@@ -2145,14 +2145,8 @@ int vtkDataWriter::WriteFieldData(ostream *fp, vtkFieldData *f)
buffer = new char[ strlen(array->GetName()) * 4 + 1];
this->EncodeString(buffer, array->GetName(), true);
}
#ifdef VTK_USE_64BIT_IDS
sprintf(format, "%s %lld %lld %s\n", buffer, numComp, numTuples,
sprintf(format, "%s %" VTK_ID_TYPE_PRId " %" VTK_ID_TYPE_PRId " %s\n", buffer, numComp, numTuples,
"%s");
#else // VTK_USE_64BIT_IDS
sprintf(format, "%s %ld %ld %s\n", buffer, numComp, numTuples,
"%s");
#endif // VTK_USE_64BIT_IDS
this->WriteArray(fp, array->GetDataType(), array, format, numTuples,
numComp);
delete [] buffer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment