Browse Source

genann: Fix unused-result warnings for fscanf()

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
pull/7/head
Andrew Jeffery 3 years ago
parent
commit
9e86fc903e
1 changed files with 17 additions and 2 deletions
  1. +17
    -2
      genann.c

+ 17
- 2
genann.c View File

@ -30,6 +30,7 @@
#include <math.h>
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#define LOOKUP_SIZE 4096
@ -122,13 +123,27 @@ genann *genann_init(int inputs, int hidden_layers, int hidden, int outputs) {
genann *genann_read(FILE *in) {
int inputs, hidden_layers, hidden, outputs;
fscanf(in, "%d %d %d %d", &inputs, &hidden_layers, &hidden, &outputs);
int rc;
errno = 0;
rc = fscanf(in, "%d %d %d %d", &inputs, &hidden_layers, &hidden, &outputs);
if (rc < 4 || errno != 0) {
perror("fscanf");
return NULL;
}
genann *ann = genann_init(inputs, hidden_layers, hidden, outputs);
int i;
for (i = 0; i < ann->total_weights; ++i) {
fscanf(in, " %le", ann->weight + i);
errno = 0;
rc = fscanf(in, " %le", ann->weight + i);
if (rc < 1 || errno != 0) {
perror("fscanf");
genann_free(ann);
return NULL;
}
}
return ann;


Loading…
Cancel
Save