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
9144d30848
commit
ed8350422e
@ -23,37 +23,17 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Set up pollfd for buffers. */
|
|
||||||
void
|
|
||||||
buffer_set(
|
|
||||||
struct pollfd *pfd, int fd, unused struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
pfd->fd = fd;
|
|
||||||
pfd->events = POLLIN;
|
|
||||||
if (BUFFER_USED(out) > 0)
|
|
||||||
pfd->events |= POLLOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill buffers from socket based on poll results. */
|
/* Fill buffers from socket based on poll results. */
|
||||||
int
|
int
|
||||||
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll (%ld): fd=%d, revents=%d; out=%zu in=%zu",
|
|
||||||
(long) getpid(),
|
|
||||||
pfd->fd, pfd->revents, BUFFER_USED(out), BUFFER_USED(in));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
||||||
return (-1);
|
return (-1);
|
||||||
if (pfd->revents & POLLIN) {
|
if (pfd->revents & POLLIN) {
|
||||||
buffer_ensure(in, BUFSIZ);
|
buffer_ensure(in, BUFSIZ);
|
||||||
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll: fd=%d, read=%zd", pfd->fd, n);
|
|
||||||
#endif
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
@ -64,9 +44,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);
|
||||||
@ -75,23 +52,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
85
buffer.c
85
buffer.c
@ -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);
|
|
||||||
}
|
|
||||||
|
10
tmux.h
10
tmux.h
@ -1533,26 +1533,16 @@ char *get_proc_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