diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-04-15 14:58:15 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-04-15 15:05:38 +0200 |
commit | 9d699b790cfc3afa6766a1d047def724cc42386e (patch) | |
tree | 598916fa36ae96b851e20e6543d7912a5db0ac28 /net | |
parent | 3f732effd575831a21708dd8a4e2161a4f411f71 (diff) | |
download | barebox-9d699b790cfc3afa6766a1d047def724cc42386e.tar.gz barebox-9d699b790cfc3afa6766a1d047def724cc42386e.tar.xz |
net: use static string in string_to_ip
Simplify usage of ip_to_string by using a static string.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/net.c | 14 | ||||
-rw-r--r-- | net/tftp.c | 3 |
2 files changed, 7 insertions, 10 deletions
@@ -85,8 +85,10 @@ uint16_t net_checksum(unsigned char *ptr, int len) return xsum & 0xffff; } -char *ip_to_string (IPaddr_t x, char *s) +char *ip_to_string (IPaddr_t x) { + static char s[sizeof("xxx.xxx.xxx.xxx")]; + x = ntohl (x); sprintf (s, "%d.%d.%d.%d", (int) ((x >> 24) & 0xff), @@ -146,9 +148,9 @@ IPaddr_t getenv_ip_dns(const char *name, int dns) int setenv_ip(const char *name, IPaddr_t ip) { - char str[sizeof("xxx.xxx.xxx.xxx")]; + const char *str; - ip_to_string(ip, str); + str = ip_to_string(ip); setenv(name, str); @@ -157,11 +159,7 @@ int setenv_ip(const char *name, IPaddr_t ip) void print_IPaddr (IPaddr_t x) { - char tmp[16]; - - ip_to_string (x, tmp); - - puts (tmp); + puts(ip_to_string(x)); } int string_to_ethaddr(const char *str, char *enetaddr) diff --git a/net/tftp.c b/net/tftp.c index fc33c94583..ca12638353 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -273,7 +273,6 @@ static void tftp_handler(void *ctx, char *packet, unsigned len) static int do_tftpb(int argc, char *argv[]) { char *localfile, *remotefile, *file1, *file2; - char ip1[16]; int opt; struct stat s; unsigned long flags; @@ -328,7 +327,7 @@ static int do_tftpb(int argc, char *argv[]) printf("TFTP %s server %s ('%s' -> '%s')\n", tftp_push ? "to" : "from", - ip_to_string(net_get_serverip(), ip1), + ip_to_string(net_get_serverip()), file1, file2); init_progression_bar(tftp_push ? s.st_size : 0); |