]> granicus.if.org Git - graphviz/commitdiff
squash warning in SparseMatrix_import_matrix_market/MATRIX_TYPE_INTEGER
authorCosta Shulyupin <constantine.shulyupin@gmail.com>
Sun, 3 Apr 2022 08:08:47 +0000 (11:08 +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 79d121ff635133352e476de522db7ed39864160a..8803afb7c9ee9acf8173cfbcb7dad8879a20da3f 100644 (file)
@@ -153,7 +153,9 @@ SparseMatrix SparseMatrix_import_matrix_market(FILE * f, int format)
        case MATRIX_TYPE_INTEGER:
            vali = malloc(nz * sizeof(int));
            for (i = 0; i < nz; i++) {
-               fscanf(f, "%d %d %d\n", &I[i], &J[i], &vali[i]);
+               int num = fscanf(f, "%d %d %d\n", &I[i], &J[i], &vali[i]);
+               (void)num;
+               assert(num == 3);
                I[i]--;         /* adjust from 1-based to 0-based */
                J[i]--;
            }