Browse Source

buffer structs and API ssize_t -> size_t; from bgpd

OPENBSD_3_7
henning 20 years ago
parent
commit
5ab4c063ff
2 changed files with 10 additions and 10 deletions
  1. +4
    -4
      src/usr.sbin/ntpd/buffer.c
  2. +6
    -6
      src/usr.sbin/ntpd/ntpd.h

+ 4
- 4
src/usr.sbin/ntpd/buffer.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: buffer.c,v 1.4 2004/09/15 00:05:29 henning Exp $ */
/* $OpenBSD: buffer.c,v 1.5 2005/02/02 18:57:09 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -32,7 +32,7 @@ void buf_enqueue(struct msgbuf *, struct buf *);
void buf_dequeue(struct msgbuf *, struct buf *);
struct buf *
buf_open(ssize_t len)
buf_open(size_t len)
{
struct buf *buf;
@ -48,7 +48,7 @@ buf_open(ssize_t len)
}
int
buf_add(struct buf *buf, void *data, ssize_t len)
buf_add(struct buf *buf, void *data, size_t len)
{
if (buf->wpos + len > buf->size)
return (-1);
@ -127,7 +127,7 @@ msgbuf_write(struct msgbuf *msgbuf)
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
buf = next) {
next = TAILQ_NEXT(buf, entries);
if (n >= buf->size - buf->rpos) {
if (buf->rpos + n >= buf->size) {
n -= buf->size - buf->rpos;
buf_dequeue(msgbuf, buf);
} else {


+ 6
- 6
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.51 2005/01/28 12:37:20 dtucker Exp $ */
/* $OpenBSD: ntpd.h,v 1.52 2005/02/02 18:57:09 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -128,9 +128,9 @@ struct ntpd_conf {
struct buf {
TAILQ_ENTRY(buf) entries;
u_char *buf;
ssize_t size;
ssize_t wpos;
ssize_t rpos;
size_t size;
size_t wpos;
size_t rpos;
};
struct msgbuf {
@ -189,8 +189,8 @@ void fatalx(const char *);
const char * log_sockaddr(struct sockaddr *);
/* buffer.c */
struct buf *buf_open(ssize_t);
int buf_add(struct buf *, void *, ssize_t);
struct buf *buf_open(size_t);
int buf_add(struct buf *, void *, size_t);
int buf_close(struct msgbuf *, struct buf *);
void buf_free(struct buf *);
void msgbuf_init(struct msgbuf *);


Loading…
Cancel
Save