libbb: reduce the overhead of single parameter bb_error_msg() calls

Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
James Byrne
2019-07-02 11:35:03 +02:00
committed by Denys Vlasenko
parent caecfdc20d
commit 6937487be7
225 changed files with 845 additions and 736 deletions
+18 -18
View File
@@ -116,7 +116,7 @@ static int arp_del(char **args)
/* Resolve the host name. */
host = *args;
if (ap->input(host, &sa) < 0) {
bb_herror_msg_and_die("%s", host);
bb_simple_herror_msg_and_die(host);
}
/* If a host has more than one address, use the correct one! */
@@ -149,7 +149,7 @@ static int arp_del(char **args)
#ifdef HAVE_ATF_DONTPUB
req.arp_flags |= ATF_DONTPUB;
#else
bb_error_msg("feature ATF_DONTPUB is not supported");
bb_simple_error_msg("feature ATF_DONTPUB is not supported");
#endif
args++;
break;
@@ -157,7 +157,7 @@ static int arp_del(char **args)
#ifdef HAVE_ATF_MAGIC
req.arp_flags |= ATF_MAGIC;
#else
bb_error_msg("feature ATF_MAGIC is not supported");
bb_simple_error_msg("feature ATF_MAGIC is not supported");
#endif
args++;
break;
@@ -173,7 +173,7 @@ static int arp_del(char **args)
if (strcmp(*args, "255.255.255.255") != 0) {
host = *args;
if (ap->input(host, &sa) < 0) {
bb_herror_msg_and_die("%s", host);
bb_simple_herror_msg_and_die(host);
}
memcpy(&req.arp_netmask, &sa, sizeof(struct sockaddr));
req.arp_flags |= ATF_NETMASK;
@@ -195,7 +195,7 @@ static int arp_del(char **args)
/* Call the kernel. */
if (flags & 2) {
if (option_mask32 & ARP_OPT_v)
bb_error_msg("SIOCDARP(nopub)");
bb_simple_error_msg("SIOCDARP(nopub)");
err = ioctl(sockfd, SIOCDARP, &req);
if (err < 0) {
if (errno == ENXIO) {
@@ -204,20 +204,20 @@ static int arp_del(char **args)
printf("No ARP entry for %s\n", host);
return -1;
}
bb_perror_msg_and_die("SIOCDARP(priv)");
bb_simple_perror_msg_and_die("SIOCDARP(priv)");
}
}
if ((flags & 1) && err) {
nopub:
req.arp_flags |= ATF_PUBL;
if (option_mask32 & ARP_OPT_v)
bb_error_msg("SIOCDARP(pub)");
bb_simple_error_msg("SIOCDARP(pub)");
if (ioctl(sockfd, SIOCDARP, &req) < 0) {
if (errno == ENXIO) {
printf("No ARP entry for %s\n", host);
return -1;
}
bb_perror_msg_and_die("SIOCDARP(pub)");
bb_simple_perror_msg_and_die("SIOCDARP(pub)");
}
}
return 0;
@@ -233,7 +233,7 @@ static void arp_getdevhw(char *ifname, struct sockaddr *sa)
ioctl_or_perror_and_die(sockfd, SIOCGIFHWADDR, &ifr,
"can't get HW-Address for '%s'", ifname);
if (hw_set && (ifr.ifr_hwaddr.sa_family != hw->type)) {
bb_error_msg_and_die("protocol type mismatch");
bb_simple_error_msg_and_die("protocol type mismatch");
}
memcpy(sa, &(ifr.ifr_hwaddr), sizeof(struct sockaddr));
@@ -261,20 +261,20 @@ static int arp_set(char **args)
host = *args++;
if (ap->input(host, &sa) < 0) {
bb_herror_msg_and_die("%s", host);
bb_simple_herror_msg_and_die(host);
}
/* If a host has more than one address, use the correct one! */
memcpy(&req.arp_pa, &sa, sizeof(struct sockaddr));
/* Fetch the hardware address. */
if (*args == NULL) {
bb_error_msg_and_die("need hardware address");
bb_simple_error_msg_and_die("need hardware address");
}
if (option_mask32 & ARP_OPT_D) {
arp_getdevhw(*args++, &req.arp_ha);
} else {
if (hw->input(*args++, &req.arp_ha) < 0) {
bb_error_msg_and_die("invalid hardware address");
bb_simple_error_msg_and_die("invalid hardware address");
}
}
@@ -302,7 +302,7 @@ static int arp_set(char **args)
#ifdef HAVE_ATF_DONTPUB
flags |= ATF_DONTPUB;
#else
bb_error_msg("feature ATF_DONTPUB is not supported");
bb_simple_error_msg("feature ATF_DONTPUB is not supported");
#endif
args++;
break;
@@ -310,7 +310,7 @@ static int arp_set(char **args)
#ifdef HAVE_ATF_MAGIC
flags |= ATF_MAGIC;
#else
bb_error_msg("feature ATF_MAGIC is not supported");
bb_simple_error_msg("feature ATF_MAGIC is not supported");
#endif
args++;
break;
@@ -326,7 +326,7 @@ static int arp_set(char **args)
if (strcmp(*args, "255.255.255.255") != 0) {
host = *args;
if (ap->input(host, &sa) < 0) {
bb_herror_msg_and_die("%s", host);
bb_simple_herror_msg_and_die(host);
}
memcpy(&req.arp_netmask, &sa, sizeof(struct sockaddr));
flags |= ATF_NETMASK;
@@ -346,7 +346,7 @@ static int arp_set(char **args)
/* Call the kernel. */
if (option_mask32 & ARP_OPT_v)
bb_error_msg("SIOCSARP()");
bb_simple_error_msg("SIOCSARP()");
xioctl(sockfd, SIOCSARP, &req);
return 0;
}
@@ -422,7 +422,7 @@ static int arp_show(char *name)
if (name != NULL) {
/* Resolve the host name. */
if (ap->input(name, &sa) < 0) {
bb_herror_msg_and_die("%s", name);
bb_simple_herror_msg_and_die(name);
}
host = xstrdup(ap->sprint(&sa, 1));
}
@@ -530,7 +530,7 @@ int arp_main(int argc UNUSED_PARAM, char **argv)
/* Now see what we have to do here... */
if (opts & (ARP_OPT_d | ARP_OPT_s)) {
if (argv[0] == NULL)
bb_error_msg_and_die("need host name");
bb_simple_error_msg_and_die("need host name");
if (opts & ARP_OPT_s)
return arp_set(argv);
return arp_del(argv);
+2 -2
View File
@@ -375,7 +375,7 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
xconnect(probe_fd, (struct sockaddr *) &G.probe_saddr, sizeof(G.probe_saddr));
bb_getsockname(probe_fd, (struct sockaddr *) &G.probe_saddr, sizeof(G.probe_saddr));
if (G.probe_saddr.sin_family != AF_INET)
bb_error_msg_and_die("no IP address configured");
bb_simple_error_msg_and_die("no IP address configured");
src = G.probe_saddr.sin_addr;
}
close(probe_fd);
@@ -430,7 +430,7 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
/* Don't allow SIGALRMs while we process the reply */
sigprocmask(SIG_BLOCK, &G.sset, NULL);
if (cc < 0) {
bb_perror_msg("recvfrom");
bb_simple_perror_msg("recvfrom");
continue;
}
recv_pack(G.packet, cc, &from);
+4 -4
View File
@@ -395,11 +395,11 @@ static int process_packet(struct dns_entry *conf_data,
head = (struct dns_head *)buf;
if (head->nquer == 0) {
bb_error_msg("packet has 0 queries, ignored");
bb_simple_error_msg("packet has 0 queries, ignored");
return 0; /* don't reply */
}
if (head->flags & htons(0x8000)) { /* QR bit */
bb_error_msg("response packet, ignored");
bb_simple_error_msg("response packet, ignored");
return 0; /* don't reply */
}
/* QR = 1 "response", RCODE = 4 "Not Implemented" */
@@ -474,7 +474,7 @@ static int process_packet(struct dns_entry *conf_data,
* RCODE = 0 "success"
*/
if (OPT_verbose)
bb_info_msg("returning positive reply");
bb_simple_info_msg("returning positive reply");
outr_flags = htons(0x8000 | 0x0400 | 0);
/* we have one answer */
head->nansw = htons(1);
@@ -557,7 +557,7 @@ int dnsd_main(int argc UNUSED_PARAM, char **argv)
continue;
}
if (OPT_verbose)
bb_info_msg("got UDP packet");
bb_simple_info_msg("got UDP packet");
buf[r] = '\0'; /* paranoia */
r = process_packet(conf_data, conf_ttl, buf);
if (r <= 0)
+2 -2
View File
@@ -182,7 +182,7 @@ static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd)
byte_cnt = sscanf(ethoptarg, "%u.%u.%u.%u",
&passwd[0], &passwd[1], &passwd[2], &passwd[3]);
if (byte_cnt < 4) {
bb_error_msg("can't read Wake-On-LAN pass");
bb_simple_error_msg("can't read Wake-On-LAN pass");
return 0;
}
// TODO: check invalid numbers >255??
@@ -266,7 +266,7 @@ int ether_wake_main(int argc UNUSED_PARAM, char **argv)
/* This is necessary for broadcasts to work */
if (flags /* & 1 OPT_BROADCAST */) {
if (setsockopt_broadcast(s) != 0)
bb_perror_msg("SO_BROADCAST");
bb_simple_perror_msg("SO_BROADCAST");
}
#if defined(PF_PACKET)
+1 -1
View File
@@ -214,7 +214,7 @@ int ftp_receive(const char *local_path, char *server_path)
struct stat sbuf;
/* lstat would be wrong here! */
if (stat(local_path, &sbuf) < 0) {
bb_perror_msg_and_die("stat");
bb_simple_perror_msg_and_die("stat");
}
if (sbuf.st_size > 0) {
beg_range = sbuf.st_size;
+1 -1
View File
@@ -61,7 +61,7 @@ static void do_sethostname(char *s, int isfile)
} else if (sethostname(s, strlen(s))) {
// if (errno == EPERM)
// bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
bb_perror_msg_and_die("sethostname");
bb_simple_perror_msg_and_die("sethostname");
}
}
+5 -5
View File
@@ -1025,7 +1025,7 @@ static void log_and_exit(void)
*/
if (verbose > 2)
bb_error_msg("closed");
bb_simple_error_msg("closed");
_exit(xfunc_error_retval);
}
@@ -1220,7 +1220,7 @@ static void send_headers(unsigned responseNum)
}
if (full_write(STDOUT_FILENO, iobuf, len) != len) {
if (verbose > 1)
bb_perror_msg("error");
bb_simple_perror_msg("error");
log_and_exit();
}
}
@@ -1838,7 +1838,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
if (count < 0) {
IF_FEATURE_USE_SENDFILE(fin:)
if (verbose > 1)
bb_perror_msg("error");
bb_simple_perror_msg("error");
}
log_and_exit();
}
@@ -2149,7 +2149,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
if (rmt_ip_str)
applet_name = rmt_ip_str;
if (verbose > 2)
bb_error_msg("connected");
bb_simple_error_msg("connected");
}
if_ip_denied_send_HTTP_FORBIDDEN_and_exit(remote_ip);
@@ -2746,7 +2746,7 @@ int httpd_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_SETUID) {
if (ugid.gid != (gid_t)-1) {
if (setgroups(1, &ugid.gid) == -1)
bb_perror_msg_and_die("setgroups");
bb_simple_perror_msg_and_die("setgroups");
xsetgid(ugid.gid);
}
xsetuid(ugid.uid);
+1 -1
View File
@@ -361,7 +361,7 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_IFCONFIG_STATUS
return display_interfaces(argv[0] ? argv[0] : show_all_param);
#else
bb_error_msg_and_die("no support for status display");
bb_simple_error_msg_and_die("no support for status display");
#endif
}
+8 -8
View File
@@ -365,7 +365,7 @@ static void up_iface(void)
if (!(ifrequest.ifr_flags & IFF_UP)) {
ifrequest.ifr_flags |= IFF_UP;
/* Let user know we mess up with interface */
bb_info_msg("upping interface");
bb_simple_info_msg("upping interface");
if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0) {
if (errno != ENODEV && errno != EADDRNOTAVAIL)
xfunc_die();
@@ -461,7 +461,7 @@ static smallint detect_link(void)
else if (option_mask32 & FLAG_IGNORE_FAIL_POSITIVE)
status = IFSTATUS_UP;
else if (G.api_mode[0] == 'a')
bb_error_msg("can't detect link status");
bb_simple_error_msg("can't detect link status");
}
if (status != G.iface_last_status) {
@@ -493,14 +493,14 @@ static NOINLINE int check_existence_through_netlink(void)
goto ret;
if (errno == EINTR)
continue;
bb_perror_msg("netlink: recv");
bb_simple_perror_msg("netlink: recv");
return -1;
}
mhdr = (struct nlmsghdr*)replybuf;
while (bytes > 0) {
if (!NLMSG_OK(mhdr, bytes)) {
bb_error_msg("netlink packet too small or truncated");
bb_simple_error_msg("netlink packet too small or truncated");
return -1;
}
@@ -509,7 +509,7 @@ static NOINLINE int check_existence_through_netlink(void)
int attr_len;
if (mhdr->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) {
bb_error_msg("netlink packet too small or truncated");
bb_simple_error_msg("netlink packet too small or truncated");
return -1;
}
@@ -591,7 +591,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
}
if (pid_from_pidfile > 0 && kill(pid_from_pidfile, 0) == 0)
bb_error_msg_and_die("daemon already running");
bb_simple_error_msg_and_die("daemon already running");
#endif
api_mode_found = strchr(api_modes, G.api_mode[0]);
@@ -690,7 +690,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
) {
if (errno == EINTR)
continue;
bb_perror_msg("poll");
bb_simple_perror_msg("poll");
goto exiting;
}
@@ -763,5 +763,5 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
exiting:
remove_pidfile(pidfile_name);
bb_error_msg_and_die("exiting");
bb_simple_error_msg_and_die("exiting");
}
+2 -2
View File
@@ -665,7 +665,7 @@ static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec)
if (executable_exists(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].startcmd, ifd, exec);
}
bb_error_msg("no dhcp clients found");
bb_simple_error_msg("no dhcp clients found");
return 0;
}
# elif ENABLE_UDHCPC
@@ -707,7 +707,7 @@ static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec)
}
if (!result)
bb_error_msg("warning: no dhcp clients found and stopped");
bb_simple_error_msg("warning: no dhcp clients found and stopped");
/* Sleep a bit, otherwise static_down tries to bring down interface too soon,
and it may come back up because udhcpc is still shutting down */
+10 -10
View File
@@ -504,7 +504,7 @@ static void register_rpc(servtab_t *sep)
if (bb_getsockname(sep->se_fd, (struct sockaddr *) &ir_sin, sizeof(ir_sin)) < 0) {
//TODO: verify that such failure is even possible in Linux kernel
bb_perror_msg("getsockname");
bb_simple_perror_msg("getsockname");
return;
}
@@ -544,7 +544,7 @@ static void bump_nofile(void)
}
if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
bb_perror_msg("setrlimit");
bb_simple_perror_msg("setrlimit");
return;
}
@@ -599,7 +599,7 @@ static void prepare_socket_fd(servtab_t *sep)
fd = socket(sep->se_family, sep->se_socktype, 0);
if (fd < 0) {
bb_perror_msg("socket");
bb_simple_perror_msg("socket");
return;
}
setsockopt_reuseaddr(fd);
@@ -815,7 +815,7 @@ static NOINLINE servtab_t *parse_one_line(void)
n = bb_strtou(p, &p, 10);
if (n > INT_MAX) {
bad_ver_spec:
bb_error_msg("bad rpc version");
bb_simple_error_msg("bad rpc version");
goto parse_err;
}
sep->se_rpcver_lo = sep->se_rpcver_hi = n;
@@ -829,7 +829,7 @@ static NOINLINE servtab_t *parse_one_line(void)
if (*p != '\0')
goto bad_ver_spec;
#else
bb_error_msg("no support for rpc services");
bb_simple_error_msg("no support for rpc services");
goto parse_err;
#endif
}
@@ -1235,7 +1235,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
if (argv[0])
config_filename = argv[0];
if (config_filename == NULL)
bb_error_msg_and_die("non-root must specify config file");
bb_simple_error_msg_and_die("non-root must specify config file");
if (!(opt & 2))
bb_daemonize_or_rexec(0, argv - optind);
else
@@ -1304,7 +1304,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
ready_fd_cnt = select(maxsock + 1, &readable, NULL, NULL, NULL);
if (ready_fd_cnt < 0) {
if (errno != EINTR) {
bb_perror_msg("select");
bb_simple_perror_msg("select");
sleep(1);
}
continue;
@@ -1405,7 +1405,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
pid = vfork();
if (pid < 0) { /* fork error */
bb_perror_msg("vfork"+1);
bb_simple_perror_msg("vfork"+1);
sleep(1);
restore_sigmask(&omask);
maybe_close(new_udp_fd);
@@ -1488,7 +1488,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
}
if (real_uid != 0 && real_uid != pwd->pw_uid) {
/* a user running private inetd */
bb_error_msg("non-root must run services as himself");
bb_simple_error_msg("non-root must run services as himself");
goto do_exit1;
}
if (pwd->pw_uid != real_uid) {
@@ -1502,7 +1502,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
}
if (rlim_ofile.rlim_cur != rlim_ofile_cur)
if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0)
bb_perror_msg("setrlimit");
bb_simple_perror_msg("setrlimit");
/* closelog(); - WRONG. we are after vfork,
* this may confuse syslog() internal state.
+1 -1
View File
@@ -183,7 +183,7 @@ int ipcalc_main(int argc UNUSED_PARAM, char **argv)
if (argv[1]) {
if (ENABLE_FEATURE_IPCALC_FANCY && have_netmask) {
bb_error_msg_and_die("use prefix or netmask, not both");
bb_simple_error_msg_and_die("use prefix or netmask, not both");
}
if (inet_aton(argv[1], &s_netmask) == 0) {
bb_error_msg_and_die("bad netmask: %s", argv[1]);
+2 -2
View File
@@ -185,7 +185,7 @@ static void handle_accept(isrv_state_t *state, int fd)
/* Most probably someone gave us wrong fd type
* (for example, non-socket). Don't want
* to loop forever. */
bb_perror_msg_and_die("accept");
bb_simple_perror_msg_and_die("accept");
}
DPRINTF("new_peer(%d)", newfd);
@@ -311,7 +311,7 @@ void isrv_run(
if (n < 0) {
if (errno != EINTR)
bb_perror_msg("select");
bb_simple_perror_msg("select");
continue;
}
+5 -5
View File
@@ -119,7 +119,7 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
//memset(tb, 0, sizeof(tb)); - parse_rtattr does this
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
if (tb[IFLA_IFNAME] == NULL) {
bb_error_msg("nil ifname");
bb_simple_error_msg("nil ifname");
return -1;
}
if (G_filter.label
@@ -205,7 +205,7 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
static int flush_update(void)
{
if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
bb_perror_msg("can't send flush request");
bb_simple_perror_msg("can't send flush request");
return -1;
}
G_filter.flushp = 0;
@@ -439,7 +439,7 @@ int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush)
bb_error_msg_and_die(bb_msg_requires_arg, "flush");
}
if (G_filter.family == AF_PACKET) {
bb_error_msg_and_die("can't flush link addresses");
bb_simple_error_msg_and_die("can't flush link addresses");
}
}
@@ -700,7 +700,7 @@ static int ipaddr_modify(int cmd, int flags, char **argv)
if (!d) {
/* There was no "dev IFACE", but we need that */
bb_error_msg_and_die("need \"dev IFACE\"");
bb_simple_error_msg_and_die("need \"dev IFACE\"");
}
if (l && !is_prefixed_with(l, d)) {
bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
@@ -717,7 +717,7 @@ static int ipaddr_modify(int cmd, int flags, char **argv)
inet_prefix brd;
int i;
if (req.ifa.ifa_family != AF_INET) {
bb_error_msg_and_die("broadcast can be set only for IPv4 addresses");
bb_simple_error_msg_and_die("broadcast can be set only for IPv4 addresses");
}
brd = peer;
if (brd.bitlen <= 30) {
+4 -4
View File
@@ -49,7 +49,7 @@ typedef struct filter_t filter_t;
static int flush_update(void)
{
if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
bb_perror_msg("can't send flush request");
bb_simple_perror_msg("can't send flush request");
return -1;
}
G_filter.flushp = 0;
@@ -305,7 +305,7 @@ static int FAST_FUNC ipneigh_list_or_flush(char **argv, int flush)
xrtnl_wilddump_request(&rth, G_filter.family, RTM_GETNEIGH);
G_filter.flushed = 0;
if (xrtnl_dump_filter(&rth, print_neigh, NULL) < 0) {
bb_perror_msg_and_die("flush terminated");
bb_simple_perror_msg_and_die("flush terminated");
}
if (G_filter.flushed == 0) {
if (round == 0)
@@ -325,11 +325,11 @@ static int FAST_FUNC ipneigh_list_or_flush(char **argv, int flush)
ndm.ndm_family = G_filter.family;
if (rtnl_dump_request(&rth, RTM_GETNEIGH, &ndm, sizeof(struct ndmsg)) < 0) {
bb_perror_msg_and_die("can't send dump request");
bb_simple_perror_msg_and_die("can't send dump request");
}
if (xrtnl_dump_filter(&rth, print_neigh, NULL) < 0) {
bb_error_msg_and_die("dump terminated");
bb_simple_error_msg_and_die("dump terminated");
}
return 0;
+6 -6
View File
@@ -57,7 +57,7 @@ typedef struct filter_t filter_t;
static int flush_update(void)
{
if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
bb_perror_msg("can't send flush request");
bb_simple_perror_msg("can't send flush request");
return -1;
}
G_filter.flushp = 0;
@@ -756,7 +756,7 @@ static void iproute_flush_cache(void)
}
if (write(flush_fd, "-1", 2) < 2) {
bb_perror_msg("can't flush routing cache");
bb_simple_perror_msg("can't flush routing cache");
return;
}
close(flush_fd);
@@ -948,7 +948,7 @@ static int iproute_list_or_flush(char **argv, int flush)
if (G_filter.tb != -1) {
xrtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE);
} else if (rtnl_rtcache_request(&rth, do_ipv6) < 0) {
bb_perror_msg_and_die("can't send dump request");
bb_simple_perror_msg_and_die("can't send dump request");
}
xrtnl_dump_filter(&rth, print_route, NULL);
@@ -1041,7 +1041,7 @@ static int iproute_get(char **argv)
}
if (req.r.rtm_dst_len == 0) {
bb_error_msg_and_die("need at least destination address");
bb_simple_error_msg_and_die("need at least destination address");
}
xrtnl_open(&rth);
@@ -1077,7 +1077,7 @@ static int iproute_get(char **argv)
print_route(NULL, &req.n, NULL);
if (req.n.nlmsg_type != RTM_NEWROUTE) {
bb_error_msg_and_die("not a route?");
bb_simple_error_msg_and_die("not a route?");
}
len -= NLMSG_LENGTH(sizeof(*r));
if (len < 0) {
@@ -1091,7 +1091,7 @@ static int iproute_get(char **argv)
tb[RTA_PREFSRC]->rta_type = RTA_SRC;
r->rtm_src_len = 8*RTA_PAYLOAD(tb[RTA_PREFSRC]);
} else if (!tb[RTA_SRC]) {
bb_error_msg_and_die("can't connect the route");
bb_simple_error_msg_and_die("can't connect the route");
}
if (!odev && tb[RTA_OIF]) {
tb[RTA_OIF]->rta_type = 0;
+5 -5
View File
@@ -338,7 +338,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
bb_error_msg_and_die("keys are not allowed with ipip and sit");
bb_simple_error_msg_and_die("keys are not allowed with ipip and sit");
}
}
@@ -355,7 +355,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
p->o_flags |= GRE_KEY;
}
if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) {
bb_error_msg_and_die("broadcast tunnel requires a source address");
bb_simple_error_msg_and_die("broadcast tunnel requires a source address");
}
}
@@ -367,7 +367,7 @@ static int do_add(int cmd, char **argv)
parse_args(argv, cmd, &p);
if (p.iph.ttl && p.iph.frag_off == 0) {
bb_error_msg_and_die("ttl != 0 and noptmudisc are incompatible");
bb_simple_error_msg_and_die("ttl != 0 and noptmudisc are incompatible");
}
switch (p.iph.protocol) {
@@ -378,7 +378,7 @@ static int do_add(int cmd, char **argv)
case IPPROTO_IPV6:
return do_add_ioctl(cmd, "sit0", &p);
default:
bb_error_msg_and_die("can't determine tunnel mode (ipip, gre or sit)");
bb_simple_error_msg_and_die("can't determine tunnel mode (ipip, gre or sit)");
}
}
@@ -485,7 +485,7 @@ static void do_tunnels_list(struct ip_tunnel_parm *p)
if (ptr == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)
) {
bb_error_msg("wrong format of /proc/net/dev");
bb_simple_error_msg("wrong format of /proc/net/dev");
return;
}
if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
+15 -15
View File
@@ -79,7 +79,7 @@ int FAST_FUNC rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len)
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr)))
bb_error_msg("ERROR truncated");
bb_simple_error_msg("ERROR truncated");
else
errno = -err->error;
return -1;
@@ -149,11 +149,11 @@ static int rtnl_dump_filter(struct rtnl_handle *rth,
if (status < 0) {
if (errno == EINTR)
continue;
bb_perror_msg("OVERRUN");
bb_simple_perror_msg("OVERRUN");
continue;
}
if (status == 0) {
bb_error_msg("EOF on netlink");
bb_simple_error_msg("EOF on netlink");
goto ret;
}
if (msg.msg_namelen != sizeof(nladdr)) {
@@ -184,10 +184,10 @@ static int rtnl_dump_filter(struct rtnl_handle *rth,
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *l_err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
bb_error_msg("ERROR truncated");
bb_simple_error_msg("ERROR truncated");
} else {
errno = -l_err->error;
bb_perror_msg("RTNETLINK answers");
bb_simple_perror_msg("RTNETLINK answers");
}
goto ret;
}
@@ -201,7 +201,7 @@ static int rtnl_dump_filter(struct rtnl_handle *rth,
h = NLMSG_NEXT(h, status);
}
if (msg.msg_flags & MSG_TRUNC) {
bb_error_msg("message truncated");
bb_simple_error_msg("message truncated");
continue;
}
if (status) {
@@ -221,7 +221,7 @@ int FAST_FUNC xrtnl_dump_filter(struct rtnl_handle *rth,
{
int ret = rtnl_dump_filter(rth, filter, arg1/*, NULL, NULL*/);
if (ret < 0)
bb_error_msg_and_die("dump terminated");
bb_simple_error_msg_and_die("dump terminated");
return ret;
}
@@ -266,7 +266,7 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
status = sendmsg(rtnl->fd, &msg, 0);
if (status < 0) {
bb_perror_msg("can't talk to rtnetlink");
bb_simple_perror_msg("can't talk to rtnetlink");
goto ret;
}
@@ -280,11 +280,11 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (errno == EINTR) {
continue;
}
bb_perror_msg("OVERRUN");
bb_simple_perror_msg("OVERRUN");
continue;
}
if (status == 0) {
bb_error_msg("EOF on netlink");
bb_simple_error_msg("EOF on netlink");
goto ret;
}
if (msg.msg_namelen != sizeof(nladdr)) {
@@ -297,7 +297,7 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (l < 0 || len > status) {
if (msg.msg_flags & MSG_TRUNC) {
bb_error_msg("truncated message");
bb_simple_error_msg("truncated message");
goto ret;
}
bb_error_msg_and_die("malformed message: len=%d!", len);
@@ -320,7 +320,7 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (l < (int)sizeof(struct nlmsgerr)) {
bb_error_msg("ERROR truncated");
bb_simple_error_msg("ERROR truncated");
} else {
errno = - err->error;
if (errno == 0) {
@@ -329,7 +329,7 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
}
goto ret_0;
}
bb_perror_msg("RTNETLINK answers");
bb_simple_perror_msg("RTNETLINK answers");
}
goto ret;
}
@@ -338,13 +338,13 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
goto ret_0;
}
bb_error_msg("unexpected reply!");
bb_simple_error_msg("unexpected reply!");
status -= NLMSG_ALIGN(len);
h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len));
}
if (msg.msg_flags & MSG_TRUNC) {
bb_error_msg("message truncated");
bb_simple_error_msg("message truncated");
continue;
}
if (status) {
+1 -1
View File
@@ -230,7 +230,7 @@ uint32_t FAST_FUNC get_addr32(char *name)
char** FAST_FUNC next_arg(char **argv)
{
if (!*++argv)
bb_error_msg_and_die("command line is not complete, try \"help\"");
bb_simple_error_msg_and_die("command line is not complete, try \"help\"");
return argv;
}
+5 -5
View File
@@ -179,7 +179,7 @@ int nbdclient_main(int argc, char **argv)
if (memcmp(&nbd_header.magic1, "NBDMAGIC",
sizeof(nbd_header.magic1)) != 0
) {
bb_error_msg_and_die("login failed");
bb_simple_error_msg_and_die("login failed");
}
if (memcmp(&nbd_header.magic2,
"\x00\x00\x42\x02\x81\x86\x12\x53",
@@ -189,7 +189,7 @@ int nbdclient_main(int argc, char **argv)
} else if (memcmp(&nbd_header.magic2, "IHAVEOPT", 8) == 0) {
proto_new = 1;
} else {
bb_error_msg_and_die("login failed");
bb_simple_error_msg_and_die("login failed");
}
if (!proto_new) {
@@ -240,17 +240,17 @@ int nbdclient_main(int argc, char **argv)
}
if (ioctl(nbd, BLKROSET, &ro) < 0) {
bb_perror_msg_and_die("BLKROSET");
bb_simple_perror_msg_and_die("BLKROSET");
}
if (timeout) {
if (ioctl(nbd, NBD_SET_TIMEOUT, (unsigned long) timeout)) {
bb_perror_msg_and_die("NBD_SET_TIMEOUT");
bb_simple_perror_msg_and_die("NBD_SET_TIMEOUT");
}
}
if (ioctl(nbd, NBD_SET_SOCK, sock)) {
bb_perror_msg_and_die("NBD_SET_SOCK");
bb_simple_perror_msg_and_die("NBD_SET_SOCK");
}
//if (swap) mlockall(MCL_CURRENT|MCL_FUTURE);
+3 -3
View File
@@ -112,7 +112,7 @@
static void timeout(int signum UNUSED_PARAM)
{
bb_error_msg_and_die("timed out");
bb_simple_error_msg_and_die("timed out");
}
int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -211,7 +211,7 @@ int nc_main(int argc, char **argv)
accept_again:
cfd = accept(sfd, NULL, 0);
if (cfd < 0)
bb_perror_msg_and_die("accept");
bb_simple_perror_msg_and_die("accept");
if (!execparam)
close(sfd);
} else {
@@ -260,7 +260,7 @@ int nc_main(int argc, char **argv)
int nread;
if (safe_poll(pfds, 2, -1) < 0)
bb_perror_msg_and_die("poll");
bb_simple_perror_msg_and_die("poll");
fdidx = 0;
while (1) {
+9 -9
View File
@@ -198,8 +198,8 @@ enum {
#define Debug(...) do { } while (0)
#endif
#define holler_error(...) do { if (o_verbose) bb_error_msg(__VA_ARGS__); } while (0)
#define holler_perror(...) do { if (o_verbose) bb_perror_msg(__VA_ARGS__); } while (0)
#define holler_error(msg) do { if (o_verbose) bb_simple_error_msg(msg); } while (0)
#define holler_perror(msg) do { if (o_verbose) bb_simple_perror_msg(msg); } while (0)
/* catch: no-brainer interrupt handler */
static void catch(int sig)
@@ -361,10 +361,10 @@ static void dolisten(int is_persistent, char **proggie)
rr = recv_from_to(netfd, NULL, 0, MSG_PEEK, /*was bigbuf_net, BIGSIZ*/
&remend.u.sa, &ouraddr->u.sa, ouraddr->len);
if (rr < 0)
bb_perror_msg_and_die("recvfrom");
bb_simple_perror_msg_and_die("recvfrom");
unarm();
} else
bb_error_msg_and_die("timeout");
bb_simple_error_msg_and_die("timeout");
/* Now we learned *to which IP* peer has connected, and we want to anchor
our socket on it, so that our outbound packets will have correct local IP.
Unfortunately, bind() on already bound socket will fail now (EINVAL):
@@ -382,7 +382,7 @@ create new one, and bind() it. TODO */
remend.len = LSA_SIZEOF_SA;
rr = accept(netfd, &remend.u.sa, &remend.len);
if (rr < 0)
bb_perror_msg_and_die("accept");
bb_simple_perror_msg_and_die("accept");
if (themaddr) {
int sv_port, port, r;
@@ -409,7 +409,7 @@ create new one, and bind() it. TODO */
}
unarm();
} else
bb_error_msg_and_die("timeout");
bb_simple_error_msg_and_die("timeout");
if (is_persistent && proggie) {
/* -l -k -e PROG */
@@ -494,7 +494,7 @@ static int udptest(void)
rr = write(netfd, bigbuf_in, 1);
if (rr != 1)
bb_perror_msg("udptest first write");
bb_simple_perror_msg("udptest first write");
if (o_wait)
sleep(o_wait); // can be interrupted! while (t) nanosleep(&t)?
@@ -644,7 +644,7 @@ static int readwrite(void)
if (rr <= 0) {
if (rr < 0 && o_verbose > 1) {
/* nc 1.10 doesn't do this */
bb_perror_msg("net read");
bb_simple_perror_msg("net read");
}
pfds[1].fd = -1; /* don't poll for netfd anymore */
fds_open--;
@@ -869,7 +869,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv)
/* apparently UDP can listen ON "port 0",
but that's not useful */
if (!o_lport)
bb_error_msg_and_die("UDP listen needs nonzero -p port");
bb_simple_error_msg_and_die("UDP listen needs nonzero -p port");
}
#endif
+2 -2
View File
@@ -343,9 +343,9 @@ static void prg_cache_load(void)
return;
if (prg_cache_loaded == 1)
bb_error_msg("can't scan /proc - are you root?");
bb_simple_error_msg("can't scan /proc - are you root?");
else
bb_error_msg("showing only processes with your user ID");
bb_simple_error_msg("showing only processes with your user ID");
}
#else
+1 -1
View File
@@ -549,7 +549,7 @@ static int send_queries(struct ns *ns)
recvlen = read(pfd.fd, reply, sizeof(reply));
if (recvlen < 0) {
bb_perror_msg("read");
bb_simple_perror_msg("read");
next:
tcur = monotonic_ms();
continue;
+10 -10
View File
@@ -905,7 +905,7 @@ do_sendto(int fd,
ret = send_to_from(fd, msg, len, MSG_DONTWAIT, to, from, addrlen);
}
if (ret != len) {
bb_perror_msg("send failed");
bb_simple_perror_msg("send failed");
return -1;
}
return 0;
@@ -1121,7 +1121,7 @@ step_time(double offset)
dtime = tvc.tv_sec + (1.0e-6 * tvc.tv_usec) + offset;
d_to_tv(dtime, &tvn);
if (settimeofday(&tvn, NULL) == -1)
bb_perror_msg_and_die("settimeofday");
bb_simple_perror_msg_and_die("settimeofday");
VERB2 {
tval = tvc.tv_sec;
@@ -1494,7 +1494,7 @@ select_and_cluster(void)
/* Starting from 1 is ok here */
for (i = 1; i < num_survivors; i++) {
if (G.last_update_peer == survivor[i].p) {
VERB5 bb_error_msg("keeping old synced peer");
VERB5 bb_simple_error_msg("keeping old synced peer");
p = G.last_update_peer;
goto keep_old;
}
@@ -1702,7 +1702,7 @@ update_local_clock(peer_t *p)
#else
set_new_values(STATE_SYNC, offset, recv_time);
#endif
VERB4 bb_error_msg("transitioning to FREQ, datapoint ignored");
VERB4 bb_simple_error_msg("transitioning to FREQ, datapoint ignored");
return 0; /* "leave poll interval as is" */
#if 0 /* this is dead code for now */
@@ -1796,7 +1796,7 @@ update_local_clock(peer_t *p)
VERB4 {
memset(&tmx, 0, sizeof(tmx));
if (adjtimex(&tmx) < 0)
bb_perror_msg_and_die("adjtimex");
bb_simple_perror_msg_and_die("adjtimex");
bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld",
tmx.freq, tmx.offset, tmx.status, tmx.constant);
}
@@ -1906,7 +1906,7 @@ update_local_clock(peer_t *p)
//tmx.maxerror = (uint32_t)((sys_rootdelay / 2 + sys_rootdisp) * 1e6);
rc = adjtimex(&tmx);
if (rc < 0)
bb_perror_msg_and_die("adjtimex");
bb_simple_perror_msg_and_die("adjtimex");
/* NB: here kernel returns constant == G.poll_exp, not == G.poll_exp - 4.
* Not sure why. Perhaps it is normal.
*/
@@ -2248,7 +2248,7 @@ recv_and_process_client_pkt(void /*int fd*/)
if (size < 0) {
if (errno == EAGAIN)
goto bail;
bb_perror_msg_and_die("recv");
bb_simple_perror_msg_and_die("recv");
}
addr = xmalloc_sockaddr2dotted_noport(from);
bb_error_msg("malformed packet received from %s: size %u", addr, (int)size);
@@ -2415,7 +2415,7 @@ static NOINLINE void ntp_init(char **argv)
srand(getpid());
if (getuid())
bb_error_msg_and_die(bb_msg_you_must_be_root);
bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
/* Set some globals */
G.discipline_jitter = G_precision_sec;
@@ -2491,7 +2491,7 @@ static NOINLINE void ntp_init(char **argv)
/* supports 'sha' and 'sha1' formats */
hash_type = HASH_SHA1;
else
bb_error_msg_and_die("only MD5 and SHA1 keys supported");
bb_simple_error_msg_and_die("only MD5 and SHA1 keys supported");
/* man ntp.keys:
* MD5 The key is 1 to 16 printable characters terminated by an EOL,
* whitespace, or a # (which is the "start of comment" character).
@@ -2674,7 +2674,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
if (p->p_fd == -1) {
/* Time to send new req */
if (--cnt == 0) {
VERB4 bb_error_msg("disabling burst mode");
VERB4 bb_simple_error_msg("disabling burst mode");
G.polladj_count = 0;
G.poll_exp = MINPOLL;
}
+8 -8
View File
@@ -184,8 +184,8 @@ create_icmp_socket(void)
sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */
if (sock < 0) {
if (errno == EPERM)
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
bb_simple_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
}
xmove_fd(sock, pingsock);
@@ -235,7 +235,7 @@ static void ping4(len_and_sockaddr *lsa)
#endif
if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
bb_simple_perror_msg("recvfrom");
continue;
}
if (c >= 76) { /* ip + icmp */
@@ -280,7 +280,7 @@ static void ping6(len_and_sockaddr *lsa)
#endif
if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
bb_simple_perror_msg("recvfrom");
continue;
}
if (c >= ICMP_MINLEN) { /* icmp6_hdr */
@@ -482,7 +482,7 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
* it doesn't matter */
sz = xsendto(pingsock, G.snd_packet, size_pkt, &pingaddr.sa, sizeof(pingaddr));
if (sz != size_pkt)
bb_error_msg_and_die(bb_msg_write_error);
bb_simple_error_msg_and_die(bb_msg_write_error);
if (pingcount == 0 || G.ntransmitted < pingcount) {
/* Didn't send all pings yet - schedule next in -i SEC interval */
@@ -723,7 +723,7 @@ static void ping4(len_and_sockaddr *lsa)
if (source_lsa) {
if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
&source_lsa->u.sa, source_lsa->len))
bb_error_msg_and_die("can't set multicast source interface");
bb_simple_error_msg_and_die("can't set multicast source interface");
xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
}
@@ -757,7 +757,7 @@ static void ping4(len_and_sockaddr *lsa)
(struct sockaddr *) &from, &fromlen);
if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
bb_simple_perror_msg("recvfrom");
continue;
}
c = unpack4(G.rcv_packet, c, &from);
@@ -838,7 +838,7 @@ static void ping6(len_and_sockaddr *lsa)
c = recvmsg(pingsock, &msg, 0);
if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
bb_simple_perror_msg("recvfrom");
continue;
}
for (mp = CMSG_FIRSTHDR(&msg); mp; mp = CMSG_NXTHDR(&msg, mp)) {
+3 -3
View File
@@ -336,7 +336,7 @@ static NOINLINE void INET_setroute(int action, char **args)
}
mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr;
if (mask & ~(uint32_t)mask_in_addr(*rt)) {
bb_error_msg_and_die("netmask and route address conflict");
bb_simple_error_msg_and_die("netmask and route address conflict");
}
}
@@ -532,7 +532,7 @@ void FAST_FUNC bb_displayroutes(int noresolve, int netstatfmt)
if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
break;
}
bb_perror_msg_and_die(bb_msg_read_error);
bb_simple_perror_msg_and_die(bb_msg_read_error);
}
if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */
@@ -598,7 +598,7 @@ static void INET6_displayroutes(void)
break;
}
ERROR:
bb_perror_msg_and_die(bb_msg_read_error);
bb_simple_perror_msg_and_die(bb_msg_read_error);
}
/* Do the addr6x shift-and-insert changes to ':'-delimit addresses.
+2 -2
View File
@@ -56,7 +56,7 @@ static int tcsetattr_serial_or_warn(struct termios *state)
ret = tcsetattr(serial_fd, TCSANOW, state);
if (ret != 0) {
bb_perror_msg("tcsetattr");
bb_simple_perror_msg("tcsetattr");
return 1; /* used as exitcode */
}
return ret; /* 0 */
@@ -159,7 +159,7 @@ int slattach_main(int argc UNUSED_PARAM, char **argv)
/* Save current tty state */
if (tcgetattr(serial_fd, &G.saved_state) != 0)
bb_perror_msg_and_die("tcgetattr");
bb_simple_perror_msg_and_die("tcgetattr");
/* Save line discipline */
xioctl(serial_fd, TIOCGETD, &G.saved_disc);
+3 -3
View File
@@ -325,7 +325,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
client = 0;
if ((getuid() == 0) && !(opts & OPT_u)) {
xfunc_error_retval = 100;
bb_error_msg_and_die(bb_msg_you_must_be_root);
bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
}
if (opts & OPT_u)
if (!uidgid_get(&sslugid, ssluser, 1)) {
@@ -419,7 +419,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
sig_block(SIGCHLD);
if (conn < 0) {
if (errno != EINTR)
bb_perror_msg(tcp ? "accept" : "recv");
bb_simple_perror_msg(tcp ? "accept" : "recv");
goto again2;
}
xmove_fd(tcp ? conn : sock, 0);
@@ -484,7 +484,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
pid = vfork();
if (pid == -1) {
bb_perror_msg("vfork");
bb_simple_perror_msg("vfork");
goto again;
}
+1 -1
View File
@@ -495,7 +495,7 @@ make_new_session(
free(ts);
close(fd);
/* sock will be closed by caller */
bb_perror_msg("vfork");
bb_simple_perror_msg("vfork");
return NULL;
}
if (pid > 0) {
+5 -5
View File
@@ -453,7 +453,7 @@ static int tftp_protocol(
/* fill in packet if the filename fits into xbuf */
len = strlen(remote_file) + 1;
if (2 + len + sizeof("octet") >= io_bufsize) {
bb_error_msg("remote filename is too long");
bb_simple_error_msg("remote filename is too long");
goto ret;
}
strcpy(cp, remote_file);
@@ -468,7 +468,7 @@ static int tftp_protocol(
/* Need to add option to pkt */
if ((&xbuf[io_bufsize - 1] - cp) < sizeof("blksize NNNNN tsize ") + sizeof(off_t)*3) {
bb_error_msg("remote filename is too long");
bb_simple_error_msg("remote filename is too long");
goto ret;
}
expect_OACK = 1;
@@ -569,7 +569,7 @@ static int tftp_protocol(
retries--;
if (retries == 0) {
tftp_progress_done();
bb_error_msg("timeout");
bb_simple_error_msg("timeout");
goto ret; /* no err packet sent */
}
@@ -674,7 +674,7 @@ static int tftp_protocol(
* must be ignored by the client and server
* as if it were never requested." */
if (blksize != TFTP_BLKSIZE_DEFAULT)
bb_error_msg("falling back to blocksize "TFTP_BLKSIZE_DEFAULT_STR);
bb_simple_error_msg("falling back to blocksize "TFTP_BLKSIZE_DEFAULT_STR);
blksize = TFTP_BLKSIZE_DEFAULT;
io_bufsize = TFTP_BLKSIZE_DEFAULT + 4;
}
@@ -739,7 +739,7 @@ static int tftp_protocol(
strcpy(G_error_pkt_str, bb_msg_read_error);
send_err_pkt:
if (G_error_pkt_str[0])
bb_error_msg("%s", G_error_pkt_str);
bb_simple_error_msg(G_error_pkt_str);
G.error_pkt[1] = TFTP_ERROR;
xsendto(socket_fd, G.error_pkt, 4 + 1 + strlen(G_error_pkt_str),
&peer_lsa->u.sa, peer_lsa->len);
+7 -7
View File
@@ -446,7 +446,7 @@ static void hmac_begin(hmac_precomputed_t *pre, uint8_t *key, unsigned key_size,
// than INSIZE bytes will first hash the key using H and then use the
// resultant OUTSIZE byte string as the actual key to HMAC."
if (key_size > SHA_INSIZE) {
bb_error_msg_and_die("HMAC key>64"); //does not happen (yet?)
bb_simple_error_msg_and_die("HMAC key>64"); //does not happen (yet?)
// md5sha_ctx_t ctx;
// begin(&ctx);
// md5sha_hash(&ctx, key, key_size);
@@ -1132,7 +1132,7 @@ static int tls_xread_record(tls_state_t *tls, const char *expected)
}
}
if (sz < 0)
bb_error_msg_and_die("encrypted data too short");
bb_simple_error_msg_and_die("encrypted data too short");
//dump_hex("<< %s\n", tls->inbuf, RECHDR_LEN + sz);
@@ -1411,7 +1411,7 @@ static void find_key_in_der_cert(tls_state_t *tls, uint8_t *der, int len)
dbg("ECDSA key\n");
//UNUSED: tls->flags |= GOT_CERT_ECDSA_KEY_ALG;
} else
bb_error_msg_and_die("not RSA or ECDSA cert");
bb_simple_error_msg_and_die("not RSA or ECDSA cert");
}
if (tls->flags & GOT_CERT_RSA_KEY_ALG) {
@@ -1882,7 +1882,7 @@ static void process_server_key(tls_state_t *tls, int len)
/* So far we only support curve_x25519 */
move_from_unaligned32(t32, keybuf);
if (t32 != htonl(0x03001d20))
bb_error_msg_and_die("elliptic curve is not x25519");
bb_simple_error_msg_and_die("elliptic curve is not x25519");
memcpy(tls->hsd->ecc_pub_key32, keybuf + 4, 32);
tls->flags |= GOT_EC_KEY;
@@ -1929,7 +1929,7 @@ static void send_client_key_exchange(tls_state_t *tls)
if (!(tls->flags & NEED_EC_KEY)) {
/* RSA */
if (!(tls->flags & GOT_CERT_RSA_KEY_ALG))
bb_error_msg("server cert is not RSA");
bb_simple_error_msg("server cert is not RSA");
tls_get_random(rsa_premaster, sizeof(rsa_premaster));
if (TLS_DEBUG_FIXED_SECRETS)
@@ -1959,7 +1959,7 @@ static void send_client_key_exchange(tls_state_t *tls)
uint8_t privkey[CURVE25519_KEYSIZE]; //[32]
if (!(tls->flags & GOT_EC_KEY))
bb_error_msg("server did not provide EC key");
bb_simple_error_msg("server did not provide EC key");
/* Generate random private key, see RFC 7748 */
tls_get_random(privkey, sizeof(privkey));
@@ -2322,7 +2322,7 @@ void FAST_FUNC tls_run_copy_loop(tls_state_t *tls, unsigned flags)
int nread;
if (safe_poll(pfds, 2, -1) < 0)
bb_perror_msg_and_die("poll");
bb_simple_perror_msg_and_die("poll");
if (pfds[0].revents) {
void *buf;
+1 -1
View File
@@ -90,7 +90,7 @@ void xorbuf_aligned_AES_BLOCK_SIZE(void* buf, const void* mask) FAST_FUNC;
#define matrixCryptoGetPrngData(buf, len, userPtr) (tls_get_random(buf, len), PS_SUCCESS)
#define psFree(p, pool) free(p)
#define psTraceCrypto(...) bb_error_msg_and_die(__VA_ARGS__)
#define psTraceCrypto(msg) bb_simple_error_msg_and_die(msg)
/* Secure zerofill */
#define memset_s(A,B,C,D) memset((A),(C),(D))
+3 -3
View File
@@ -875,7 +875,7 @@ common_traceroute_main(int op, char **argv)
* probe (e.g., on a multi-homed host).
*/
if (getuid() != 0)
bb_error_msg_and_die(bb_msg_you_must_be_root);
bb_simple_error_msg_and_die(bb_msg_you_must_be_root);
}
if (op & OPT_WAITTIME)
waittime = xatou_range(waittime_str, 1, 24 * 60 * 60);
@@ -1003,7 +1003,7 @@ common_traceroute_main(int op, char **argv)
if (af == AF_INET)
if (setsockopt(sndsock, IPPROTO_IP, IP_MULTICAST_IF,
&source_lsa->u.sa, source_lsa->len))
bb_error_msg_and_die("can't set multicast source interface");
bb_simple_error_msg_and_die("can't set multicast source interface");
//TODO: we can query source port we bound to,
// and check it in replies... if we care enough
xbind(sndsock, &source_lsa->u.sa, source_lsa->len);
@@ -1025,7 +1025,7 @@ common_traceroute_main(int op, char **argv)
/* read IP and port */
source_lsa = get_sock_lsa(probe_fd);
if (source_lsa == NULL)
bb_error_msg_and_die("can't get probe addr");
bb_simple_error_msg_and_die("can't get probe addr");
close(probe_fd);
+2 -2
View File
@@ -53,12 +53,12 @@ int FAST_FUNC arpping(uint32_t test_nip,
s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP));
if (s == -1) {
bb_perror_msg(bb_msg_can_not_create_raw_socket);
bb_simple_perror_msg(bb_msg_can_not_create_raw_socket);
return -1;
}
if (setsockopt_broadcast(s) == -1) {
bb_perror_msg("can't enable bcast on raw socket");
bb_simple_perror_msg("can't enable bcast on raw socket");
goto ret;
}
+1 -1
View File
@@ -240,7 +240,7 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code)
while (1) {
if (rem <= 0) {
complain:
bb_error_msg("bad packet, malformed option field");
bb_simple_error_msg("bad packet, malformed option field");
return NULL;
}
+19
View File
@@ -267,26 +267,45 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code)
# define IF_UDHCP_VERBOSE(...) __VA_ARGS__
extern unsigned dhcp_verbose;
# define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0)
# define log1s(msg) do { if (dhcp_verbose >= 1) bb_simple_info_msg(msg); } while (0)
# if CONFIG_UDHCP_DEBUG >= 2
void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
# define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0)
# define log2s(msg) do { if (dhcp_verbose >= 2) bb_simple_info_msg(msg); } while (0)
# else
# define udhcp_dump_packet(...) ((void)0)
# define log2(...) ((void)0)
# define log2s(msg) ((void)0)
# endif
# if CONFIG_UDHCP_DEBUG >= 3
# define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0)
# define log3s(msg) do { if (dhcp_verbose >= 3) bb_simple_info_msg(msg); } while (0)
# else
# define log3(...) ((void)0)
# define log3s(msg) ((void)0)
# endif
#else
# define IF_UDHCP_VERBOSE(...)
# define udhcp_dump_packet(...) ((void)0)
# define log1(...) ((void)0)
# define log1s(msg) ((void)0)
# define log2(...) ((void)0)
# define log2s(msg) ((void)0)
# define log3(...) ((void)0)
# define log3s(msg) ((void)0)
#endif
#if defined(__mips__)
/*
* The 'simple' message functions have a negative impact on the size of the
* DHCP code when compiled for MIPS, so don't use them in this case.
*/
#define bb_simple_info_msg bb_info_msg
#define bb_simple_error_msg bb_error_msg
#define bb_simple_perror_msg_and_die bb_perror_msg_and_die
#undef log1s
#define log1s log1
#endif
/*** Other shared functions ***/
+17 -17
View File
@@ -235,7 +235,7 @@ static char *string_option_to_env(const uint8_t *option,
found:
val_len = (option[2] << 8) | option[3];
if (val_len + &option[D6_OPT_DATA] > option_end) {
bb_error_msg("option data exceeds option length");
bb_simple_error_msg("option data exceeds option length");
return NULL;
}
return xasprintf("%s=%.*s", name, val_len, (char*)option + 4);
@@ -848,19 +848,19 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
bytes = safe_read(fd, &packet, sizeof(packet));
if (bytes < 0) {
log1("packet read error, ignoring");
log1s("packet read error, ignoring");
/* NB: possible down interface, etc. Caller should pause. */
return bytes; /* returns -1 */
}
if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) {
log1("packet is too short, ignoring");
log1s("packet is too short, ignoring");
return -2;
}
if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) {
/* packet is bigger than sizeof(packet), we did partial read */
log1("oversized packet, ignoring");
log1s("oversized packet, ignoring");
return -2;
}
@@ -874,7 +874,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
/* || bytes > (int) sizeof(packet) - can't happen */
|| packet.udp.len != packet.ip6.ip6_plen
) {
log1("unrelated/bogus packet, ignoring");
log1s("unrelated/bogus packet, ignoring");
return -2;
}
@@ -1003,7 +1003,7 @@ static int d6_raw_socket(int ifindex)
}
#endif
log1("created raw socket");
log1s("created raw socket");
return fd;
}
@@ -1031,7 +1031,7 @@ static void change_listen_mode(int new_mode)
/* Called only on SIGUSR1 */
static void perform_renew(void)
{
bb_info_msg("performing DHCP renew");
bb_simple_info_msg("performing DHCP renew");
switch (client_data.state) {
case BOUND:
change_listen_mode(LISTEN_KERNEL);
@@ -1059,10 +1059,10 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
|| client_data.state == REBINDING
|| client_data.state == RENEW_REQUESTED
) {
bb_info_msg("unicasting a release");
bb_simple_info_msg("unicasting a release");
send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
}
bb_info_msg("entering released state");
bb_simple_info_msg("entering released state");
/*
* We can be here on: SIGUSR2,
* or on exit (SIGTERM) and -R "release on quit" is specified.
@@ -1275,7 +1275,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
/* Create pidfile */
write_pidfile(client_data.pidfile);
/* Goes to stdout (unless NOMMU) and possibly syslog */
bb_info_msg("started, v"BB_VER);
bb_simple_info_msg("started, v"BB_VER);
client_data.state = INIT_SELECTING;
d6_run_script_no_option("deconfig");
@@ -1321,7 +1321,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
continue;
}
/* Else: an error occured, panic! */
bb_perror_msg_and_die("poll");
bb_simple_perror_msg_and_die("poll");
}
}
@@ -1362,7 +1362,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
d6_run_script_no_option("leasefail");
#if BB_MMU /* -b is not supported on NOMMU */
if (opt & OPT_b) { /* background if no lease */
bb_info_msg("no lease, forking to background");
bb_simple_info_msg("no lease, forking to background");
client_background();
/* do not background again! */
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
@@ -1375,7 +1375,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
} else
#endif
if (opt & OPT_n) { /* abort if no lease */
bb_info_msg("no lease, failing");
bb_simple_info_msg("no lease, failing");
retval = 1;
goto ret;
}
@@ -1403,7 +1403,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
client_data.state = RENEWING;
client_data.first_secs = 0; /* make secs field count from 0 */
change_listen_mode(LISTEN_KERNEL);
log1("entering renew state");
log1s("entering renew state");
/* fall right through */
case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
case_RENEW_REQUESTED:
@@ -1423,7 +1423,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
continue;
}
/* Timed out, enter rebinding state */
log1("entering rebinding state");
log1s("entering rebinding state");
client_data.state = REBINDING;
/* fall right through */
case REBINDING:
@@ -1438,7 +1438,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
continue;
}
/* Timed out, enter init state */
bb_info_msg("lease lost, entering init state");
bb_simple_info_msg("lease lost, entering init state");
d6_run_script_no_option("deconfig");
client_data.state = INIT_SELECTING;
client_data.first_secs = 0; /* make secs field count from 0 */
@@ -1560,7 +1560,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
}
option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID);
if (!option) {
bb_info_msg("no server ID, ignoring packet");
bb_simple_info_msg("no server ID, ignoring packet");
continue;
/* still selecting - this server looks bad */
}
+2 -2
View File
@@ -35,12 +35,12 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6
memset(packet, 0, sizeof(*packet));
bytes = safe_read(fd, packet, sizeof(*packet));
if (bytes < 0) {
log1("packet read error, ignoring");
log1s("packet read error, ignoring");
return bytes; /* returns -1 */
}
if (bytes < offsetof(struct d6_packet, d6_options)) {
bb_info_msg("packet with bad magic, ignoring");
bb_simple_info_msg("packet with bad magic, ignoring");
return -2;
}
log1("received %s", "a packet");
+1 -1
View File
@@ -115,7 +115,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf)
setsockopt_reuseaddr(fd);
if (setsockopt_broadcast(fd) == -1)
bb_perror_msg_and_die("SO_BROADCAST");
bb_simple_perror_msg_and_die("SO_BROADCAST");
/* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
if (setsockopt_bindtodevice(fd, inf))
+25 -25
View File
@@ -906,7 +906,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
if (bytes < 0) {
if (errno == EINTR)
continue;
log1("packet read error, ignoring");
log1s("packet read error, ignoring");
/* NB: possible down interface, etc. Caller should pause. */
return bytes; /* returns -1 */
}
@@ -914,13 +914,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
}
if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
log1("packet is too short, ignoring");
log1s("packet is too short, ignoring");
return -2;
}
if (bytes < ntohs(packet.ip.tot_len)) {
/* packet is bigger than sizeof(packet), we did partial read */
log1("oversized packet, ignoring");
log1s("oversized packet, ignoring");
return -2;
}
@@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
/* || bytes > (int) sizeof(packet) - can't happen */
|| ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
) {
log1("unrelated/bogus packet, ignoring");
log1s("unrelated/bogus packet, ignoring");
return -2;
}
@@ -943,7 +943,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
check = packet.ip.check;
packet.ip.check = 0;
if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) {
log1("bad IP header checksum, ignoring");
log1s("bad IP header checksum, ignoring");
return -2;
}
@@ -968,13 +968,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
check = packet.udp.check;
packet.udp.check = 0;
if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
log1("packet with bad UDP checksum received, ignoring");
log1s("packet with bad UDP checksum received, ignoring");
return -2;
}
skip_udp_sum_check:
if (packet.data.cookie != htonl(DHCP_MAGIC)) {
bb_info_msg("packet with bad magic, ignoring");
bb_simple_info_msg("packet with bad magic, ignoring");
return -2;
}
@@ -1089,10 +1089,10 @@ static int udhcp_raw_socket(int ifindex)
if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) {
if (errno != ENOPROTOOPT)
log1("can't set PACKET_AUXDATA on raw socket");
log1s("can't set PACKET_AUXDATA on raw socket");
}
log1("created raw socket");
log1s("created raw socket");
return fd;
}
@@ -1120,7 +1120,7 @@ static void change_listen_mode(int new_mode)
/* Called only on SIGUSR1 */
static void perform_renew(void)
{
bb_info_msg("performing DHCP renew");
bb_simple_info_msg("performing DHCP renew");
switch (client_data.state) {
case BOUND:
change_listen_mode(LISTEN_KERNEL);
@@ -1158,7 +1158,7 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
inet_ntoa(temp_addr), buffer);
send_release(server_addr, requested_ip); /* unicast */
}
bb_info_msg("entering released state");
bb_simple_info_msg("entering released state");
/*
* We can be here on: SIGUSR2,
* or on exit (SIGTERM) and -R "release on quit" is specified.
@@ -1303,7 +1303,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
);
if (opt & (OPT_h|OPT_H)) {
//msg added 2011-11
bb_error_msg("option -h NAME is deprecated, use -x hostname:NAME");
bb_simple_error_msg("option -h NAME is deprecated, use -x hostname:NAME");
client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0);
}
if (opt & OPT_F) {
@@ -1397,7 +1397,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* Create pidfile */
write_pidfile(client_data.pidfile);
/* Goes to stdout (unless NOMMU) and possibly syslog */
bb_info_msg("started, v"BB_VER);
bb_simple_info_msg("started, v"BB_VER);
/* We want random_xid to be random... */
srand(monotonic_us());
@@ -1444,7 +1444,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
continue;
}
/* Else: an error occurred, panic! */
bb_perror_msg_and_die("poll");
bb_simple_perror_msg_and_die("poll");
}
}
@@ -1485,7 +1485,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
udhcp_run_script(NULL, "leasefail");
#if BB_MMU /* -b is not supported on NOMMU */
if (opt & OPT_b) { /* background if no lease */
bb_info_msg("no lease, forking to background");
bb_simple_info_msg("no lease, forking to background");
client_background();
/* do not background again! */
opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f);
@@ -1498,7 +1498,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
} else
#endif
if (opt & OPT_n) { /* abort if no lease */
bb_info_msg("no lease, failing");
bb_simple_info_msg("no lease, failing");
retval = 1;
goto ret;
}
@@ -1526,7 +1526,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
client_data.state = RENEWING;
client_data.first_secs = 0; /* make secs field count from 0 */
change_listen_mode(LISTEN_KERNEL);
log1("entering renew state");
log1s("entering renew state");
/* fall right through */
case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
case_RENEW_REQUESTED:
@@ -1559,7 +1559,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
*/
}
/* Timed out or error, enter rebinding state */
log1("entering rebinding state");
log1s("entering rebinding state");
client_data.state = REBINDING;
/* fall right through */
case REBINDING:
@@ -1574,7 +1574,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
continue;
}
/* Timed out, enter init state */
bb_info_msg("lease lost, entering init state");
bb_simple_info_msg("lease lost, entering init state");
udhcp_run_script(NULL, "deconfig");
client_data.state = INIT_SELECTING;
client_data.first_secs = 0; /* make secs field count from 0 */
@@ -1660,13 +1660,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
|| memcmp(packet.chaddr, client_data.client_mac, 6) != 0
) {
//FIXME: need to also check that last 10 bytes are zero
log1("chaddr does not match, ignoring packet"); // log2?
log1("chaddr does not match%s", ", ignoring packet"); // log2?
continue;
}
message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
if (message == NULL) {
bb_info_msg("no message type option, ignoring packet");
bb_info_msg("no message type option%s", ", ignoring packet");
continue;
}
@@ -1703,7 +1703,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
server_addr = 0;
temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
if (!temp) {
bb_info_msg("no server ID, using 0.0.0.0");
bb_simple_info_msg("no server ID, using 0.0.0.0");
} else {
/* it IS unaligned sometimes, don't "optimize" */
move_from_unaligned32(server_addr, temp);
@@ -1730,7 +1730,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
if (!temp) {
bb_info_msg("no lease time with ACK, using 1 hour lease");
bb_simple_info_msg("no lease time with ACK, using 1 hour lease");
lease_seconds = 60 * 60;
} else {
/* it IS unaligned sometimes, don't "optimize" */
@@ -1763,7 +1763,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
client_data.interface,
arpping_ms)
) {
bb_info_msg("offered address is in use "
bb_simple_info_msg("offered address is in use "
"(got ARP reply), declining");
send_decline(/*xid,*/ server_addr, packet.yiaddr);
@@ -1827,7 +1827,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
if (!temp) {
non_matching_svid:
log1("received DHCP NAK with wrong"
" server ID, ignoring packet");
" server ID%s", ", ignoring packet");
continue;
}
move_from_unaligned32(svid, temp);
+12 -12
View File
@@ -582,11 +582,11 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
|| (dhcp_pkt->flags & htons(BROADCAST_FLAG))
|| dhcp_pkt->ciaddr == 0
) {
log1("broadcasting packet to client");
log1s("broadcasting packet to client");
ciaddr = INADDR_BROADCAST;
chaddr = MAC_BCAST_ADDR;
} else {
log1("unicasting packet to client ciaddr");
log1s("unicasting packet to client ciaddr");
ciaddr = dhcp_pkt->ciaddr;
chaddr = dhcp_pkt->chaddr;
}
@@ -600,7 +600,7 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
/* Send a packet to gateway_nip using the kernel ip stack */
static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
{
log1("forwarding packet to relay");
log1s("forwarding packet to relay");
udhcp_send_kernel_packet(dhcp_pkt,
server_data.server_nip, SERVER_PORT,
@@ -754,7 +754,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
}
if (!packet.yiaddr) {
bb_error_msg("no free IP addresses. OFFER abandoned");
bb_simple_error_msg("no free IP addresses. OFFER abandoned");
return;
}
/* Reserve the IP for a short time hoping to get DHCPREQUEST soon */
@@ -765,7 +765,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
p_host_name ? (unsigned char)p_host_name[OPT_LEN - OPT_DATA] : 0
);
if (!lease) {
bb_error_msg("no free IP addresses. OFFER abandoned");
bb_simple_error_msg("no free IP addresses. OFFER abandoned");
return;
}
}
@@ -914,7 +914,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
write_pidfile(server_data.pidfile);
/* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
bb_info_msg("started, v"BB_VER);
bb_simple_info_msg("started, v"BB_VER);
option = udhcp_find_option(server_data.options, DHCP_LEASE_TIME);
server_data.max_lease_sec = DEFAULT_LEASE_TIME;
@@ -985,7 +985,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
if (errno == EINTR)
goto new_tv;
/* < 0 and not EINTR: should not happen */
bb_perror_msg_and_die("poll");
bb_simple_perror_msg_and_die("poll");
}
if (pfds[0].revents) switch (udhcp_sp_read()) {
@@ -1019,16 +1019,16 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
continue;
}
if (packet.hlen != 6) {
bb_info_msg("MAC length != 6, ignoring packet");
bb_info_msg("MAC length != 6%s", ", ignoring packet");
continue;
}
if (packet.op != BOOTREQUEST) {
bb_info_msg("not a REQUEST, ignoring packet");
bb_info_msg("not a REQUEST%s", ", ignoring packet");
continue;
}
state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) {
bb_info_msg("no or bad message type option, ignoring packet");
bb_info_msg("no or bad message type option%s", ", ignoring packet");
continue;
}
@@ -1039,7 +1039,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
move_from_unaligned32(server_id_network_order, server_id_opt);
if (server_id_network_order != server_data.server_nip) {
/* client talks to somebody else */
log1("server ID doesn't match, ignoring");
log1("server ID doesn't match%s", ", ignoring");
continue;
}
}
@@ -1162,7 +1162,7 @@ o DHCPREQUEST generated during REBINDING state:
if (!requested_ip_opt) {
requested_nip = packet.ciaddr;
if (requested_nip == 0) {
log1("no requested IP and no ciaddr, ignoring");
log1("no requested IP and no ciaddr%s", ", ignoring");
break;
}
}
+2 -2
View File
@@ -186,7 +186,7 @@ static int sendto_ip4(int sock, const void *msg, int msg_len, struct sockaddr_in
err = sendto(sock, msg, msg_len, 0, (struct sockaddr*) to, sizeof(*to));
err -= msg_len;
if (err)
bb_perror_msg("sendto");
bb_simple_perror_msg("sendto");
return err;
}
@@ -273,7 +273,7 @@ int dhcprelay_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage();
if (argv[3]) {
if (!inet_aton(argv[3], &server_addr.sin_addr))
bb_perror_msg_and_die("bad server IP");
bb_simple_perror_msg_and_die("bad server IP");
}
iface_list = make_iface_list(argv + 1, &num_sockets);
+2 -2
View File
@@ -85,14 +85,14 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
memset(packet, 0, sizeof(*packet));
bytes = safe_read(fd, packet, sizeof(*packet));
if (bytes < 0) {
log1("packet read error, ignoring");
log1s("packet read error, ignoring");
return bytes; /* returns -1 */
}
if (bytes < offsetof(struct dhcp_packet, options)
|| packet->cookie != htonl(DHCP_MAGIC)
) {
bb_info_msg("packet with bad magic, ignoring");
bb_simple_info_msg("packet with bad magic, ignoring");
return -2;
}
log1("received %s", "a packet");
+1 -1
View File
@@ -28,7 +28,7 @@ static void signal_handler(int sig)
int sv = errno;
unsigned char ch = sig; /* use char, avoid dealing with partial writes */
if (write(WRITE_FD, &ch, 1) != 1)
bb_perror_msg("can't send signal");
bb_simple_perror_msg("can't send signal");
errno = sv;
}
+1 -1
View File
@@ -87,7 +87,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
setsockopt_reuseaddr(fd);
if (setsockopt_broadcast(fd) == -1)
bb_perror_msg_and_die("SO_BROADCAST");
bb_simple_perror_msg_and_die("SO_BROADCAST");
/* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */
colon = strrchr(inf, ':');
+11 -11
View File
@@ -368,7 +368,7 @@ static void alarm_handler(int sig UNUSED_PARAM)
{
/* This is theoretically unsafe (uses stdio and malloc in signal handler) */
if (G.die_if_timed_out)
bb_error_msg_and_die("download timed out");
bb_simple_error_msg_and_die("download timed out");
}
static void set_alarm(void)
{
@@ -452,7 +452,7 @@ static char fgets_trim_sanitize(FILE *fp, const char *fmt)
set_alarm();
if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL)
bb_perror_msg_and_die("error getting response");
bb_simple_perror_msg_and_die("error getting response");
clear_alarm();
buf_ptr = strchrnul(G.wget_buf, '\n');
@@ -633,7 +633,7 @@ static char *get_sanitized_hdr(FILE *fp)
static void reset_beg_range_to_zero(void)
{
bb_error_msg("restart failed");
bb_simple_error_msg("restart failed");
G.beg_range = 0;
xlseek(G.output_fd, 0, SEEK_SET);
/* Done at the end instead: */
@@ -651,7 +651,7 @@ static int spawn_https_helper_openssl(const char *host, unsigned port)
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0)
/* Kernel can have AF_UNIX support disabled */
bb_perror_msg_and_die("socketpair");
bb_simple_perror_msg_and_die("socketpair");
if (!strchr(host, ':'))
host = allocated = xasprintf("%s:%u", host, port);
@@ -724,7 +724,7 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags)
if (!(option_mask32 & WGET_OPT_NO_CHECK_CERT)) {
option_mask32 |= WGET_OPT_NO_CHECK_CERT;
bb_error_msg("note: TLS certificate validation not implemented");
bb_simple_error_msg("note: TLS certificate validation not implemented");
}
servername = xstrdup(host);
@@ -733,7 +733,7 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags)
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0)
/* Kernel can have AF_UNIX support disabled */
bb_perror_msg_and_die("socketpair");
bb_simple_perror_msg_and_die("socketpair");
fflush_all();
pid = BB_MMU ? xfork() : xvfork();
@@ -785,7 +785,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
#endif
if (ftpcmd(NULL, NULL, sfp) != 220)
bb_error_msg_and_die("%s", G.wget_buf);
bb_simple_error_msg_and_die(G.wget_buf);
/* note: ftpcmd() sanitizes G.wget_buf, ok to print */
/* Split username:password pair */
@@ -948,7 +948,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
if (errno != EAGAIN) {
if (ferror(dfp)) {
progress_meter(PROGRESS_END);
bb_perror_msg_and_die(bb_msg_read_error);
bb_simple_perror_msg_and_die(bb_msg_read_error);
}
break; /* EOF, not error */
}
@@ -961,7 +961,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
# if ENABLE_FEATURE_WGET_TIMEOUT
if (second_cnt != 0 && --second_cnt == 0) {
progress_meter(PROGRESS_END);
bb_error_msg_and_die("download timed out");
bb_simple_error_msg_and_die("download timed out");
}
# endif
/* We used to loop back to poll here,
@@ -1014,7 +1014,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
G.got_clen = 1; /* makes it show 100% even for download of (formerly) unknown size */
progress_meter(PROGRESS_END);
if (G.content_len != 0) {
bb_perror_msg_and_die("connection closed prematurely");
bb_simple_perror_msg_and_die("connection closed prematurely");
/* GNU wget says "DATE TIME (NN MB/s) - Connection closed at byte NNN. Retrying." */
}
@@ -1348,7 +1348,7 @@ However, in real world it was observed that some web servers
}
if (key == KEY_location && status >= 300) {
if (--redir_limit == 0)
bb_error_msg_and_die("too many redirections");
bb_simple_error_msg_and_die("too many redirections");
fclose(sfp);
if (str[0] == '/') {
free(redirected_path);
+3 -3
View File
@@ -276,7 +276,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
if (inet_aton(l_opt, &net) == 0
|| (net.s_addr & htonl(IN_CLASSB_NET)) != net.s_addr
) {
bb_error_msg_and_die("invalid network address");
bb_simple_error_msg_and_die("invalid network address");
}
G.localnet_ip = ntohl(net.s_addr);
}
@@ -285,7 +285,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
if (inet_aton(r_opt, &ip) == 0
|| (ntohl(ip.s_addr) & IN_CLASSB_NET) != G.localnet_ip
) {
bb_error_msg_and_die("invalid link address");
bb_simple_error_msg_and_die("invalid link address");
}
chosen_nip = ip.s_addr;
}
@@ -473,7 +473,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
// Read ARP packet
if (safe_read(sock_fd, &p, sizeof(p)) < 0) {
bb_perror_msg_and_die(bb_msg_read_error);
bb_simple_perror_msg_and_die(bb_msg_read_error);
}
if (p.eth.ether_type != htons(ETHERTYPE_ARP))