Xinqi Bao's Git

Implement esnprintf() and make formatted calls more efficient
[slstatus.git] / components / netspeeds.c
index b4e6972..6adc3ea 100644 (file)
 
                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;
                }
 
                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;
                }