summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-14 02:23:43 +0000
committerDenis Vlasenko2006-10-14 02:23:43 +0000
commitea62077b850076c4d7dc3cf78ebd1888928c6ddf (patch)
tree37b7584ae40b99edb5583fbc4392b62ffdadf278 /networking
parent88ca06769028e442bf873b270c176ca0e9f021f8 (diff)
downloadbusybox-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.zip
busybox-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.gz
add open_read_close() and similar stuff
Diffstat (limited to 'networking')
-rw-r--r--networking/fakeidentd.c2
-rw-r--r--networking/ftpgetput.c2
-rw-r--r--networking/inetd.c2
-rw-r--r--networking/libiproute/libnetlink.c2
-rw-r--r--networking/netstat.c8
-rw-r--r--networking/traceroute.c8
-rw-r--r--networking/udhcp/arpping.c2
-rw-r--r--networking/udhcp/clientpacket.c7
-rw-r--r--networking/udhcp/options.c2
-rw-r--r--networking/udhcp/signalpipe.c2
-rw-r--r--networking/wget.c4
11 files changed, 19 insertions, 22 deletions
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c
index c8d3276..18e86c5 100644
--- a/networking/fakeidentd.c
+++ b/networking/fakeidentd.c
@@ -140,7 +140,7 @@ static int godaemon(void)
case 0:
pw = getpwnam(nobodystr);
if (pw == NULL)
- bb_error_msg_and_die("Cannot find uid/gid of user '%s'", nobodystr);
+ bb_error_msg_and_die("cannot find uid/gid of user '%s'", nobodystr);
nobody = pw->pw_uid;
nogrp = pw->pw_gid;
writepid(nobody, nogrp);
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 47126ee..aafeaf6 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -166,7 +166,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
if (do_continue) {
fd_local = xopen(local_path, O_APPEND | O_WRONLY);
} else {
- fd_local = xopen3(local_path, O_CREAT | O_TRUNC | O_WRONLY, 0777);
+ fd_local = xopen3(local_path, O_CREAT | O_TRUNC | O_WRONLY, 0666);
}
}
diff --git a/networking/inetd.c b/networking/inetd.c
index 9664253..75b2b14 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1371,7 +1371,7 @@ inetd_main(int argc, char *argv[])
socklen_t plen = sizeof(peer);
if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) {
- bb_error_msg("could not getpeername");
+ bb_error_msg("cannot getpeername");
close(ctrl);
continue;
}
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c
index de11d9d..a595e96 100644
--- a/networking/libiproute/libnetlink.c
+++ b/networking/libiproute/libnetlink.c
@@ -126,7 +126,7 @@ int rtnl_dump_filter(struct rtnl_handle *rth,
int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
void *arg2)
{
- char buf[8192];
+ char buf[8192];
struct sockaddr_nl nladdr;
struct iovec iov = { buf, sizeof(buf) };
diff --git a/networking/netstat.c b/networking/netstat.c
index bc5c619..8e481f6 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -496,7 +496,6 @@ static void unix_do_one(int nr, const char *line)
static void do_info(const char *file, const char *name, void (*proc)(int, const char *))
{
- char buffer[8192];
int lnr = 0;
FILE *procinfo;
@@ -505,12 +504,15 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const
if (errno != ENOENT) {
perror(file);
} else {
- bb_error_msg("no support for `%s' on this system", name);
+ bb_error_msg("no support for '%s' on this system", name);
}
} else {
do {
- if (fgets(buffer, sizeof(buffer), procinfo))
+ char *buffer = xmalloc_fgets(procinfo);
+ if (buffer) {
(proc)(lnr++, buffer);
+ free(buffer);
+ }
} while (!feof(procinfo));
fclose(procinfo);
}
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 84ce8ae..3b59063 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -417,7 +417,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
++nipaddr;
}
if (nipaddr == 0)
- bb_error_msg_and_die ("Can't find any network interfaces");
+ bb_error_msg_and_die ("can't find any network interfaces");
(void)close(fd);
*ipaddrp = st_ifaddrlist;
@@ -472,7 +472,7 @@ findsaddr(const struct sockaddr_in *to, struct sockaddr_in *from)
fclose(f);
if (device[0] == '\0')
- bb_error_msg_and_die ("Can't find interface");
+ bb_error_msg_and_die ("can't find interface");
/* Get the interface address list */
n = ifaddrlist(&al);
@@ -482,7 +482,7 @@ findsaddr(const struct sockaddr_in *to, struct sockaddr_in *from)
if (strcmp(device, al->device) == 0)
break;
if (i <= 0)
- bb_error_msg_and_die("Can't find interface %s", device);
+ bb_error_msg_and_die("can't find interface %s", device);
setsin(from, al->addr);
}
@@ -1156,7 +1156,7 @@ traceroute_main(int argc, char *argv[])
if (strcmp(device, al->device) == 0)
break;
if (i <= 0) {
- bb_error_msg_and_die("Can't find interface %s", device);
+ bb_error_msg_and_die("can't find interface %s", device);
}
}
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 587339f..0866920 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -49,7 +49,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
}
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) {
- bb_perror_msg("Could not setsocketopt on raw socket");
+ bb_perror_msg("cannot setsocketopt on raw socket");
close(s);
return -1;
}
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index f9f5a3b..439aa02 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -39,16 +39,13 @@ unsigned long random_xid(void)
{
static int initialized;
if (!initialized) {
- int fd;
unsigned long seed;
- fd = open("/dev/urandom", 0);
- if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) {
- bb_info_msg("Could not load seed "
+ if (open_read_close("/dev/urandom", &seed, sizeof(seed)) < 0) {
+ bb_info_msg("Cannot load seed "
"from /dev/urandom: %s", strerror(errno));
seed = time(0);
}
- if (fd >= 0) close(fd);
srand(seed);
initialized++;
}
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index ded0f7b..8dba2ef 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -171,6 +171,6 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
}
}
- bb_error_msg("Could not add option 0x%02x", code);
+ bb_error_msg("cannot add option 0x%02x", code);
return 0;
}
diff --git a/networking/udhcp/signalpipe.c b/networking/udhcp/signalpipe.c
index 6c4a9f1..bece419 100644
--- a/networking/udhcp/signalpipe.c
+++ b/networking/udhcp/signalpipe.c
@@ -36,7 +36,7 @@ static int signal_pipe[2];
static void signal_handler(int sig)
{
if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0)
- bb_perror_msg("Could not send signal");
+ bb_perror_msg("cannot send signal");
}
diff --git a/networking/wget.c b/networking/wget.c
index 264ae44..7a931f3 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -219,9 +219,7 @@ int wget_main(int argc, char **argv)
} else if (opt & WGET_OPT_CONTINUE) {
output_fd = open(fname_out, O_WRONLY);
if (output_fd >= 0) {
- beg_range = lseek(output_fd, 0, SEEK_END);
- if (beg_range == (off_t)-1)
- bb_perror_msg_and_die("lseek");
+ beg_range = xlseek(output_fd, 0, SEEK_END);
}
/* File doesn't exist. We do not create file here yet.
We are not sure it exists on remove side */