From 94f690893edad70353039c192906f87aa66302ab Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 23 Apr 2021 20:32:49 -0700 Subject: [PATCH] squash a number of -Wconversion warnings The fread function returns a size_t, so Graphviz should be using a size_t variable to store its result. --- lib/sparse/SparseMatrix.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index bff75965c..6d7d9a805 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #if PQ @@ -659,10 +660,10 @@ void SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag){ SparseMatrix SparseMatrix_import_binary_fp(FILE *f){ SparseMatrix A = NULL; - int m, n, nz, nzmax, type, format, property, iread; + int m, n, nz, nzmax, type, format, property; size_t sz; - iread = fread(&m, sizeof(int), 1, f); + size_t iread = fread(&m, sizeof(int), 1, f); if (iread != 1) return NULL; iread = fread(&n, sizeof(int), 1, f); if (iread != 1) return NULL; @@ -685,17 +686,17 @@ SparseMatrix SparseMatrix_import_binary_fp(FILE *f){ if (format == FORMAT_COORD){ iread = fread(A->ia, sizeof(int), A->nz, f); - if (iread != A->nz) return NULL; + if (iread > (size_t)INT_MAX || (int)iread != A->nz) return NULL; } else { iread = fread(A->ia, sizeof(int), A->m + 1, f); - if (iread != A->m + 1) return NULL; + if (iread > (size_t)INT_MAX || (int)iread != A->m + 1) return NULL; } iread = fread(A->ja, sizeof(int), A->nz, f); - if (iread != A->nz) return NULL; + if (iread > (size_t)INT_MAX || (int)iread != A->nz) return NULL; if (A->size > 0) { iread = fread(A->a, A->size, A->nz, f); - if (iread != A->nz) return NULL; + if (iread > (size_t)INT_MAX || (int)iread != A->nz) return NULL; } fclose(f); return A; -- 2.40.0