Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Implement esnprintf() and make formatted calls more efficient
[slstatus.git]
/
components
/
netspeeds.c
diff --git
a/components/netspeeds.c
b/components/netspeeds.c
index
b4e6972
..
6adc3ea
100644
(file)
--- a/
components/netspeeds.c
+++ b/
components/netspeeds.c
@@
-17,8
+17,11
@@
oldrxbytes = rxbytes;
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;
}
if (pscanf(path, "%llu", &rxbytes) != 1) {
return NULL;
}
@@
-37,8
+40,11
@@
oldtxbytes = txbytes;
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;
}
if (pscanf(path, "%llu", &txbytes) != 1) {
return NULL;
}