From: guenther Date: Sun, 20 Jul 2014 06:24:19 +0000 (+0000) Subject: ring_init() can't fail X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3ea84687b6831b623436ab362742e5380bd4c2a2;p=openbsd ring_init() can't fail KNF ring.h --- diff --git a/usr.bin/telnet/network.c b/usr.bin/telnet/network.c index 07ea7d8f748..f14ad7d754f 100644 --- a/usr.bin/telnet/network.c +++ b/usr.bin/telnet/network.c @@ -1,4 +1,4 @@ -/* $OpenBSD: network.c,v 1.11 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: network.c,v 1.12 2014/07/20 06:24:19 guenther Exp $ */ /* $NetBSD: network.c,v 1.5 1996/02/28 21:04:06 thorpej Exp $ */ /* @@ -40,16 +40,12 @@ unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ]; * Initialize internal network data structures. */ - void -init_network() +void +init_network(void) { - if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) { - exit(1); - } - if (ring_init(&netiring, netibuf, sizeof netibuf) != 1) { - exit(1); - } - NetTrace = stdout; + ring_init(&netoring, netobuf, sizeof netobuf); + ring_init(&netiring, netibuf, sizeof netibuf); + NetTrace = stdout; } diff --git a/usr.bin/telnet/ring.c b/usr.bin/telnet/ring.c index d6dbbe076f7..c08f604fe4f 100644 --- a/usr.bin/telnet/ring.c +++ b/usr.bin/telnet/ring.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ring.c,v 1.6 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: ring.c,v 1.7 2014/07/20 06:24:19 guenther Exp $ */ /* $NetBSD: ring.c,v 1.7 1996/02/28 21:04:07 thorpej Exp $ */ /* @@ -80,21 +80,19 @@ static u_long ring_clock = 0; /* Buffer state transition routines */ - int +void ring_init(ring, buffer, count) Ring *ring; unsigned char *buffer; int count; { - memset((char *)ring, 0, sizeof *ring); + memset(ring, 0, sizeof *ring); ring->size = count; ring->supply = ring->consume = ring->bottom = buffer; ring->top = ring->bottom+ring->size; - - return 1; } /* Mark routines */ diff --git a/usr.bin/telnet/ring.h b/usr.bin/telnet/ring.h index 22f90b5e7b6..bc8266849de 100644 --- a/usr.bin/telnet/ring.h +++ b/usr.bin/telnet/ring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ring.h,v 1.7 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: ring.h,v 1.8 2014/07/20 06:24:19 guenther Exp $ */ /* $NetBSD: ring.h,v 1.5 1996/02/28 21:04:09 thorpej Exp $ */ /* @@ -43,42 +43,36 @@ * */ typedef struct { - unsigned char *consume, /* where data comes out of */ - *supply, /* where data comes in to */ - *bottom, /* lowest address in buffer */ - *top, /* highest address+1 in buffer */ - *mark; /* marker (user defined) */ - int size; /* size in bytes of buffer */ - u_long consumetime, /* help us keep straight full, empty, etc. */ - supplytime; + unsigned char *consume; /* where data comes out of */ + unsigned char *supply; /* where data comes in to */ + unsigned char *bottom; /* lowest address in buffer */ + unsigned char *top; /* highest address+1 in buffer */ + unsigned char *mark; /* marker (user defined) */ + int size; /* size in bytes of buffer */ + u_long consumetime; /* help us keep straight full, empty, etc. */ + u_long supplytime; } Ring; /* Here are some functions and macros to deal with the ring buffer */ /* Initialization routine */ -extern int - ring_init(Ring *ring, unsigned char *buffer, int count); +void ring_init(Ring *ring, unsigned char *buffer, int size); /* Data movement routines */ -extern void - ring_supply_data(Ring *ring, unsigned char *buffer, int count); +void ring_supply_data(Ring *ring, unsigned char *buffer, int count); /* Buffer state transition routines */ -extern void - ring_supplied(Ring *ring, int count), - ring_consumed(Ring *ring, int count); +void ring_supplied(Ring *ring, int count); +void ring_consumed(Ring *ring, int count); /* Buffer state query routines */ -extern int - ring_empty_count(Ring *ring), - ring_empty_consecutive(Ring *ring), - ring_full_count(Ring *ring), - ring_full_consecutive(Ring *ring); +int ring_empty_count(Ring *ring); +int ring_empty_consecutive(Ring *ring); +int ring_full_count(Ring *ring); +int ring_full_consecutive(Ring *ring); -extern void - ring_clear_mark(Ring *), - ring_mark(Ring *); +/* Buffer urgent data handling */ +void ring_clear_mark(Ring *); +void ring_mark(Ring *); +int ring_at_mark(Ring *); - -extern int - ring_at_mark(Ring *); diff --git a/usr.bin/telnet/terminal.c b/usr.bin/telnet/terminal.c index f6a4033ec17..f096260d7ea 100644 --- a/usr.bin/telnet/terminal.c +++ b/usr.bin/telnet/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.7 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: terminal.c,v 1.8 2014/07/20 06:24:19 guenther Exp $ */ /* $NetBSD: terminal.c,v 1.5 1996/02/28 21:04:17 thorpej Exp $ */ /* @@ -72,16 +72,12 @@ cc_t termAytChar; * initialize the terminal data structures. */ - void +void init_terminal() { - if (ring_init(&ttyoring, ttyobuf, sizeof ttyobuf) != 1) { - exit(1); - } - if (ring_init(&ttyiring, ttyibuf, sizeof ttyibuf) != 1) { - exit(1); - } - autoflush = TerminalAutoFlush(); + ring_init(&ttyoring, ttyobuf, sizeof ttyobuf); + ring_init(&ttyiring, ttyibuf, sizeof ttyibuf); + autoflush = TerminalAutoFlush(); }