mirror of
https://github.com/codeplea/genann
synced 2024-11-24 23:40:02 +03:00
genann: Fix unused-result warnings for fscanf()
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
This commit is contained in:
parent
4ef0a3f874
commit
9e86fc903e
19
genann.c
19
genann.c
@ -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…
Reference in New Issue
Block a user