mirror of
https://github.com/tmux/tmux.git
synced 2025-01-13 03:48:51 +00:00
Nuke unused buffer functions. Found by lint.
Also remove some old debug output which was #if 0.
This commit is contained in:
parent
abb5e36199
commit
62822b1848
@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer-poll.c,v 1.11 2009-05-13 23:27:00 nicm Exp $ */
|
/* $OpenBSD: buffer-poll.c,v 1.2 2009/06/25 06:05:47 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -66,9 +66,6 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
|||||||
}
|
}
|
||||||
if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
|
if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
|
||||||
n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out));
|
n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out));
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll: fd=%d, write=%zd", pfd->fd, n);
|
|
||||||
#endif
|
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno != EINTR && errno != EAGAIN)
|
if (errno != EINTR && errno != EAGAIN)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -77,23 +74,3 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
|||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush buffer output to socket. */
|
|
||||||
void
|
|
||||||
buffer_flush(int fd, struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
struct pollfd pfd;
|
|
||||||
|
|
||||||
while (BUFFER_USED(out) > 0) {
|
|
||||||
buffer_set(&pfd, fd, in, out);
|
|
||||||
|
|
||||||
if (poll(&pfd, 1, INFTIM) == -1) {
|
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
|
||||||
continue;
|
|
||||||
fatal("poll failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_poll(&pfd, in, out) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
87
buffer.c
87
buffer.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.c,v 1.5 2008-08-07 20:20:52 nicm Exp $ */
|
/* $OpenBSD: buffer.c,v 1.2 2009/06/25 06:05:47 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -47,14 +47,6 @@ buffer_destroy(struct buffer *b)
|
|||||||
xfree(b);
|
xfree(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Empty a buffer. */
|
|
||||||
void
|
|
||||||
buffer_clear(struct buffer *b)
|
|
||||||
{
|
|
||||||
b->size = 0;
|
|
||||||
b->off = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure free space for size in buffer. */
|
/* Ensure free space for size in buffer. */
|
||||||
void
|
void
|
||||||
buffer_ensure(struct buffer *b, size_t size)
|
buffer_ensure(struct buffer *b, size_t size)
|
||||||
@ -91,18 +83,6 @@ buffer_add(struct buffer *b, size_t size)
|
|||||||
b->size += size;
|
b->size += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reverse buffer add. */
|
|
||||||
void
|
|
||||||
buffer_reverse_add(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("underflow");
|
|
||||||
|
|
||||||
b->size -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust buffer after data removed. */
|
/* Adjust buffer after data removed. */
|
||||||
void
|
void
|
||||||
buffer_remove(struct buffer *b, size_t size)
|
buffer_remove(struct buffer *b, size_t size)
|
||||||
@ -116,50 +96,6 @@ buffer_remove(struct buffer *b, size_t size)
|
|||||||
b->off += size;
|
b->off += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reverse buffer remove. */
|
|
||||||
void
|
|
||||||
buffer_reverse_remove(struct buffer *b, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->off)
|
|
||||||
fatalx("overflow");
|
|
||||||
|
|
||||||
b->size += size;
|
|
||||||
b->off -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Insert a section into the buffer. */
|
|
||||||
void
|
|
||||||
buffer_insert_range(struct buffer *b, size_t base, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (base > b->size)
|
|
||||||
fatalx("range outside buffer");
|
|
||||||
|
|
||||||
buffer_ensure(b, size);
|
|
||||||
memmove(b->base + b->off + base + size,
|
|
||||||
b->base + b->off + base, b->size - base);
|
|
||||||
b->size += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete a section from the buffer. */
|
|
||||||
void
|
|
||||||
buffer_delete_range(struct buffer *b, size_t base, size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
fatalx("zero size");
|
|
||||||
if (size > b->size)
|
|
||||||
fatalx("size too big");
|
|
||||||
if (base + size > b->size)
|
|
||||||
fatalx("range outside buffer");
|
|
||||||
|
|
||||||
memmove(b->base + b->off + base,
|
|
||||||
b->base + b->off + base + size, b->size - base - size);
|
|
||||||
b->size -= size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy data into a buffer. */
|
/* Copy data into a buffer. */
|
||||||
void
|
void
|
||||||
buffer_write(struct buffer *b, const void *data, size_t size)
|
buffer_write(struct buffer *b, const void *data, size_t size)
|
||||||
@ -194,16 +130,6 @@ buffer_write8(struct buffer *b, uint8_t n)
|
|||||||
buffer_add(b, 1);
|
buffer_add(b, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store a 16-bit value. */
|
|
||||||
void
|
|
||||||
buffer_write16(struct buffer *b, uint16_t n)
|
|
||||||
{
|
|
||||||
buffer_ensure(b, 2);
|
|
||||||
BUFFER_IN(b)[0] = n & 0xff;
|
|
||||||
BUFFER_IN(b)[1] = n >> 8;
|
|
||||||
buffer_add(b, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extract an 8-bit value. */
|
/* Extract an 8-bit value. */
|
||||||
uint8_t
|
uint8_t
|
||||||
buffer_read8(struct buffer *b)
|
buffer_read8(struct buffer *b)
|
||||||
@ -214,14 +140,3 @@ buffer_read8(struct buffer *b)
|
|||||||
buffer_remove(b, 1);
|
buffer_remove(b, 1);
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract a 16-bit value. */
|
|
||||||
uint16_t
|
|
||||||
buffer_read16(struct buffer *b)
|
|
||||||
{
|
|
||||||
uint16_t n;
|
|
||||||
|
|
||||||
n = BUFFER_OUT(b)[0] | (BUFFER_OUT(b)[1] << 8);
|
|
||||||
buffer_remove(b, 2);
|
|
||||||
return (n);
|
|
||||||
}
|
|
||||||
|
12
tmux.h
12
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: tmux.h,v 1.10 2009/06/24 22:49:56 nicm Exp $ */
|
/* $OpenBSD: tmux.h,v 1.11 2009/06/25 06:05:47 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1654,26 +1654,16 @@ char *osdep_get_name(int, char *);
|
|||||||
/* buffer.c */
|
/* buffer.c */
|
||||||
struct buffer *buffer_create(size_t);
|
struct buffer *buffer_create(size_t);
|
||||||
void buffer_destroy(struct buffer *);
|
void buffer_destroy(struct buffer *);
|
||||||
void buffer_clear(struct buffer *);
|
|
||||||
void buffer_ensure(struct buffer *, size_t);
|
void buffer_ensure(struct buffer *, size_t);
|
||||||
void buffer_add(struct buffer *, size_t);
|
void buffer_add(struct buffer *, size_t);
|
||||||
void buffer_reverse_add(struct buffer *, size_t);
|
|
||||||
void buffer_remove(struct buffer *, size_t);
|
void buffer_remove(struct buffer *, size_t);
|
||||||
void buffer_reverse_remove(struct buffer *, size_t);
|
|
||||||
void buffer_insert_range(struct buffer *, size_t, size_t);
|
|
||||||
void buffer_delete_range(struct buffer *, size_t, size_t);
|
|
||||||
void buffer_write(struct buffer *, const void *, size_t);
|
void buffer_write(struct buffer *, const void *, size_t);
|
||||||
void buffer_read(struct buffer *, void *, size_t);
|
void buffer_read(struct buffer *, void *, size_t);
|
||||||
void buffer_write8(struct buffer *, uint8_t);
|
void buffer_write8(struct buffer *, uint8_t);
|
||||||
void buffer_write16(struct buffer *, uint16_t);
|
|
||||||
uint8_t buffer_read8(struct buffer *);
|
uint8_t buffer_read8(struct buffer *);
|
||||||
uint16_t buffer_read16(struct buffer *);
|
|
||||||
|
|
||||||
/* buffer-poll.c */
|
/* buffer-poll.c */
|
||||||
void buffer_set(
|
|
||||||
struct pollfd *, int, struct buffer *, struct buffer *);
|
|
||||||
int buffer_poll(struct pollfd *, struct buffer *, struct buffer *);
|
int buffer_poll(struct pollfd *, struct buffer *, struct buffer *);
|
||||||
void buffer_flush(int, struct buffer *n, struct buffer *);
|
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
#define LOG_FACILITY LOG_DAEMON
|
#define LOG_FACILITY LOG_DAEMON
|
||||||
|
Loading…
Reference in New Issue
Block a user