summaryrefslogtreecommitdiff
path: root/components/netspeeds.c
diff options
context:
space:
mode:
authorLaslo Hunhold <dev@frign.de>2018-05-19 19:33:04 +0200
committerAaron Marcher <me@drkhsh.at>2018-05-19 19:44:02 +0200
commit422cadfd5ffd78ae1b8fdf15734e03bd0333b26e (patch)
treecf243529272e96e3d65b44afecd08cbb9f4e3005 /components/netspeeds.c
parentf31b113e7e85bf7057cb88a70d88c5ce9325e208 (diff)
Implement esnprintf() and make formatted calls more efficient
Within the components, snprintf() was unchecked and had inefficient calls in some places. We implement esnprintf() that does all the dirty laundry for us and use it exclusively now.
Diffstat (limited to 'components/netspeeds.c')
-rw-r--r--components/netspeeds.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/components/netspeeds.c b/components/netspeeds.c
index b4e6972..6adc3ea 100644
--- a/components/netspeeds.c
+++ b/components/netspeeds.c
@@ -17,8 +17,11 @@
oldrxbytes = rxbytes;
- snprintf(path, sizeof(path),
- "/sys/class/net/%s/statistics/rx_bytes", interface);
+ if (esnprintf(path, sizeof(path),
+ "/sys/class/net/%s/statistics/rx_bytes",
+ interface) < 0) {
+ return NULL;
+ }
if (pscanf(path, "%llu", &rxbytes) != 1) {
return NULL;
}
@@ -37,8 +40,11 @@
oldtxbytes = txbytes;
- snprintf(path, sizeof(path),
- "/sys/class/net/%s/statistics/tx_bytes", interface);
+ if (esnprintf(path, sizeof(path),
+ "/sys/class/net/%s/statistics/tx_bytes",
+ interface) < 0) {
+ return NULL;
+ }
if (pscanf(path, "%llu", &txbytes) != 1) {
return NULL;
}