Fix warning on unused fscanf return code
Relevant output of make:
gtp.c: In function ‘log_restart’:
gtp.c:697: warning: ignoring return value of ‘fscanf’, declared with
attribute warn_unused_result
Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 5e6c4ab..3ffdb60 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -676,7 +676,7 @@
/* Perform restoration and recovery error handling as described in 29.060 */
static void log_restart(struct gsn_t *gsn) {
FILE *f;
- int i;
+ int i, rc;
int counter = 0;
char filename[NAMESIZE];
@@ -694,7 +694,11 @@
}
else {
umask(i);
- fscanf(f, "%d", &counter);
+ rc = fscanf(f, "%d", &counter);
+ if (rc != 1) {
+ gtp_err(LOG_ERR, __FILE__, __LINE__, "fscanf failed to read counter value");
+ return;
+ }
if (fclose(f)) {
gtp_err(LOG_ERR, __FILE__, __LINE__, "fclose failed: Error = %s", strerror(errno));
}