safe_strtoXX interface proved to be a bit unconvenient.
Remove it, introduce saner bb_strtoXX. Saved ~350 bytes.
This commit is contained in:
@@ -124,7 +124,8 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
|
||||
fd_data = xconnect_ftpdata(server, buf);
|
||||
|
||||
if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
|
||||
if (SAFE_STRTOOFF(buf + 4, &filesize))
|
||||
filesize = BB_STRTOOFF(buf + 4, NULL, 10);
|
||||
if (errno || filesize < 0)
|
||||
bb_error_msg_and_die("SIZE error: %s", buf + 4);
|
||||
} else {
|
||||
filesize = -1;
|
||||
|
@@ -64,7 +64,8 @@ static int read_str(const char *line, void *arg)
|
||||
|
||||
static int read_u32(const char *line, void *arg)
|
||||
{
|
||||
return safe_strtou32(line, (uint32_t*)arg) == 0;
|
||||
*((uint32_t*)arg) = bb_strtou32(line, NULL, 10);
|
||||
return errno == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +102,8 @@ static void attach_option(struct option_set **opt_list,
|
||||
struct option_set *existing, *new, **curr;
|
||||
|
||||
/* add it to an existing option */
|
||||
if ((existing = find_option(*opt_list, option->code))) {
|
||||
existing = find_option(*opt_list, option->code);
|
||||
if (existing) {
|
||||
DEBUG("Attaching option %s to existing member of list", option->name);
|
||||
if (option->flags & OPTION_LIST) {
|
||||
if (existing->data[OPT_LEN] + length <= 255) {
|
||||
|
@@ -335,7 +335,8 @@ int wget_main(int argc, char **argv)
|
||||
*/
|
||||
while ((s = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) {
|
||||
if (strcasecmp(buf, "content-length") == 0) {
|
||||
if (SAFE_STRTOOFF(s, &content_len) || content_len < 0) {
|
||||
content_len = BB_STRTOOFF(s, NULL, 10);
|
||||
if (errno || content_len < 0) {
|
||||
bb_error_msg_and_die("content-length %s is garbage", s);
|
||||
}
|
||||
got_clen = 1;
|
||||
@@ -402,7 +403,8 @@ int wget_main(int argc, char **argv)
|
||||
* Querying file size
|
||||
*/
|
||||
if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) {
|
||||
if (SAFE_STRTOOFF(buf+4, &content_len) || content_len < 0) {
|
||||
content_len = BB_STRTOOFF(buf+4, NULL, 10);
|
||||
if (errno || content_len < 0) {
|
||||
bb_error_msg_and_die("SIZE value is garbage");
|
||||
}
|
||||
got_clen = 1;
|
||||
@@ -437,7 +439,7 @@ int wget_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (ftpcmd("RETR ", target.path, sfp, buf) > 150)
|
||||
bb_error_msg_and_die("bad response to %s: %s", "RETR", buf);
|
||||
bb_error_msg_and_die("bad response to RETR: %s", buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -446,7 +448,7 @@ int wget_main(int argc, char **argv)
|
||||
*/
|
||||
if (chunked) {
|
||||
fgets(buf, sizeof(buf), dfp);
|
||||
content_len = STRTOOFF(buf, (char **) NULL, 16);
|
||||
content_len = STRTOOFF(buf, NULL, 16);
|
||||
/* FIXME: error check?? */
|
||||
}
|
||||
|
||||
@@ -480,7 +482,7 @@ int wget_main(int argc, char **argv)
|
||||
if (chunked) {
|
||||
safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */
|
||||
safe_fgets(buf, sizeof(buf), dfp);
|
||||
content_len = STRTOOFF(buf, (char **) NULL, 16);
|
||||
content_len = STRTOOFF(buf, NULL, 16);
|
||||
/* FIXME: error check? */
|
||||
if (content_len == 0) {
|
||||
chunked = 0; /* all done! */
|
||||
|
Reference in New Issue
Block a user