]> granicus.if.org Git - graphviz/commitdiff
squash warning in SparseMatrix_import_matrix_market/MATRIX_TYPE_REAL
authorCosta Shulyupin <constantine.shulyupin@gmail.com>
Sun, 3 Apr 2022 08:04:41 +0000 (11:04 +0300)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 7 Apr 2022 15:28:22 +0000 (08:28 -0700)
warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]

On  success,  these functions return the number of input items
successfully matched and assigned; this can be fewer  than
provided  for,  or even zero, in the event of an early
matching failure.

cmd/tools/matrix_market.c

index 4a81723332df971416a67c0d689148b5cf85bb58..79d121ff635133352e476de522db7ed39864160a 100644 (file)
@@ -116,7 +116,9 @@ SparseMatrix SparseMatrix_import_matrix_market(FILE * f, int format)
        case MATRIX_TYPE_REAL:
            val = malloc(nz * sizeof(double));
            for (i = 0; i < nz; i++) {
-               fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
+               int num = fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
+               (void)num;
+               assert(num == 3);
                I[i]--;         /* adjust from 1-based to 0-based */
                J[i]--;
            }