Fix kbuild bugs noticed by Bernhard Fischer <rep.nop@aon.at>
[oweals/busybox.git] / networking / tftp.c
index b0572c89009c676088b4db32733a3f315eefa5da..6213d662271a2d6698312ecb347a5c78b44daa46 100644 (file)
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  * ------------------------------------------------------------------------- */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <fcntl.h>
-
 #include "busybox.h"
 
 
@@ -159,7 +147,7 @@ static int tftp(const int cmd, const struct hostent *host,
        char *buf=xmalloc(tftp_bufsize += 4);
 
        if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
-               /* need to unlink the localfile, so don't use bb_xsocket here. */
+               /* need to unlink the localfile, so don't use xsocket here. */
                bb_perror_msg("socket");
                return EXIT_FAILURE;
        }
@@ -167,7 +155,7 @@ static int tftp(const int cmd, const struct hostent *host,
        len = sizeof(sa);
 
        memset(&sa, 0, len);
-       bb_xbind(socketfd, (struct sockaddr *)&sa, len);
+       xbind(socketfd, (struct sockaddr *)&sa, len);
 
        sa.sin_family = host->h_addrtype;
        sa.sin_port = port;
@@ -249,7 +237,7 @@ static int tftp(const int cmd, const struct hostent *host,
                        block_nr++;
 
                        if ((cmd & tftp_cmd_put) && (opcode == TFTP_DATA)) {
-                               len = bb_full_read(localfd, cp, tftp_bufsize - 4);
+                               len = full_read(localfd, cp, tftp_bufsize - 4);
 
                                if (len < 0) {
                                        bb_perror_msg(bb_msg_read_error);
@@ -385,7 +373,7 @@ static int tftp(const int cmd, const struct hostent *host,
                                res = tftp_option_get(&buf[2], len - 2, OPTION_BLOCKSIZE);
 
                                if (res) {
-                                       int blksize = atoi(res);
+                                       int blksize = xatoi_u(res);
 
                                        if (tftp_blocksize_check(blksize, tftp_bufsize - 4)) {
 
@@ -420,7 +408,7 @@ static int tftp(const int cmd, const struct hostent *host,
 
                        if (tmp == block_nr) {
 
-                               len = bb_full_write(localfd, &buf[4], len - 4);
+                               len = full_write(localfd, &buf[4], len - 4);
 
                                if (len < 0) {
                                        bb_perror_msg(bb_msg_write_error);
@@ -509,14 +497,12 @@ int tftp_main(int argc, char **argv)
 #endif
 
 #if defined(CONFIG_FEATURE_TFTP_GET) && defined(CONFIG_FEATURE_TFTP_PUT)
-       bb_opt_complementally = GET_COMPL PUT_COMPL ":?g--p:p--g";
+       opt_complementary = GET_COMPL PUT_COMPL ":?g--p:p--g";
 #elif defined(CONFIG_FEATURE_TFTP_GET) || defined(CONFIG_FEATURE_TFTP_PUT)
-       bb_opt_complementally = GET_COMPL PUT_COMPL;
+       opt_complementary = GET_COMPL PUT_COMPL;
 #endif
 
-
-       cmd = bb_getopt_ulflags(argc, argv, GET PUT "l:r:" BS,
-                                                       &localfile, &remotefile BS_ARG);
+       cmd = getopt32(argc, argv, GET PUT "l:r:" BS, &localfile, &remotefile BS_ARG);
 
        cmd &= (tftp_cmd_get | tftp_cmd_put);
 #ifdef CONFIG_FEATURE_TFTP_GET
@@ -530,7 +516,7 @@ int tftp_main(int argc, char **argv)
 
 #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
        if (sblocksize) {
-               blocksize = atoi(sblocksize);
+               blocksize = xatoi_u(sblocksize);
                if (!tftp_blocksize_check(blocksize, 0)) {
                        return EXIT_FAILURE;
                }
@@ -571,5 +557,5 @@ int tftp_main(int argc, char **argv)
                if (cmd == tftp_cmd_get && result != EXIT_SUCCESS)
                        unlink(localfile);
        }
-       return (result);
+       return result;
 }