diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-12 20:04:00 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-12 20:04:00 +0000 |
commit | 5188b261f9e930e2a3330b385d04f3df4dab5101 (patch) | |
tree | fa440acc3c6dac5a89d41fc0a0e68cd774ccbacb | |
parent | 4c90819a28a6ff368dc8ec867714cf856e6b58f3 (diff) | |
download | busybox-w32-5188b261f9e930e2a3330b385d04f3df4dab5101.tar.gz busybox-w32-5188b261f9e930e2a3330b385d04f3df4dab5101.tar.bz2 busybox-w32-5188b261f9e930e2a3330b385d04f3df4dab5101.zip |
decuddle () from for/if/while
git-svn-id: svn://busybox.net/trunk/busybox@15688 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | libbb/procps.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libbb/procps.c b/libbb/procps.c index 85549c995..0d4877cb6 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -26,7 +26,7 @@ static int read_to_buf(const char *filename, void *buf) | |||
26 | ssize_t ret; | 26 | ssize_t ret; |
27 | 27 | ||
28 | fd = open(filename, O_RDONLY); | 28 | fd = open(filename, O_RDONLY); |
29 | if(fd < 0) | 29 | if (fd < 0) |
30 | return -1; | 30 | return -1; |
31 | ret = read(fd, buf, PROCPS_BUFSIZE-1); | 31 | ret = read(fd, buf, PROCPS_BUFSIZE-1); |
32 | ((char *)buf)[ret > 0 ? ret : 0] = 0; | 32 | ((char *)buf)[ret > 0 ? ret : 0] = 0; |
@@ -53,8 +53,8 @@ procps_status_t * procps_scan(int save_user_arg0) | |||
53 | if (!dir) { | 53 | if (!dir) { |
54 | dir = bb_xopendir("/proc"); | 54 | dir = bb_xopendir("/proc"); |
55 | } | 55 | } |
56 | for(;;) { | 56 | for (;;) { |
57 | if((entry = readdir(dir)) == NULL) { | 57 | if ((entry = readdir(dir)) == NULL) { |
58 | closedir(dir); | 58 | closedir(dir); |
59 | dir = 0; | 59 | dir = 0; |
60 | return 0; | 60 | return 0; |
@@ -68,17 +68,17 @@ procps_status_t * procps_scan(int save_user_arg0) | |||
68 | curstatus.pid = pid; | 68 | curstatus.pid = pid; |
69 | 69 | ||
70 | status_tail = status + sprintf(status, "/proc/%d", pid); | 70 | status_tail = status + sprintf(status, "/proc/%d", pid); |
71 | if(stat(status, &sb)) | 71 | if (stat(status, &sb)) |
72 | continue; | 72 | continue; |
73 | bb_getpwuid(curstatus.user, sb.st_uid, sizeof(curstatus.user)); | 73 | bb_getpwuid(curstatus.user, sb.st_uid, sizeof(curstatus.user)); |
74 | 74 | ||
75 | /* see proc(5) for some details on this */ | 75 | /* see proc(5) for some details on this */ |
76 | strcpy(status_tail, "/stat"); | 76 | strcpy(status_tail, "/stat"); |
77 | n = read_to_buf(status, buf); | 77 | n = read_to_buf(status, buf); |
78 | if(n < 0) | 78 | if (n < 0) |
79 | continue; | 79 | continue; |
80 | name = strrchr(buf, ')'); /* split into "PID (cmd" and "<rest>" */ | 80 | name = strrchr(buf, ')'); /* split into "PID (cmd" and "<rest>" */ |
81 | if(name == 0 || name[1] != ' ') | 81 | if (name == 0 || name[1] != ' ') |
82 | continue; | 82 | continue; |
83 | *name = 0; | 83 | *name = 0; |
84 | sscanf(buf, "%*s (%15c", curstatus.short_cmd); | 84 | sscanf(buf, "%*s (%15c", curstatus.short_cmd); |
@@ -103,9 +103,9 @@ procps_status_t * procps_scan(int save_user_arg0) | |||
103 | &tasknice, | 103 | &tasknice, |
104 | &curstatus.rss); | 104 | &curstatus.rss); |
105 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 105 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
106 | if(n != 6) | 106 | if (n != 6) |
107 | #else | 107 | #else |
108 | if(n != 4) | 108 | if (n != 4) |
109 | #endif | 109 | #endif |
110 | continue; | 110 | continue; |
111 | 111 | ||
@@ -126,21 +126,21 @@ procps_status_t * procps_scan(int save_user_arg0) | |||
126 | curstatus.rss *= (getpagesize() >> 10); /* 2**10 = 1kb */ | 126 | curstatus.rss *= (getpagesize() >> 10); /* 2**10 = 1kb */ |
127 | #endif | 127 | #endif |
128 | 128 | ||
129 | if(save_user_arg0) { | 129 | if (save_user_arg0) { |
130 | strcpy(status_tail, "/cmdline"); | 130 | strcpy(status_tail, "/cmdline"); |
131 | n = read_to_buf(status, buf); | 131 | n = read_to_buf(status, buf); |
132 | if(n > 0) { | 132 | if (n > 0) { |
133 | if(buf[n-1]=='\n') | 133 | if (buf[n-1]=='\n') |
134 | buf[--n] = 0; | 134 | buf[--n] = 0; |
135 | name = buf; | 135 | name = buf; |
136 | while(n) { | 136 | while (n) { |
137 | if(((unsigned char)*name) < ' ') | 137 | if (((unsigned char)*name) < ' ') |
138 | *name = ' '; | 138 | *name = ' '; |
139 | name++; | 139 | name++; |
140 | n--; | 140 | n--; |
141 | } | 141 | } |
142 | *name = 0; | 142 | *name = 0; |
143 | if(buf[0]) | 143 | if (buf[0]) |
144 | curstatus.cmd = strdup(buf); | 144 | curstatus.cmd = strdup(buf); |
145 | /* if NULL it work true also */ | 145 | /* if NULL it work true also */ |
146 | } | 146 | } |