mirror of
https://github.com/sheumann/hush.git
synced 2024-11-19 23:31:39 +00:00
mpstat: code shrink
function old new delta get_uptime 134 129 -5 get_irqs_from_stat 110 103 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
75a1403f26
commit
1ec49732e2
@ -522,9 +522,7 @@ static void get_irqs_from_stat(struct stats_irq *irq)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
fp = fopen_for_read(PROCFS_STAT);
|
fp = xfopen_for_read(PROCFS_STAT);
|
||||||
if (!fp)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
//bb_error_msg("/proc/stat:'%s'", buf);
|
//bb_error_msg("/proc/stat:'%s'", buf);
|
||||||
@ -644,9 +642,7 @@ static void get_uptime(data_t *uptime)
|
|||||||
char buf[sizeof(long)*3 * 2 + 4]; /* enough for long.long */
|
char buf[sizeof(long)*3 * 2 + 4]; /* enough for long.long */
|
||||||
unsigned long uptime_sec, decimal;
|
unsigned long uptime_sec, decimal;
|
||||||
|
|
||||||
fp = fopen_for_read(PROCFS_UPTIME);
|
fp = xfopen_for_read(PROCFS_UPTIME);
|
||||||
if (!fp)
|
|
||||||
return;
|
|
||||||
if (fgets(buf, sizeof(buf), fp)) {
|
if (fgets(buf, sizeof(buf), fp)) {
|
||||||
if (sscanf(buf, "%lu.%lu", &uptime_sec, &decimal) == 2) {
|
if (sscanf(buf, "%lu.%lu", &uptime_sec, &decimal) == 2) {
|
||||||
*uptime = (data_t)uptime_sec * G.hz + decimal * G.hz / 100;
|
*uptime = (data_t)uptime_sec * G.hz + decimal * G.hz / 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user