diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-01 10:25:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-01 10:25:35 +0000 |
commit | 92258541449581302e180d05e827e27d35030a18 (patch) | |
tree | 99c5ad443f69860833c8ef37e142fddfedb90872 /util-linux/readprofile.c | |
parent | 048c93cc5593d53d6243c3e15dc8a5b0072a6083 (diff) | |
download | busybox-w32-92258541449581302e180d05e827e27d35030a18.tar.gz busybox-w32-92258541449581302e180d05e827e27d35030a18.tar.bz2 busybox-w32-92258541449581302e180d05e827e27d35030a18.zip |
mostly style fixes
Diffstat (limited to 'util-linux/readprofile.c')
-rw-r--r-- | util-linux/readprofile.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c index e635f6bf3..dd810f021 100644 --- a/util-linux/readprofile.c +++ b/util-linux/readprofile.c | |||
@@ -44,19 +44,20 @@ static const char defaultpro[] = "/proc/profile"; | |||
44 | int readprofile_main(int argc, char **argv) | 44 | int readprofile_main(int argc, char **argv) |
45 | { | 45 | { |
46 | FILE *map; | 46 | FILE *map; |
47 | const char *mapFile, *proFile, *mult=0; | 47 | const char *mapFile, *proFile, *mult = 0; |
48 | unsigned long indx=1; | 48 | unsigned long indx = 1; |
49 | size_t len; | 49 | size_t len; |
50 | uint64_t add0=0; | 50 | uint64_t add0 = 0; |
51 | unsigned int step; | 51 | unsigned int step; |
52 | unsigned int *buf, total, fn_len; | 52 | unsigned int *buf, total, fn_len; |
53 | unsigned long long fn_add, next_add; /* current and next address */ | 53 | unsigned long long fn_add, next_add; /* current and next address */ |
54 | char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */ | 54 | char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */ |
55 | char mode[8]; | ||
56 | int optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0; | ||
57 | int optBins=0, optSub=0; | ||
58 | char mapline[S_LEN]; | 55 | char mapline[S_LEN]; |
59 | int maplineno=1; | 56 | char mode[8]; |
57 | int optAll = 0, optInfo = 0, optReset = 0; | ||
58 | int optVerbose = 0, optNative = 0; | ||
59 | int optBins = 0, optSub = 0; | ||
60 | int maplineno = 1; | ||
60 | int header_printed; | 61 | int header_printed; |
61 | 62 | ||
62 | #define next (current^1) | 63 | #define next (current^1) |
@@ -85,9 +86,9 @@ int readprofile_main(int argc, char **argv) | |||
85 | to_write = 1; /* sth different from sizeof(int) */ | 86 | to_write = 1; /* sth different from sizeof(int) */ |
86 | } | 87 | } |
87 | 88 | ||
88 | fd = xopen(defaultpro,O_WRONLY); | 89 | fd = xopen(defaultpro, O_WRONLY); |
89 | 90 | ||
90 | if (write(fd, &multiplier, to_write) != to_write) | 91 | if (full_write(fd, &multiplier, to_write) != to_write) |
91 | bb_perror_msg_and_die("error writing %s", defaultpro); | 92 | bb_perror_msg_and_die("error writing %s", defaultpro); |
92 | 93 | ||
93 | close(fd); | 94 | close(fd); |
@@ -101,7 +102,7 @@ int readprofile_main(int argc, char **argv) | |||
101 | buf = xmalloc_open_read_close(proFile, &len); | 102 | buf = xmalloc_open_read_close(proFile, &len); |
102 | if (!optNative) { | 103 | if (!optNative) { |
103 | int entries = len/sizeof(*buf); | 104 | int entries = len/sizeof(*buf); |
104 | int big = 0,small = 0,i; | 105 | int big = 0, small = 0, i; |
105 | unsigned *p; | 106 | unsigned *p; |
106 | 107 | ||
107 | for (p = buf+1; p < buf+entries; p++) { | 108 | for (p = buf+1; p < buf+entries; p++) { |
@@ -135,12 +136,12 @@ int readprofile_main(int argc, char **argv) | |||
135 | 136 | ||
136 | map = xfopen(mapFile, "r"); | 137 | map = xfopen(mapFile, "r"); |
137 | 138 | ||
138 | while (fgets(mapline,S_LEN,map)) { | 139 | while (fgets(mapline, S_LEN, map)) { |
139 | if (sscanf(mapline,"%llx %s %s",&fn_add,mode,fn_name) != 3) | 140 | if (sscanf(mapline, "%llx %s %s", &fn_add, mode, fn_name) != 3) |
140 | bb_error_msg_and_die("%s(%i): wrong map line", | 141 | bb_error_msg_and_die("%s(%i): wrong map line", |
141 | mapFile, maplineno); | 142 | mapFile, maplineno); |
142 | 143 | ||
143 | if (!strcmp(fn_name,"_stext")) /* only elf works like this */ { | 144 | if (!strcmp(fn_name, "_stext")) /* only elf works like this */ { |
144 | add0 = fn_add; | 145 | add0 = fn_add; |
145 | break; | 146 | break; |
146 | } | 147 | } |
@@ -153,12 +154,12 @@ int readprofile_main(int argc, char **argv) | |||
153 | /* | 154 | /* |
154 | * Main loop. | 155 | * Main loop. |
155 | */ | 156 | */ |
156 | while (fgets(mapline,S_LEN,map)) { | 157 | while (fgets(mapline, S_LEN, map)) { |
157 | unsigned int this = 0; | 158 | unsigned int this = 0; |
158 | 159 | ||
159 | if (sscanf(mapline,"%llx %s %s",&next_add,mode,next_name) != 3) | 160 | if (sscanf(mapline, "%llx %s %s", &next_add, mode, next_name) != 3) |
160 | bb_error_msg_and_die("%s(%i): wrong map line", | 161 | bb_error_msg_and_die("%s(%i): wrong map line", |
161 | mapFile, maplineno); | 162 | mapFile, maplineno); |
162 | 163 | ||
163 | header_printed = 0; | 164 | header_printed = 0; |
164 | 165 | ||
@@ -176,10 +177,10 @@ int readprofile_main(int argc, char **argv) | |||
176 | while (indx < (next_add-add0)/step) { | 177 | while (indx < (next_add-add0)/step) { |
177 | if (optBins && (buf[indx] || optAll)) { | 178 | if (optBins && (buf[indx] || optAll)) { |
178 | if (!header_printed) { | 179 | if (!header_printed) { |
179 | printf ("%s:\n", fn_name); | 180 | printf("%s:\n", fn_name); |
180 | header_printed = 1; | 181 | header_printed = 1; |
181 | } | 182 | } |
182 | printf ("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]); | 183 | printf("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]); |
183 | } | 184 | } |
184 | this += buf[indx++]; | 185 | this += buf[indx++]; |
185 | } | 186 | } |
@@ -187,15 +188,15 @@ int readprofile_main(int argc, char **argv) | |||
187 | 188 | ||
188 | if (optBins) { | 189 | if (optBins) { |
189 | if (optVerbose || this > 0) | 190 | if (optVerbose || this > 0) |
190 | printf (" total\t\t\t\t%u\n", this); | 191 | printf(" total\t\t\t\t%u\n", this); |
191 | } else if ((this || optAll) && | 192 | } else if ((this || optAll) && |
192 | (fn_len = next_add-fn_add) != 0) { | 193 | (fn_len = next_add-fn_add) != 0) { |
193 | if (optVerbose) | 194 | if (optVerbose) |
194 | printf("%016llx %-40s %6i %8.4f\n", fn_add, | 195 | printf("%016llx %-40s %6i %8.4f\n", fn_add, |
195 | fn_name,this,this/(double)fn_len); | 196 | fn_name, this, this/(double)fn_len); |
196 | else | 197 | else |
197 | printf("%6i %-40s %8.4f\n", | 198 | printf("%6i %-40s %8.4f\n", |
198 | this,fn_name,this/(double)fn_len); | 199 | this, fn_name, this/(double)fn_len); |
199 | if (optSub) { | 200 | if (optSub) { |
200 | unsigned long long scan; | 201 | unsigned long long scan; |
201 | 202 | ||
@@ -212,7 +213,7 @@ int readprofile_main(int argc, char **argv) | |||
212 | } | 213 | } |
213 | 214 | ||
214 | fn_add = next_add; | 215 | fn_add = next_add; |
215 | strcpy(fn_name,next_name); | 216 | strcpy(fn_name, next_name); |
216 | 217 | ||
217 | maplineno++; | 218 | maplineno++; |
218 | } | 219 | } |
@@ -223,10 +224,10 @@ int readprofile_main(int argc, char **argv) | |||
223 | /* trailer */ | 224 | /* trailer */ |
224 | if (optVerbose) | 225 | if (optVerbose) |
225 | printf("%016x %-40s %6i %8.4f\n", | 226 | printf("%016x %-40s %6i %8.4f\n", |
226 | 0,"total",total,total/(double)(fn_add-add0)); | 227 | 0, "total", total, total/(double)(fn_add-add0)); |
227 | else | 228 | else |
228 | printf("%6i %-40s %8.4f\n", | 229 | printf("%6i %-40s %8.4f\n", |
229 | total,"total",total/(double)(fn_add-add0)); | 230 | total, "total", total/(double)(fn_add-add0)); |
230 | 231 | ||
231 | fclose(map); | 232 | fclose(map); |
232 | free(buf); | 233 | free(buf); |