Commit b111289e45 for aom
commit b111289e45d1bdd07ab5b1e0ee06662157ccae7a
Author: James Zern <jzern@google.com>
Date: Thu Jun 18 14:55:09 2026 -0700
grain_table.c: improve fscanf checks
Replace `!fscanf()` with a check on the returned count as `fscanf` may
also return `EOF.
Fixes some clang-19 static analysis warnings of the form:
```
File position of the stream might be 'indeterminate' after a failed
operation. Can cause undefined behavior
```
Bug: 474642915
Change-Id: Ic294e18a62610435282c0636c98e3a6f0b11f111
diff --git a/aom_dsp/grain_table.c b/aom_dsp/grain_table.c
index 91ef2b4bba..97d2465bb8 100644
--- a/aom_dsp/grain_table.c
+++ b/aom_dsp/grain_table.c
@@ -64,7 +64,7 @@ static void grain_table_entry_read(FILE *file,
"Unable to read entry params. Read %d != 12",
num_read);
}
- if (!fscanf(file, "\tsY %d ", &pars->num_y_points)) {
+ if (1 != fscanf(file, "\tsY %d ", &pars->num_y_points)) {
aom_internal_error(error_info, AOM_CODEC_ERROR,
"Unable to read num y points");
}
@@ -75,7 +75,7 @@ static void grain_table_entry_read(FILE *file,
"Unable to read y scaling points");
}
}
- if (!fscanf(file, "\n\tsCb %d", &pars->num_cb_points)) {
+ if (1 != fscanf(file, "\n\tsCb %d", &pars->num_cb_points)) {
aom_internal_error(error_info, AOM_CODEC_ERROR,
"Unable to read num cb points");
}
@@ -86,7 +86,7 @@ static void grain_table_entry_read(FILE *file,
"Unable to read cb scaling points");
}
}
- if (!fscanf(file, "\n\tsCr %d", &pars->num_cr_points)) {
+ if (1 != fscanf(file, "\n\tsCr %d", &pars->num_cr_points)) {
aom_internal_error(error_info, AOM_CODEC_ERROR,
"Unable to read num cr points");
}