From: Matthew Fernandez Date: Sat, 24 Apr 2021 03:32:49 +0000 (-0700) Subject: squash a number of -Wconversion warnings X-Git-Tag: 2.47.2~13^2~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94f690893edad70353039c192906f87aa66302ab;p=graphviz 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. --- 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;