summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/drawmouse/drawmouse.c7
-rw-r--r--src/cmd/dvd/dvd.c5
-rw-r--r--src/cmd/iochk/iochk.c15
-rw-r--r--src/cmd/netdog/nd.c7
-rw-r--r--src/cmd/netstack/ether.c3
-rw-r--r--src/cmd/netstack/fs.c3
-rw-r--r--src/cmd/netstack/ipv4.c2
-rw-r--r--src/cmd/netstack/netstack.c9
-rw-r--r--src/cmd/netstack/tcp.c5
-rw-r--r--src/cmd/netstack/udp.c3
-rw-r--r--src/cmd/netstack/util.h2
-rw-r--r--src/cmd/vterm/vterm.c3
-rw-r--r--src/cmd/vterm/vterm.h3
-rw-r--r--src/kernel/arch/amd64/driver/fsroot.c2
-rw-r--r--src/libc/compat.c4
15 files changed, 34 insertions, 39 deletions
diff --git a/src/cmd/drawmouse/drawmouse.c b/src/cmd/drawmouse/drawmouse.c
index 31a1255..c65030c 100644
--- a/src/cmd/drawmouse/drawmouse.c
+++ b/src/cmd/drawmouse/drawmouse.c
@@ -1,5 +1,6 @@
#include <camellia.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <shared/ring.h>
#include <stdbool.h>
#include <stdio.h>
@@ -9,8 +10,6 @@
#define MOUSE_SIZE 10
-#define eprintf(fmt, ...) fprintf(stderr, "drawmouse: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
struct framebuf fb, lastbehind;
struct rect dirty;
@@ -52,12 +51,12 @@ int main(void) {
char buf[64];
hid_t fd = camellia_open("/kdev/ps2/mouse", OPEN_READ);
if (fd < 0) {
- eprintf("couldn't open mouse");
+ err(1, "open");
return 1;
}
if (fb_setup(&fb, "/kdev/video/") < 0) {
- eprintf("fb_setup error");
+ err(1, "fb_setup");
return 1;
}
fb_anon(&lastbehind, MOUSE_SIZE, MOUSE_SIZE);
diff --git a/src/cmd/dvd/dvd.c b/src/cmd/dvd/dvd.c
index a15b440..b20858d 100644
--- a/src/cmd/dvd/dvd.c
+++ b/src/cmd/dvd/dvd.c
@@ -1,13 +1,12 @@
#include <camellia/execbuf.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <draw.h>
-#define eprintf(fmt, ...) fprintf(stderr, "vterm: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
struct framebuf fb;
struct rect dirty;
@@ -23,7 +22,7 @@ void draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t col) {
int main(void) {
if (fb_setup(&fb, "/kdev/video/") < 0) {
- eprintf("fb_setup error");
+ err(1, "fb_setup");
return 1;
}
int dx = 2, dy = 2, x = 100, y = 100, w = 150, h = 70;
diff --git a/src/cmd/iochk/iochk.c b/src/cmd/iochk/iochk.c
index 0850821..4483610 100644
--- a/src/cmd/iochk/iochk.c
+++ b/src/cmd/iochk/iochk.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <camellia.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -10,8 +11,6 @@
static bool verbose = false;
#define verbosef(...) do { if (verbose) printf(__VA_ARGS__); } while (0)
-#define eprintf(fmt, ...) fprintf(stderr, "iochk: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
void check(hid_t h) {
const size_t buflen = 4096;
@@ -23,14 +22,14 @@ void check(hid_t h) {
char *buflast = malloc(buflen);
char *bufcur = malloc(buflen);
if (!buflast || !bufcur) {
- eprintf("out of memory");
+ err(1, "malloc");
goto end;
}
long offlast = 0;
long retlast = _sys_read(h, buflast, buflen, offlast);
if (retlast < 0) {
- eprintf("error %ld when reading at offset %ld", retlast, offlast);
+ fprintf(stderr, "error %ld when reading at offset %ld", retlast, offlast);
goto end;
}
@@ -43,14 +42,14 @@ void check(hid_t h) {
long retcur = _sys_read(h, bufcur, buflen, offcur);
if (retcur < 0) {
- eprintf("error %ld when reading at offset %ld", retlast, offcur);
+ fprintf(stderr, "error %ld when reading at offset %ld", retlast, offcur);
break;
}
if (retcur < retlast + offlast - offcur) {
verbosef("warn: unexpected ret %ld < %ld + %ld - %ld\n", retcur, retlast, offlast, offcur);
}
if (memcmp(buflast + diff, bufcur, retlast - diff)) {
- eprintf("inconsistent read from offsets %ld and %ld", offlast, offcur);
+ fprintf(stderr, "inconsistent read from offsets %ld and %ld", offlast, offcur);
}
offlast = offcur;
@@ -79,7 +78,7 @@ int main(int argc, char **argv) {
}
}
if (optind >= argc) {
- eprintf("no files given");
+ fprintf(stderr, "usage: iochk [-v] file [files...]\n");
return 1;
}
for (; optind < argc; optind++) {
@@ -87,7 +86,7 @@ int main(int argc, char **argv) {
verbosef("checking %s...\n", path);
hid_t h = camellia_open(path, OPEN_READ);
if (h < 0) {
- eprintf("couldn't open %s", path);
+ err(1, "open %s", path);
continue;
}
check(h);
diff --git a/src/cmd/netdog/nd.c b/src/cmd/netdog/nd.c
index 2caaab9..221dc9c 100644
--- a/src/cmd/netdog/nd.c
+++ b/src/cmd/netdog/nd.c
@@ -1,12 +1,11 @@
#include <camellia.h>
#include <camellia/compat.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <stdio.h>
#include <string.h>
#include <thread.h>
-#define eprintf(fmt, ...) fprintf(stderr, "netdog: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
hid_t conn;
void send_stdin(void *arg) { (void)arg;
@@ -32,13 +31,13 @@ void recv_stdout(void *arg) { (void)arg;
int main(int argc, char **argv) {
if (argc < 2) {
- eprintf("no argument");
+ fprintf(stderr, "usage: netdog /net/connect/source/target/proto/port\n");
return 1;
}
conn = camellia_open(argv[1], OPEN_RW);
if (conn < 0) {
- eprintf("couldn't open '%s', err %u", argv[1], -conn);
+ err(1, "open %s", argv[1]);
return -conn;
}
diff --git a/src/cmd/netstack/ether.c b/src/cmd/netstack/ether.c
index 52abac2..7f3f3d4 100644
--- a/src/cmd/netstack/ether.c
+++ b/src/cmd/netstack/ether.c
@@ -1,4 +1,5 @@
#include <camellia/syscalls.h>
+#include <err.h>
#include "proto.h"
#include "util.h"
@@ -40,7 +41,7 @@ static const size_t fhoff = sizeof(size_t);
uint8_t *ether_start(size_t len, struct ethernet ether) {
if (len < 60 - Payload) len = 60 - Payload;
- if (!ether.dst) eprintf("NULL ether.dst!"); // TODO arp? i guess?
+ if (!ether.dst) warnx("null ether.dst");
if (!ether.src) ether.src = &state.mac;
uint8_t *buf = malloc(fhoff + Payload + len);
diff --git a/src/cmd/netstack/fs.c b/src/cmd/netstack/fs.c
index 6d51c35..92681ba 100644
--- a/src/cmd/netstack/fs.c
+++ b/src/cmd/netstack/fs.c
@@ -14,6 +14,7 @@
#include "util.h"
#include <camellia/flags.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -157,7 +158,7 @@ static void fs_open(hid_t reqh, char *path, int flags) {
if (ip_parse(strtok_r(NULL, "/", &save), &srcip) < 0)
respond(NULL, -1);
if (srcip != 0) {
- eprintf("unimplemented");
+ warnx("unimplemented");
respond(NULL, -1);
}
diff --git a/src/cmd/netstack/ipv4.c b/src/cmd/netstack/ipv4.c
index 1336dc1..eebd976 100644
--- a/src/cmd/netstack/ipv4.c
+++ b/src/cmd/netstack/ipv4.c
@@ -73,7 +73,7 @@ static void fragmented_tryinsert(const uint8_t *payload, size_t plen, struct ipv
struct fragmented *inc = fragmented_find(ip);
size_t off = (ip.fraginfo & FragOff) * 8;
bool last = !(ip.fraginfo & MoreFrags);
- // eprintf("fragmented packet, %u + %u, part of 0x%x", off, plen, inc);
+ // warnx("fragmented packet, %u + %u, part of 0x%x", off, plen, inc);
/* find the first fragment at a bigger offset, and insert before it */
struct fragment **insert = &inc->first;
diff --git a/src/cmd/netstack/netstack.c b/src/cmd/netstack/netstack.c
index 4cdf409..a8e011e 100644
--- a/src/cmd/netstack/netstack.c
+++ b/src/cmd/netstack/netstack.c
@@ -3,6 +3,7 @@
#include <camellia.h>
#include <camellia/compat.h>
#include <camellia/syscalls.h>
+#include <err.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
@@ -29,20 +30,20 @@ void fs_thread(void *arg);
int main(int argc, char **argv) {
if (argc < 4) {
- eprintf("usage: netstack iface ip gateway");
+ fprintf(stderr, "usage: netstack iface ip gateway\n");
return 1;
}
state.raw_h = camellia_open(argv[1], OPEN_RW);
if (state.raw_h < 0) {
- eprintf("couldn't open %s", argv[1]);
+ err(1, "open %s", argv[1]);
return 1;
}
if (ip_parse(argv[2], &state.ip) < 0) {
- eprintf("invalid ip");
+ errx(1, "invalid ip: %s", argv[2]);
return -1;
}
if (ip_parse(argv[3], &state.gateway) < 0) {
- eprintf("invalid gateway");
+ errx(1, "invalid gateway: %s", argv[2]);
return -1;
}
setproctitle(argv[2]);
diff --git a/src/cmd/netstack/tcp.c b/src/cmd/netstack/tcp.c
index d1adeab..cbe2c14 100644
--- a/src/cmd/netstack/tcp.c
+++ b/src/cmd/netstack/tcp.c
@@ -5,6 +5,7 @@
#include "proto.h"
#include "util.h"
#include <assert.h>
+#include <err.h>
#include <shared/ring.h>
enum {
@@ -123,7 +124,7 @@ struct tcp_conn *tcpc_new(
// TODO wait for ARP reply
arp_request(c->rip);
if (arpcache_get(state.gateway, &c->rmac) < 0) {
- eprintf("neither target nor gateway not in ARP cache, dropping");
+ warnx("neither target nor gateway not in ARP cache, dropping");
free(c);
return NULL;
}
@@ -222,7 +223,7 @@ void tcp_parse(const uint8_t *buf, size_t len, struct ipv4 ip) {
}
}
if (iter->lack != seq && iter->lack - 1 != seq) {
- eprintf("remote seq jumped by %d", seq - iter->lack);
+ warnx("remote seq jumped by %d", seq - iter->lack);
tcpc_sendraw(iter, FlagACK, NULL, 0);
return;
}
diff --git a/src/cmd/netstack/udp.c b/src/cmd/netstack/udp.c
index 3d560ae..285af41 100644
--- a/src/cmd/netstack/udp.c
+++ b/src/cmd/netstack/udp.c
@@ -1,5 +1,6 @@
#include "proto.h"
#include "util.h"
+#include <err.h>
enum {
SrcPort = 0,
@@ -55,7 +56,7 @@ struct udp_conn *udpc_new(
c->rport = u.dst;
if (arpcache_get(c->rip, &c->rmac) < 0) {
// TODO make arp request, wait for reply
- eprintf("not in ARP cache, unimplemented");
+ warnx("IP not in ARP cache, unimplemented");
free(c);
return NULL;
}
diff --git a/src/cmd/netstack/util.h b/src/cmd/netstack/util.h
index 0b29560..c1032a2 100644
--- a/src/cmd/netstack/util.h
+++ b/src/cmd/netstack/util.h
@@ -4,8 +4,6 @@
#include <stdlib.h>
#include <string.h>
-#define eprintf(fmt, ...) fprintf(stderr, "netstack: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
uint32_t crc32(const uint8_t *buf, size_t len);
uint16_t ip_checksum(const uint8_t *buf, size_t len);
uint16_t ip_checksumphdr(
diff --git a/src/cmd/vterm/vterm.c b/src/cmd/vterm/vterm.c
index f365f6b..97149c9 100644
--- a/src/cmd/vterm/vterm.c
+++ b/src/cmd/vterm/vterm.c
@@ -1,5 +1,6 @@
#include "vterm.h"
#include <camellia/syscalls.h>
+#include <err.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,7 +38,7 @@ void in_char(char c) {
int main(void) {
if (fb_setup(&fb, "/kdev/video/") < 0) {
- eprintf("fb_setup error");
+ err(1, "fb_setup");
return 1;
}
font_load("/init/usr/share/fonts/spleen/spleen-8x16.psfu");
diff --git a/src/cmd/vterm/vterm.h b/src/cmd/vterm/vterm.h
index 026e71a..960f089 100644
--- a/src/cmd/vterm/vterm.h
+++ b/src/cmd/vterm/vterm.h
@@ -4,9 +4,6 @@
#include <stdio.h>
#include <draw.h>
-#define eprintf(fmt, ...) fprintf(stderr, "vterm: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
-
struct psf1 {
uint16_t magic;
uint8_t mode;
diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c
index d59edf3..ed7e88c 100644
--- a/src/kernel/arch/amd64/driver/fsroot.c
+++ b/src/kernel/arch/amd64/driver/fsroot.c
@@ -16,7 +16,7 @@ static long handle(VfsReq *req) {
"com1\0"
"ps2/\0"
"ata/\0"
- "eth/\0"
+ "eth\0"
"video/";
const char *id;
int len;
diff --git a/src/libc/compat.c b/src/libc/compat.c
index fdf24bb..c7aab63 100644
--- a/src/libc/compat.c
+++ b/src/libc/compat.c
@@ -2,12 +2,10 @@
#include <stdio.h>
#include <camellia/compat.h>
-#define eprintf(fmt, ...) fprintf(stderr, "user/lib/compat: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-
static hid_t h = -1;
long c0_fs_wait(char *buf, long len, struct ufs_request *res) {
if (h != -1) {
- eprintf("didn't respond to request!");
+ fprintf(stderr, "c0_fs_wait: proc didn't respond to request\n");
c0_fs_respond(NULL, -1, 0);
}
h = _sys_fs_wait(buf, len, res);