You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

581 lines
17 KiB

  1. From 791b6de78673f005e9748983231f7260f6b69e99 Mon Sep 17 00:00:00 2001
  2. From: Marc Kleine-Budde <mkl@pengutronix.de>
  3. Date: Wed, 30 Oct 2019 11:59:49 +0100
  4. Subject: [PATCH] treewide: Fix compilation on libmusl, replace error() by
  5. err()
  6. Reported-by: Brandon Ros <brandonros1@gmail.com>
  7. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  8. ---
  9. jacd.c | 56 ++++++++++++++++++++++++++---------------------------
  10. jspy.c | 26 ++++++++++++-------------
  11. jsr.c | 28 +++++++++++++--------------
  12. libj1939.c | 4 ++--
  13. testj1939.c | 23 +++++++++++-----------
  14. 5 files changed, 68 insertions(+), 69 deletions(-)
  15. diff --git a/jacd.c b/jacd.c
  16. index 83275e2..0b7469b 100644
  17. --- a/jacd.c
  18. +++ b/jacd.c
  19. @@ -19,7 +19,7 @@
  20. #include <unistd.h>
  21. #include <getopt.h>
  22. -#include <error.h>
  23. +#include <err.h>
  24. #include <sys/time.h>
  25. #include <sys/socket.h>
  26. #include <net/if.h>
  27. @@ -154,12 +154,12 @@ static int parse_range(char *str)
  28. for (tok = strtok(str, ",;"); tok; tok = strtok(NULL, ",;")) {
  29. a0 = ae = strtoul(tok, &endp, 0);
  30. if (endp <= tok)
  31. - error(1, 0, "parsing range '%s'", tok);
  32. + err(1, "parsing range '%s'", tok);
  33. if (*endp == '-') {
  34. tok = endp+1;
  35. ae = strtoul(tok, &endp, 0);
  36. if (endp <= tok)
  37. - error(1, 0, "parsing addr '%s'", tok);
  38. + err(1, "parsing addr '%s'", tok);
  39. if (ae < a0)
  40. ae = a0;
  41. }
  42. @@ -204,21 +204,21 @@ static int open_socket(const char *device, uint64_t name)
  43. fprintf(stderr, "- socket(PF_CAN, SOCK_DGRAM, CAN_J1939);\n");
  44. sock = ret = socket(PF_CAN, SOCK_DGRAM, CAN_J1939);
  45. if (ret < 0)
  46. - error(1, errno, "socket(j1939)");
  47. + err(1, "socket(j1939)");
  48. if (s.verbose)
  49. fprintf(stderr, "- setsockopt(, SOL_SOCKET, SO_BINDTODEVICE, %s, %zd);\n", device, strlen(device));
  50. ret = setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
  51. device, strlen(device));
  52. if (ret < 0)
  53. - error(1, errno, "bindtodevice %s", device);
  54. + err(1, "bindtodevice %s", device);
  55. if (s.verbose)
  56. fprintf(stderr, "- setsockopt(, SOL_CAN_J1939, SO_J1939_FILTER, <filter>, %zd);\n", sizeof(filt));
  57. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_FILTER,
  58. &filt, sizeof(filt));
  59. if (ret < 0)
  60. - error(1, errno, "setsockopt filter");
  61. + err(1, "setsockopt filter");
  62. value = 1;
  63. if (s.verbose)
  64. @@ -226,13 +226,13 @@ static int open_socket(const char *device, uint64_t name)
  65. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_RECV_OWN,
  66. &value, sizeof(value));
  67. if (ret < 0)
  68. - error(1, errno, "setsockopt receive own msgs");
  69. + err(1, "setsockopt receive own msgs");
  70. if (s.verbose)
  71. fprintf(stderr, "- bind(, %s, %zi);\n", libj1939_addr2str(&saddr), sizeof(saddr));
  72. ret = bind(sock, (void *)&saddr, sizeof(saddr));
  73. if (ret < 0)
  74. - error(1, errno, "bind()");
  75. + err(1, "bind()");
  76. return sock;
  77. }
  78. @@ -249,7 +249,7 @@ static int repeat_address(int sock, uint64_t name)
  79. fprintf(stderr, "- send(, %" PRId64 ", 8, 0);\n", name);
  80. ret = send(sock, dat, 8, 0);
  81. if (must_warn(ret))
  82. - error(1, errno, "send address claim for 0x%02x", s.last_sa);
  83. + err(1, "send address claim for 0x%02x", s.last_sa);
  84. return ret;
  85. }
  86. static int claim_address(int sock, uint64_t name, int sa)
  87. @@ -269,7 +269,7 @@ static int claim_address(int sock, uint64_t name, int sa)
  88. fprintf(stderr, "- bind(, %s, %zi);\n", libj1939_addr2str(&saddr), sizeof(saddr));
  89. ret = bind(sock, (void *)&saddr, sizeof(saddr));
  90. if (ret < 0)
  91. - error(1, errno, "rebind with sa 0x%02x", sa);
  92. + err(1, "rebind with sa 0x%02x", sa);
  93. s.last_sa = sa;
  94. return repeat_address(sock, name);
  95. }
  96. @@ -288,7 +288,7 @@ static int request_addresses(int sock)
  97. fprintf(stderr, "- sendto(, { 0, 0xee, 0, }, %zi, 0, %s, %zi);\n", sizeof(dat), libj1939_addr2str(&saddr), sizeof(saddr));
  98. ret = sendto(sock, dat, sizeof(dat), 0, (void *)&saddr, sizeof(saddr));
  99. if (must_warn(ret))
  100. - error(1, errno, "send request for address claims");
  101. + err(1, "send request for address claims");
  102. return ret;
  103. }
  104. @@ -356,7 +356,7 @@ static void install_signal(int sig)
  105. sigfillset(&sigact.sa_mask);
  106. ret = sigaction(sig, &sigact, NULL);
  107. if (ret < 0)
  108. - error(1, errno, "sigaction for signal %i", sig);
  109. + err(1, "sigaction for signal %i", sig);
  110. }
  111. static void schedule_itimer(int msec)
  112. @@ -372,7 +372,7 @@ static void schedule_itimer(int msec)
  113. ret = setitimer(ITIMER_REAL, &val, NULL);
  114. } while ((ret < 0) && (errno == EINTR));
  115. if (ret < 0)
  116. - error(1, errno, "setitimer %i msec", msec);
  117. + err(1, "setitimer %i msec", msec);
  118. }
  119. /* dump status */
  120. @@ -413,7 +413,7 @@ static void save_cache(void)
  121. return;
  122. fp = fopen(s.cachefile, "w");
  123. if (!fp)
  124. - error(1, errno, "fopen %s, w", s.cachefile);
  125. + err(1, "fopen %s, w", s.cachefile);
  126. time(&t);
  127. fprintf(fp, "# saved on %s\n", ctime(&t));
  128. @@ -436,7 +436,7 @@ static void restore_cache(void)
  129. if (!fp) {
  130. if (ENOENT == errno)
  131. return;
  132. - error(1, errno, "fopen %s, r", s.cachefile);
  133. + err(1, "fopen %s, r", s.cachefile);
  134. }
  135. while (!feof(fp)) {
  136. ret = getline(&line, &sz, fp);
  137. @@ -486,7 +486,7 @@ int main(int argc, char *argv[])
  138. #ifdef _GNU_SOURCE
  139. asprintf(&program_invocation_name, "%s.%s", program_invocation_short_name, optarg);
  140. #else
  141. - error(0, 0, "compile with -D_GNU_SOURCE to use -p");
  142. + err(0, "compile with -D_GNU_SOURCE to use -p");
  143. #endif
  144. break;
  145. default:
  146. @@ -505,18 +505,18 @@ int main(int argc, char *argv[])
  147. ret = parse_range(s.ranges);
  148. if (!ret)
  149. - error(1, 0, "no addresses in range");
  150. + err(1, "no addresses in range");
  151. if ((s.current_sa < J1939_IDLE_ADDR) && !(addr[s.current_sa].flags & F_USE)) {
  152. if (s.verbose)
  153. - error(0, 0, "forget saved address 0x%02x", s.current_sa);
  154. + err(0, "forget saved address 0x%02x", s.current_sa);
  155. s.current_sa = J1939_IDLE_ADDR;
  156. }
  157. if (s.verbose)
  158. - error(0, 0, "ready for %s:%016llx", s.intf, (long long)s.name);
  159. + err(0, "ready for %s:%016llx", s.intf, (long long)s.name);
  160. if (!s.intf || !s.name)
  161. - error(1, 0, "bad arguments");
  162. + err(1, "bad arguments");
  163. ret = sock = open_socket(s.intf, s.name);
  164. install_signal(SIGTERM);
  165. @@ -534,7 +534,7 @@ int main(int argc, char *argv[])
  166. case STATE_INITIAL:
  167. ret = request_addresses(sock);
  168. if (ret < 0)
  169. - error(1, errno, "could not sent initial request");
  170. + err(1, "could not sent initial request");
  171. s.state = STATE_REQ_SENT;
  172. break;
  173. case STATE_REQ_PENDING:
  174. @@ -544,7 +544,7 @@ int main(int argc, char *argv[])
  175. /* claim addr */
  176. sa = choose_new_sa(s.name, s.current_sa);
  177. if (sa == J1939_IDLE_ADDR)
  178. - error(1, 0, "no free address to use");
  179. + err(1, "no free address to use");
  180. ret = claim_address(sock, s.name, sa);
  181. if (ret < 0)
  182. schedule_itimer(50);
  183. @@ -565,7 +565,7 @@ int main(int argc, char *argv[])
  184. if (ret < 0) {
  185. if (EINTR == errno)
  186. continue;
  187. - error(1, errno, "recvfrom()");
  188. + err(1, "recvfrom()");
  189. }
  190. switch (saddr.can_addr.j1939.pgn) {
  191. case 0x0ea00:
  192. @@ -577,7 +577,7 @@ int main(int argc, char *argv[])
  193. break;
  194. if (s.state == STATE_REQ_SENT) {
  195. if (s.verbose)
  196. - error(0, 0, "request sent, pending for 1250 ms");
  197. + err(0, "request sent, pending for 1250 ms");
  198. schedule_itimer(1250);
  199. s.state = STATE_REQ_PENDING;
  200. } else if (s.state == STATE_OPERATIONAL) {
  201. @@ -607,14 +607,14 @@ int main(int argc, char *argv[])
  202. /* ourselve, disable itimer */
  203. s.current_sa = sa;
  204. if (s.verbose)
  205. - error(0, 0, "claimed 0x%02x", sa);
  206. + err(0, "claimed 0x%02x", sa);
  207. } else if (sa == s.current_sa) {
  208. if (s.verbose)
  209. - error(0, 0, "address collision for 0x%02x", sa);
  210. + err(0, "address collision for 0x%02x", sa);
  211. if (s.name > saddr.can_addr.j1939.name) {
  212. sa = choose_new_sa(s.name, sa);
  213. if (sa == J1939_IDLE_ADDR) {
  214. - error(0, 0, "no address left");
  215. + err(0, "no address left");
  216. /* put J1939_IDLE_ADDR in cache file */
  217. s.current_sa = sa;
  218. goto done;
  219. @@ -639,7 +639,7 @@ int main(int argc, char *argv[])
  220. }
  221. done:
  222. if (s.verbose)
  223. - error(0, 0, "shutdown");
  224. + err(0, "shutdown");
  225. claim_address(sock, s.name, J1939_IDLE_ADDR);
  226. save_cache();
  227. return 0;
  228. diff --git a/jspy.c b/jspy.c
  229. index 6ae34d8..64bef2a 100644
  230. --- a/jspy.c
  231. +++ b/jspy.c
  232. @@ -18,7 +18,7 @@
  233. #include <unistd.h>
  234. #include <getopt.h>
  235. -#include <error.h>
  236. +#include <err.h>
  237. #include <sys/socket.h>
  238. #include <sys/ioctl.h>
  239. #include <sys/time.h>
  240. @@ -122,7 +122,7 @@ int main(int argc, char **argv)
  241. case 't':
  242. if (optarg) {
  243. if (!strchr("adzA", optarg[0]))
  244. - error(1, 0, "unknown time option '%c'", optarg[0]);
  245. + err(1, "unknown time option '%c'", optarg[0]);
  246. s.time = optarg[0];
  247. } else {
  248. s.time = 'z';
  249. @@ -137,19 +137,19 @@ int main(int argc, char **argv)
  250. optarg = argv[optind];
  251. ret = libj1939_str2addr(optarg, 0, &s.addr);
  252. if (ret < 0) {
  253. - error(0, 0, "bad URI %s", optarg);
  254. + err(0, "bad URI %s", optarg);
  255. return 1;
  256. }
  257. }
  258. buf = malloc(s.pkt_len);
  259. if (!buf)
  260. - error(1, errno, "malloc %u", s.pkt_len);
  261. + err(1, "malloc %u", s.pkt_len);
  262. /* setup socket */
  263. sock = socket(PF_CAN, SOCK_DGRAM, CAN_J1939);
  264. if (sock < 0)
  265. - error(1, errno, "socket(can, dgram, j1939)");
  266. + err(1, "socket(can, dgram, j1939)");
  267. memset(&filt, 0, sizeof(filt));
  268. if (s.addr.can_addr.j1939.name) {
  269. @@ -170,23 +170,23 @@ int main(int argc, char **argv)
  270. if (filter) {
  271. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_FILTER, &filt, sizeof(filt));
  272. if (ret < 0)
  273. - error(1, errno, "setsockopt filter");
  274. + err(1, "setsockopt filter");
  275. }
  276. if (s.promisc) {
  277. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_PROMISC, &ival_1, sizeof(ival_1));
  278. if (ret < 0)
  279. - error(1, errno, "setsockopt promisc");
  280. + err(1, "setsockopt promisc");
  281. }
  282. if (s.time) {
  283. ret = setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &ival_1, sizeof(ival_1));
  284. if (ret < 0)
  285. - error(1, errno, "setsockopt timestamp");
  286. + err(1, "setsockopt timestamp");
  287. }
  288. ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &s.pkt_len, sizeof(s.pkt_len));
  289. if (ret < 0)
  290. - error(1, errno, "setsockopt rcvbuf %u", s.pkt_len);
  291. + err(1, "setsockopt rcvbuf %u", s.pkt_len);
  292. /* bind(): to default, only ifindex is used. */
  293. memset(&src, 0, sizeof(src));
  294. @@ -197,7 +197,7 @@ int main(int argc, char **argv)
  295. src.can_addr.j1939.pgn = J1939_NO_PGN;
  296. ret = bind(sock, (void *)&src, sizeof(src));
  297. if (ret < 0)
  298. - error(1, errno, "bind(%s)", argv[1]);
  299. + err(1, "bind(%s)", argv[1]);
  300. /* these settings are static and can be held out of the hot path */
  301. iov.iov_base = &buf[0];
  302. @@ -208,7 +208,7 @@ int main(int argc, char **argv)
  303. memset(&tref, 0, sizeof(tref));
  304. if (s.verbose)
  305. - error(0, 0, "listening");
  306. + err(0, "listening");
  307. while (1) {
  308. /* these settings may be modified by recvmsg() */
  309. iov.iov_len = s.pkt_len;
  310. @@ -221,12 +221,12 @@ int main(int argc, char **argv)
  311. if (ret < 0) {
  312. switch (errno) {
  313. case ENETDOWN:
  314. - error(0, errno, "ifindex %i", s.addr.can_ifindex);
  315. + err(0, "ifindex %i", s.addr.can_ifindex);
  316. continue;
  317. case EINTR:
  318. continue;
  319. default:
  320. - error(1, errno, "recvmsg(ifindex %i)", s.addr.can_ifindex);
  321. + err(1, "recvmsg(ifindex %i)", s.addr.can_ifindex);
  322. break;
  323. }
  324. }
  325. diff --git a/jsr.c b/jsr.c
  326. index 20ea99c..3b84f0d 100644
  327. --- a/jsr.c
  328. +++ b/jsr.c
  329. @@ -17,7 +17,7 @@
  330. #include <unistd.h>
  331. #include <getopt.h>
  332. -#include <error.h>
  333. +#include <err.h>
  334. #include <poll.h>
  335. #include <sys/types.h>
  336. #include <sys/socket.h>
  337. @@ -105,7 +105,7 @@ int main(int argc, char **argv)
  338. case 's':
  339. s.pkt_len = strtoul(optarg, 0, 0);
  340. if (!s.pkt_len)
  341. - error(1, EINVAL, "packet size of %s", optarg);
  342. + err(1, "packet size of %s", optarg);
  343. break;
  344. case 'p':
  345. s.priority = strtoul(optarg, 0, 0);
  346. @@ -124,14 +124,14 @@ int main(int argc, char **argv)
  347. optarg = argv[optind++];
  348. ret = libj1939_str2addr(optarg, 0, &s.src);
  349. if (ret < 0)
  350. - error(1, 0, "bad address spec [%s]", optarg);
  351. + err(1, "bad address spec [%s]", optarg);
  352. s.defined |= DEF_SRC;
  353. }
  354. if (argv[optind]) {
  355. optarg = argv[optind++];
  356. ret = libj1939_str2addr(optarg, 0, &s.dst);
  357. if (ret < 0)
  358. - error(1, 0, "bad address spec [%s]", optarg);
  359. + err(1, "bad address spec [%s]", optarg);
  360. s.defined |= DEF_DST;
  361. }
  362. @@ -139,36 +139,36 @@ int main(int argc, char **argv)
  363. struct stat st;
  364. if (fstat(STDIN_FILENO, &st) < 0)
  365. - error(1, errno, "stat stdin, could not determine buffer size");
  366. + err(1, "stat stdin, could not determine buffer size");
  367. s.pkt_len = st.st_size ?: 1024;
  368. }
  369. /* prepare */
  370. buf = malloc(s.pkt_len);
  371. if (!buf)
  372. - error(1, errno, "malloc %u", s.pkt_len);
  373. + err(1, "malloc %u", s.pkt_len);
  374. sock = socket(PF_CAN, SOCK_DGRAM, CAN_J1939);
  375. if (sock < 0)
  376. - error(1, errno, "socket(can, dgram, j1939)");
  377. + err(1, "socket(can, dgram, j1939)");
  378. if (s.defined & DEF_PRIO) {
  379. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_SEND_PRIO, &s.priority, sizeof(s.priority));
  380. if (ret < 0)
  381. - error(1, errno, "setsockopt priority");
  382. + err(1, "setsockopt priority");
  383. }
  384. if (s.defined & DEF_SRC) {
  385. s.src.can_family = AF_CAN;
  386. ret = bind(sock, (void *)&s.src, sizeof(s.src));
  387. if (ret < 0)
  388. - error(1, errno, "bind(%s), %i", libj1939_addr2str(&s.src), -errno);
  389. + err(1, "bind(%s), %i", libj1939_addr2str(&s.src), -errno);
  390. }
  391. if (s.defined & DEF_DST) {
  392. s.dst.can_family = AF_CAN;
  393. ret = connect(sock, (void *)&s.dst, sizeof(s.dst));
  394. if (ret < 0)
  395. - error(1, errno, "connect(%s), %i", libj1939_addr2str(&s.dst), -errno);
  396. + err(1, "connect(%s), %i", libj1939_addr2str(&s.dst), -errno);
  397. }
  398. pfd[0].fd = STDIN_FILENO;
  399. @@ -182,19 +182,19 @@ int main(int argc, char **argv)
  400. if (ret < 0) {
  401. if (errno == EINTR)
  402. continue;
  403. - error(1, errno, "poll()");
  404. + err(1, "poll()");
  405. }
  406. if (pfd[0].revents) {
  407. ret = read(pfd[0].fd, buf, s.pkt_len);
  408. if (ret < 0)
  409. - error(1, errno, "read(stdin)");
  410. + err(1, "read(stdin)");
  411. if (!ret)
  412. break;
  413. len = ret;
  414. do {
  415. ret = send(pfd[1].fd, buf, len, s.sendflags);
  416. if (ret < 0)
  417. - error(errno != ENOBUFS, errno, "write(%s)",
  418. + err(errno != ENOBUFS, "write(%s)",
  419. libj1939_addr2str(&s.src));
  420. } while (ret < 0);
  421. }
  422. @@ -202,7 +202,7 @@ int main(int argc, char **argv)
  423. ret = read(pfd[1].fd, buf, s.pkt_len);
  424. if (ret < 0) {
  425. ret = errno;
  426. - error(0, errno, "read(%s)", libj1939_addr2str(&s.dst));
  427. + err(0, "read(%s)", libj1939_addr2str(&s.dst));
  428. switch (ret) {
  429. case EHOSTDOWN:
  430. break;
  431. diff --git a/libj1939.c b/libj1939.c
  432. index 5970d02..a710b73 100644
  433. --- a/libj1939.c
  434. +++ b/libj1939.c
  435. @@ -15,7 +15,7 @@
  436. #include <errno.h>
  437. #include <inttypes.h>
  438. -#include <error.h>
  439. +#include <err.h>
  440. #include <unistd.h>
  441. #include <fcntl.h>
  442. #include <net/if.h>
  443. @@ -41,7 +41,7 @@ static inline void fetch_names(void)
  444. if (!saved) {
  445. saved = if_nameindex();
  446. if (!saved)
  447. - error(1, errno, "if_nameindex()");
  448. + err(1, "if_nameindex()");
  449. }
  450. }
  451. diff --git a/testj1939.c b/testj1939.c
  452. index 83df1d2..82d3266 100644
  453. --- a/testj1939.c
  454. +++ b/testj1939.c
  455. @@ -19,7 +19,7 @@
  456. #include <unistd.h>
  457. #include <getopt.h>
  458. -#include <error.h>
  459. +#include <err.h>
  460. #include <sys/time.h>
  461. #include <sys/socket.h>
  462. #include <net/if.h>
  463. @@ -71,7 +71,7 @@ static void parse_canaddr(char *spec, struct sockaddr_can *paddr)
  464. static void onsigalrm(int sig)
  465. {
  466. - error(0, 0, "exit as requested");
  467. + err(0, "exit as requested");
  468. exit(0);
  469. }
  470. @@ -82,7 +82,7 @@ static void schedule_oneshot_itimer(double delay)
  471. it.it_value.tv_sec = delay;
  472. it.it_value.tv_usec = (long)(delay * 1e6) % 1000000;
  473. if (setitimer(ITIMER_REAL, &it, NULL) < 0)
  474. - error(1, errno, "schedule itimer %.3lfs", delay);
  475. + err(1, "schedule itimer %.3lfs", delay);
  476. }
  477. /* main */
  478. @@ -165,7 +165,7 @@ int main(int argc, char *argv[])
  479. fprintf(stderr, "- socket(PF_CAN, SOCK_DGRAM, CAN_J1939);\n");
  480. sock = ret = socket(PF_CAN, SOCK_DGRAM, CAN_J1939);
  481. if (ret < 0)
  482. - error(1, errno, "socket(j1939)");
  483. + err(1, "socket(j1939)");
  484. if (todo_prio >= 0) {
  485. if (verbose)
  486. @@ -173,23 +173,22 @@ int main(int argc, char *argv[])
  487. ret = setsockopt(sock, SOL_CAN_J1939, SO_J1939_SEND_PRIO,
  488. &todo_prio, sizeof(todo_prio));
  489. if (ret < 0)
  490. - error(1, errno, "set priority %i", todo_prio);
  491. + err(1, "set priority %i", todo_prio);
  492. }
  493. if (verbose)
  494. fprintf(stderr, "- bind(, %s, %zi);\n", libj1939_addr2str(&sockname), sizeof(sockname));
  495. ret = bind(sock, (void *)&sockname, sizeof(sockname));
  496. if (ret < 0)
  497. - error(1, errno, "bind()");
  498. -
  499. + err(1, "bind()");
  500. if (todo_connect) {
  501. if (!valid_peername)
  502. - error(1, 0, "no peername supplied");
  503. + err(1, "no peername supplied");
  504. if (verbose)
  505. fprintf(stderr, "- connect(, %s, %zi);\n", libj1939_addr2str(&peername), sizeof(peername));
  506. ret = connect(sock, (void *)&peername, sizeof(peername));
  507. if (ret < 0)
  508. - error(1, errno, "connect()");
  509. + err(1, "connect()");
  510. }
  511. if (todo_send) {
  512. @@ -218,7 +217,7 @@ int main(int argc, char *argv[])
  513. }
  514. if (ret < 0)
  515. - error(1, errno, "sendto");
  516. + err(1, "sendto");
  517. }
  518. /* main loop */
  519. @@ -240,7 +239,7 @@ int main(int argc, char *argv[])
  520. fprintf(stderr, "-\t<interrupted>\n");
  521. continue;
  522. }
  523. - error(1, errno, "recvfrom()");
  524. + err(1, "recvfrom()");
  525. }
  526. if (todo_echo) {
  527. @@ -249,7 +248,7 @@ int main(int argc, char *argv[])
  528. ret = sendto(sock, dat, ret, 0,
  529. (void *)&peername, peernamelen);
  530. if (ret < 0)
  531. - error(1, errno, "sendto");
  532. + err(1, "sendto");
  533. }
  534. if (todo_recv) {
  535. if (todo_names && peername.can_addr.j1939.name)