Skip to content

Commit 9ae82ff

Browse files
committed
Update packages
1 parent fae04bf commit 9ae82ff

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

package/simple-radvd/src/simple-radvd.c

+19-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define _GNU_SOURCE
2828

2929
#include <errno.h>
30-
#include <error.h>
3130
#include <ifaddrs.h>
3231
#include <fcntl.h>
3332
#include <poll.h>
@@ -107,11 +106,12 @@ static struct global {
107106

108107

109108
static inline void exit_errno(const char *message) {
110-
error(1, errno, "error: %s", message);
109+
fprintf(stderr, "error: %s: %s\n", message, strerror(errno));
110+
exit(1);
111111
}
112112

113113
static inline void warn_errno(const char *message) {
114-
error(0, errno, "warning: %s", message);
114+
fprintf(stderr, "warning: %s: %s\n", message, strerror(errno));
115115
}
116116

117117

@@ -370,7 +370,8 @@ static void handle_rtnl(void) {
370370
return;
371371

372372
case NLMSG_ERROR:
373-
error(1, 0, "error: netlink error");
373+
fprintf(stderr, "error: netlink error");
374+
exit(1);
374375

375376
default:
376377
if (handle_rtnl_msg(nh->nlmsg_type, NLMSG_DATA(nh))) {
@@ -545,8 +546,10 @@ static void usage(void) {
545546
}
546547

547548
static void add_prefix(const char *prefix) {
548-
if (G.n_prefixes == MAX_PREFIXES)
549-
error(1, 0, "maximum number of prefixes is %i.", MAX_PREFIXES);
549+
if (G.n_prefixes == MAX_PREFIXES) {
550+
fprintf(stderr, "maximum number of prefixes is %i.", MAX_PREFIXES);
551+
exit(1);
552+
}
550553

551554
const size_t len = strlen(prefix)+1;
552555
char prefix2[len];
@@ -570,16 +573,19 @@ static void add_prefix(const char *prefix) {
570573
return;
571574

572575
error:
573-
error(1, 0, "invalid prefix %s (only prefixes of length 64 are supported).", prefix);
576+
fprintf(stderr, "invalid prefix %s (only prefixes of length 64 are supported).", prefix);
577+
exit(1);
574578
}
575579

576580
static void parse_cmdline(int argc, char *argv[]) {
577581
int c;
578582
while ((c = getopt(argc, argv, "i:p:h")) != -1) {
579583
switch(c) {
580584
case 'i':
581-
if (G.ifname)
582-
error(1, 0, "multiple interfaces are not supported.");
585+
if (G.ifname) {
586+
fprintf(stderr, "multiple interfaces are not supported.");
587+
exit(1);
588+
}
583589

584590
G.ifname = optarg;
585591

@@ -603,8 +609,10 @@ static void parse_cmdline(int argc, char *argv[]) {
603609
int main(int argc, char *argv[]) {
604610
parse_cmdline(argc, argv);
605611

606-
if (!G.ifname || !G.n_prefixes)
607-
error(1, 0, "interface and prefix arguments are required.");
612+
if (!G.ifname || !G.n_prefixes) {
613+
fprintf(stderr, "interface and prefix arguments are required.");
614+
exit(1);
615+
}
608616

609617
init_random();
610618
init_icmp();

package/simple-tc/src/simple-tc.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define _GNU_SOURCE
2828

2929
#include <errno.h>
30-
#include <error.h>
3130
#include <stdbool.h>
3231
#include <stdio.h>
3332
#include <stdlib.h>
@@ -62,11 +61,12 @@ static int nlerror;
6261

6362

6463
static inline void exit_errno(const char *message) {
65-
error(1, errno, "error: %s", message);
64+
fprintf(stderr, "error: %s: %s\n", message, strerror(errno));
65+
exit(1);
6666
}
6767

6868
static inline void warn_errno(const char *message) {
69-
error(0, errno, "warning: %s", message);
69+
fprintf(stderr, "warning: %s: %s\n", message, strerror(errno));
7070
}
7171

7272

@@ -124,8 +124,8 @@ static bool do_send(struct nl_msg *msg, bool expect) {
124124
nl_wait_for_ack(sock);
125125

126126
if (nlerror) {
127-
error(0, nlerror, "netlink");
128127
errno = nlerror;
128+
warn_errno("netlink");
129129
return false;
130130
}
131131

@@ -233,7 +233,8 @@ static inline void usage(void) {
233233
}
234234

235235
static inline void maxrate(void) {
236-
error(1, 0, "error: maximum allowed rate it about 2^25 Kbit/s");
236+
fprintf(stderr, "error: maximum allowed rate it about 2^25 Kbit/s");
237+
exit(1);
237238
}
238239

239240

@@ -245,8 +246,10 @@ int main(int argc, char *argv[]) {
245246
char *end;
246247

247248
ifindex = if_nametoindex(argv[1]);
248-
if (!ifindex)
249-
error(1, 0, "invalid interface: %s", argv[1]);
249+
if (!ifindex) {
250+
fprintf(stderr, "invalid interface: %s", argv[1]);
251+
exit(1);
252+
}
250253

251254
if (strcmp(argv[2], "-") != 0) {
252255
ingress = strtod(argv[2], &end);

0 commit comments

Comments
 (0)