commit ec1d812d83bef0d5206975281eea382bcf1f4224
parent 8daa0a03a61de62d8c8d702763a415b1ab7228ea
Author: sin <sin@2f30.org>
Date: Sat, 16 Sep 2017 19:27:34 +0100
No need for goto
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/netspeed.c b/netspeed.c
@@ -102,7 +102,8 @@ netspeedread(void *arg, char *buf, size_t len)
}
if (fscanf(fp, "%llu", &rxbytes) != 1) {
warn("fscanf %s", path);
- goto err;
+ fclose(fp);
+ return -1;
}
fclose(fp);
(void)snprintf(path, sizeof(path), "/sys/class/net/%s/statistics/tx_bytes", ifname);
@@ -112,15 +113,12 @@ netspeedread(void *arg, char *buf, size_t len)
}
if (fscanf(fp, "%llu", &txbytes) != 1) {
warn("fscanf %s", path);
- goto err;
+ fclose(fp);
+ return -1;
}
fclose(fp);
updatenetspeed(buf, len, rxbytes, txbytes);
return 0;
-
-err:
- fclose(fp);
- return -1;
}
#endif