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.
This commit is contained in:
parent
f31b113e7e
commit
422cadfd5f
6 changed files with 72 additions and 23 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue