diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-08 17:40:23 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-08 17:40:23 +0000 |
commit | abbd363261cf3a9b18e611c524f8103fb68f539b (patch) | |
tree | 33545409717701ac3cc40d2a60f80a697835620c | |
parent | 53bd4015aa7ec79b8f45edd30555ea7b7235d7ca (diff) | |
download | busybox-w32-abbd363261cf3a9b18e611c524f8103fb68f539b.tar.gz busybox-w32-abbd363261cf3a9b18e611c524f8103fb68f539b.tar.bz2 busybox-w32-abbd363261cf3a9b18e611c524f8103fb68f539b.zip |
xreadlink: code shrink
udhcp: add missing tryagain member to client_config
function old new delta
xmalloc_readlink_follow 169 154 -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15) Total: -15 bytes
-rw-r--r-- | libbb/xreadlink.c | 35 | ||||
-rw-r--r-- | loginutils/login.c | 3 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 |
3 files changed, 20 insertions, 19 deletions
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index 2f6b1e237..f7948cbf3 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
@@ -41,14 +41,21 @@ char *xmalloc_readlink(const char *path) | |||
41 | */ | 41 | */ |
42 | char *xmalloc_readlink_follow(const char *path) | 42 | char *xmalloc_readlink_follow(const char *path) |
43 | { | 43 | { |
44 | char *buf = NULL, *lpc, *linkpath; | 44 | char *buf; |
45 | char *lpc; | ||
46 | char *linkpath; | ||
45 | int bufsize; | 47 | int bufsize; |
46 | smallint looping = 0; | 48 | int looping = MAXSYMLINKS + 1; |
47 | 49 | ||
48 | buf = strdup(path); | 50 | linkpath = xstrdup(path); |
49 | bufsize = strlen(path) + 1; | 51 | goto jump_in; |
50 | 52 | ||
51 | while(1) { | 53 | while (1) { |
54 | if (!--looping) { | ||
55 | free(linkpath); | ||
56 | free(buf); | ||
57 | return NULL; | ||
58 | } | ||
52 | linkpath = xmalloc_readlink(buf); | 59 | linkpath = xmalloc_readlink(buf); |
53 | if (!linkpath) { | 60 | if (!linkpath) { |
54 | if (errno == EINVAL) /* not a symlink */ | 61 | if (errno == EINVAL) /* not a symlink */ |
@@ -56,25 +63,19 @@ char *xmalloc_readlink_follow(const char *path) | |||
56 | free(buf); | 63 | free(buf); |
57 | return NULL; | 64 | return NULL; |
58 | } | 65 | } |
59 | 66 | if (linkpath[0] != '/') { | |
60 | if (*linkpath == '/') { | ||
61 | free(buf); | ||
62 | buf = linkpath; | ||
63 | bufsize = strlen(linkpath) + 1; | ||
64 | } else { | ||
65 | bufsize += strlen(linkpath); | 67 | bufsize += strlen(linkpath); |
66 | if (looping++ > MAXSYMLINKS) { | ||
67 | free(linkpath); | ||
68 | free(buf); | ||
69 | return NULL; | ||
70 | } | ||
71 | buf = xrealloc(buf, bufsize); | 68 | buf = xrealloc(buf, bufsize); |
72 | lpc = bb_get_last_path_component_strip(buf); | 69 | lpc = bb_get_last_path_component_strip(buf); |
73 | strcpy(lpc, linkpath); | 70 | strcpy(lpc, linkpath); |
74 | free(linkpath); | 71 | free(linkpath); |
72 | } else { | ||
73 | free(buf); | ||
74 | jump_in: | ||
75 | buf = linkpath; | ||
76 | bufsize = strlen(buf) + 1; | ||
75 | } | 77 | } |
76 | } | 78 | } |
77 | |||
78 | } | 79 | } |
79 | 80 | ||
80 | char *xmalloc_readlink_or_warn(const char *path) | 81 | char *xmalloc_readlink_or_warn(const char *path) |
diff --git a/loginutils/login.c b/loginutils/login.c index c1e0c7699..7e9044654 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -305,9 +305,8 @@ int login_main(int argc, char **argv) | |||
305 | openlog(applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); | 305 | openlog(applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); |
306 | 306 | ||
307 | while (1) { | 307 | while (1) { |
308 | |||
309 | /* flush away any type-ahead (as getty does) */ | 308 | /* flush away any type-ahead (as getty does) */ |
310 | (void) ioctl(0, TCFLSH, TCIFLUSH); | 309 | ioctl(0, TCFLSH, TCIFLUSH); |
311 | 310 | ||
312 | if (!username[0]) | 311 | if (!username[0]) |
313 | get_username_or_die(username, sizeof(username)); | 312 | get_username_or_die(username, sizeof(username)); |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 8da1dd8e1..72a8bd94f 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -30,6 +30,7 @@ struct client_config_t { | |||
30 | int ifindex; /* Index number of the interface to use */ | 30 | int ifindex; /* Index number of the interface to use */ |
31 | int retries; /* Max number of request packets */ | 31 | int retries; /* Max number of request packets */ |
32 | int timeout; /* Number of seconds to try to get a lease */ | 32 | int timeout; /* Number of seconds to try to get a lease */ |
33 | int tryagain; /* Number of seconds to try to get a lease */ | ||
33 | uint8_t arp[6]; /* Our arp address */ | 34 | uint8_t arp[6]; /* Our arp address */ |
34 | }; | 35 | }; |
35 | 36 | ||