diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-14 15:28:15 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-14 15:28:15 +0000 |
| commit | d3a422a3b12e43db1ceaf6fb596bc2c4cf20d620 (patch) | |
| tree | a8254e4f52edcdd333bf082477cc80449a61594b | |
| parent | 94dfc57fdb01d9a85deb1283efbcb8ea5d2f60ff (diff) | |
| download | busybox-w32-d3a422a3b12e43db1ceaf6fb596bc2c4cf20d620.tar.gz busybox-w32-d3a422a3b12e43db1ceaf6fb596bc2c4cf20d620.tar.bz2 busybox-w32-d3a422a3b12e43db1ceaf6fb596bc2c4cf20d620.zip | |
Cleanup patch from Tito.
git-svn-id: svn://busybox.net/trunk/busybox@11458 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | util-linux/readprofile.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c index 95635801f..5144de711 100644 --- a/util-linux/readprofile.c +++ b/util-linux/readprofile.c | |||
| @@ -138,8 +138,6 @@ int readprofile_main(int argc, char **argv) | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | fd = bb_xopen(defaultpro,O_WRONLY); | 140 | fd = bb_xopen(defaultpro,O_WRONLY); |
| 141 | if (fd < 0) | ||
| 142 | bb_perror_msg_and_die(defaultpro); | ||
| 143 | 141 | ||
| 144 | if (write(fd, &multiplier, to_write) != to_write) | 142 | if (write(fd, &multiplier, to_write) != to_write) |
| 145 | bb_perror_msg_and_die("error writing %s", defaultpro); | 143 | bb_perror_msg_and_die("error writing %s", defaultpro); |
| @@ -151,13 +149,14 @@ int readprofile_main(int argc, char **argv) | |||
| 151 | /* | 149 | /* |
| 152 | * Use an fd for the profiling buffer, to skip stdio overhead | 150 | * Use an fd for the profiling buffer, to skip stdio overhead |
| 153 | */ | 151 | */ |
| 154 | if (((proFd = bb_xopen(proFile,O_RDONLY)) < 0) | 152 | |
| 155 | || ((int)(len=lseek(proFd,0,SEEK_END)) < 0) | 153 | proFd = bb_xopen(proFile,O_RDONLY); |
| 154 | |||
| 155 | if (((int)(len=lseek(proFd,0,SEEK_END)) < 0) | ||
| 156 | || (lseek(proFd,0,SEEK_SET) < 0)) | 156 | || (lseek(proFd,0,SEEK_SET) < 0)) |
| 157 | bb_perror_msg_and_die(proFile); | 157 | bb_perror_msg_and_die(proFile); |
| 158 | 158 | ||
| 159 | if (!(buf = xmalloc(len))) | 159 | buf = xmalloc(len); |
| 160 | bb_perror_nomsg_and_die(); | ||
| 161 | 160 | ||
| 162 | if (read(proFd,buf,len) != len) | 161 | if (read(proFd,buf,len) != len) |
| 163 | bb_perror_msg_and_die(proFile); | 162 | bb_perror_msg_and_die(proFile); |
| @@ -176,8 +175,8 @@ int readprofile_main(int argc, char **argv) | |||
| 176 | small++; | 175 | small++; |
| 177 | } | 176 | } |
| 178 | if (big > small) { | 177 | if (big > small) { |
| 179 | fprintf(stderr,"Assuming reversed byte order. " | 178 | bb_error_msg("Assuming reversed byte order. " |
| 180 | "Use -n to force native byte order.\n"); | 179 | "Use -n to force native byte order."); |
| 181 | for (p = buf; p < buf+entries; p++) | 180 | for (p = buf; p < buf+entries; p++) |
| 182 | for (i = 0; i < sizeof(*buf)/2; i++) { | 181 | for (i = 0; i < sizeof(*buf)/2; i++) { |
| 183 | unsigned char *b = (unsigned char *) p; | 182 | unsigned char *b = (unsigned char *) p; |
| @@ -199,8 +198,6 @@ int readprofile_main(int argc, char **argv) | |||
| 199 | total = 0; | 198 | total = 0; |
| 200 | 199 | ||
| 201 | map = bb_xfopen(mapFile, "r"); | 200 | map = bb_xfopen(mapFile, "r"); |
| 202 | if (map == NULL) | ||
| 203 | bb_perror_msg_and_die(mapFile); | ||
| 204 | 201 | ||
| 205 | while (fgets(mapline,S_LEN,map)) { | 202 | while (fgets(mapline,S_LEN,map)) { |
| 206 | if (sscanf(mapline,"%llx %s %s",&fn_add,mode,fn_name) != 3) | 203 | if (sscanf(mapline,"%llx %s %s",&fn_add,mode,fn_name) != 3) |
| @@ -215,7 +212,7 @@ int readprofile_main(int argc, char **argv) | |||
| 215 | } | 212 | } |
| 216 | 213 | ||
| 217 | if (!add0) | 214 | if (!add0) |
| 218 | bb_error_msg_and_die("can't find \"_stext\" in %s\n", mapFile); | 215 | bb_error_msg_and_die("can't find \"_stext\" in %s", mapFile); |
| 219 | 216 | ||
| 220 | /* | 217 | /* |
| 221 | * Main loop. | 218 | * Main loop. |
| @@ -224,7 +221,7 @@ int readprofile_main(int argc, char **argv) | |||
| 224 | unsigned int this = 0; | 221 | unsigned int this = 0; |
| 225 | 222 | ||
| 226 | if (sscanf(mapline,"%llx %s %s",&next_add,mode,next_name) != 3) | 223 | if (sscanf(mapline,"%llx %s %s",&next_add,mode,next_name) != 3) |
| 227 | bb_error_msg_and_die("%s(%i): wrong map line\n", | 224 | bb_error_msg_and_die("%s(%i): wrong map line", |
| 228 | mapFile, maplineno); | 225 | mapFile, maplineno); |
| 229 | 226 | ||
| 230 | header_printed = 0; | 227 | header_printed = 0; |
