Browse Source

Use C99 types (uint32_t) instead of BSD (u_int32_t) - the former are

more portable. Add stdint.h to the headers in imsg_init(3).
No objections from millert@.
OPENBSD_6_1
nicm 7 years ago
parent
commit
df542bfce2
3 changed files with 37 additions and 37 deletions
  1. +9
    -9
      src/lib/libutil/imsg.c
  2. +13
    -14
      src/lib/libutil/imsg.h
  3. +15
    -14
      src/lib/libutil/imsg_init.3

+ 9
- 9
src/lib/libutil/imsg.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: imsg.c,v 1.13 2015/12/09 11:54:12 tb Exp $ */
/* $OpenBSD: imsg.c,v 1.14 2017/03/24 09:34:12 nicm Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -163,8 +163,8 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
} }
int int
imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, const void *data, u_int16_t datalen)
imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
int fd, const void *data, uint16_t datalen)
{ {
struct ibuf *wbuf; struct ibuf *wbuf;
@ -182,8 +182,8 @@ imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
} }
int int
imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, const struct iovec *iov, int iovcnt)
imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
int fd, const struct iovec *iov, int iovcnt)
{ {
struct ibuf *wbuf; struct ibuf *wbuf;
int i, datalen = 0; int i, datalen = 0;
@ -207,8 +207,8 @@ imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
/* ARGSUSED */ /* ARGSUSED */
struct ibuf * struct ibuf *
imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, u_int16_t datalen)
imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, pid_t pid,
uint16_t datalen)
{ {
struct ibuf *wbuf; struct ibuf *wbuf;
struct imsg_hdr hdr; struct imsg_hdr hdr;
@ -234,7 +234,7 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
} }
int int
imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
imsg_add(struct ibuf *msg, const void *data, uint16_t datalen)
{ {
if (datalen) if (datalen)
if (ibuf_add(msg, data, datalen) == -1) { if (ibuf_add(msg, data, datalen) == -1) {
@ -255,7 +255,7 @@ imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
if (msg->fd != -1) if (msg->fd != -1)
hdr->flags |= IMSGF_HASFD; hdr->flags |= IMSGF_HASFD;
hdr->len = (u_int16_t)msg->wpos;
hdr->len = (uint16_t)msg->wpos;
ibuf_close(&ibuf->w, msg); ibuf_close(&ibuf->w, msg);
} }


+ 13
- 14
src/lib/libutil/imsg.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: imsg.h,v 1.3 2013/12/26 17:32:33 eric Exp $ */
/* $OpenBSD: imsg.h,v 1.4 2017/03/24 09:34:12 nicm Exp $ */
/* /*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@ -37,7 +37,7 @@ struct ibuf {
struct msgbuf { struct msgbuf {
TAILQ_HEAD(, ibuf) bufs; TAILQ_HEAD(, ibuf) bufs;
u_int32_t queued;
uint32_t queued;
int fd; int fd;
}; };
@ -63,11 +63,11 @@ struct imsgbuf {
#define IMSGF_HASFD 1 #define IMSGF_HASFD 1
struct imsg_hdr { struct imsg_hdr {
u_int32_t type;
u_int16_t len;
u_int16_t flags;
u_int32_t peerid;
u_int32_t pid;
uint32_t type;
uint16_t len;
uint16_t flags;
uint32_t peerid;
uint32_t pid;
}; };
struct imsg { struct imsg {
@ -97,13 +97,12 @@ void msgbuf_drain(struct msgbuf *, size_t);
void imsg_init(struct imsgbuf *, int); void imsg_init(struct imsgbuf *, int);
ssize_t imsg_read(struct imsgbuf *); ssize_t imsg_read(struct imsgbuf *);
ssize_t imsg_get(struct imsgbuf *, struct imsg *); ssize_t imsg_get(struct imsgbuf *, struct imsg *);
int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, const void *, u_int16_t);
int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, const struct iovec *, int);
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
u_int16_t);
int imsg_add(struct ibuf *, const void *, u_int16_t);
int imsg_compose(struct imsgbuf *, uint32_t, uint32_t, pid_t, int,
const void *, uint16_t);
int imsg_composev(struct imsgbuf *, uint32_t, uint32_t, pid_t, int,
const struct iovec *, int);
struct ibuf *imsg_create(struct imsgbuf *, uint32_t, uint32_t, pid_t, uint16_t);
int imsg_add(struct ibuf *, const void *, uint16_t);
void imsg_close(struct imsgbuf *, struct ibuf *); void imsg_close(struct imsgbuf *, struct ibuf *);
void imsg_free(struct imsg *); void imsg_free(struct imsg *);
int imsg_flush(struct imsgbuf *); int imsg_flush(struct imsgbuf *);


+ 15
- 14
src/lib/libutil/imsg_init.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: imsg_init.3,v 1.17 2016/10/15 12:33:22 jmc Exp $
.\" $OpenBSD: imsg_init.3,v 1.18 2017/03/24 09:34:12 nicm Exp $
.\" .\"
.\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org> .\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: October 15 2016 $
.Dd $Mdocdate: March 24 2017 $
.Dt IMSG_INIT 3 .Dt IMSG_INIT 3
.Os .Os
.Sh NAME .Sh NAME
@ -48,6 +48,7 @@
.In sys/types.h .In sys/types.h
.In sys/queue.h .In sys/queue.h
.In sys/uio.h .In sys/uio.h
.In stdint.h
.In imsg.h .In imsg.h
.Ft void .Ft void
.Fn imsg_init "struct imsgbuf *ibuf" "int fd" .Fn imsg_init "struct imsgbuf *ibuf" "int fd"
@ -56,16 +57,16 @@
.Ft ssize_t .Ft ssize_t
.Fn imsg_get "struct imsgbuf *ibuf" "struct imsg *imsg" .Fn imsg_get "struct imsgbuf *ibuf" "struct imsg *imsg"
.Ft int .Ft int
.Fn imsg_compose "struct imsgbuf *ibuf" "u_int32_t type" "uint32_t peerid" \
"pid_t pid" "int fd" "const void *data" "u_int16_t datalen"
.Fn imsg_compose "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
"pid_t pid" "int fd" "const void *data" "uint16_t datalen"
.Ft int .Ft int
.Fn imsg_composev "struct imsgbuf *ibuf" "u_int32_t type" "u_int32_t peerid" \
.Fn imsg_composev "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
"pid_t pid" "int fd" "const struct iovec *iov" "int iovcnt" "pid_t pid" "int fd" "const struct iovec *iov" "int iovcnt"
.Ft "struct ibuf *" .Ft "struct ibuf *"
.Fn imsg_create "struct imsgbuf *ibuf" "u_int32_t type" "u_int32_t peerid" \
"pid_t pid" "u_int16_t datalen"
.Fn imsg_create "struct imsgbuf *ibuf" "uint32_t type" "uint32_t peerid" \
"pid_t pid" "uint16_t datalen"
.Ft int .Ft int
.Fn imsg_add "struct ibuf *buf" "const void *data" "u_int16_t datalen"
.Fn imsg_add "struct ibuf *buf" "const void *data" "uint16_t datalen"
.Ft void .Ft void
.Fn imsg_close "struct imsgbuf *ibuf" "struct ibuf *msg" .Fn imsg_close "struct imsgbuf *ibuf" "struct ibuf *msg"
.Ft void .Ft void
@ -262,11 +263,11 @@ struct imsg {
}; };
struct imsg_hdr { struct imsg_hdr {
u_int32_t type;
u_int16_t len;
u_int16_t flags;
u_int32_t peerid;
u_int32_t pid;
uint32_t type;
uint16_t len;
uint16_t flags;
uint32_t peerid;
uint32_t pid;
}; };
.Ed .Ed
.Pp .Pp
@ -329,7 +330,7 @@ struct ibuf {
struct msgbuf { struct msgbuf {
TAILQ_HEAD(, ibuf) bufs; TAILQ_HEAD(, ibuf) bufs;
u_int32_t queued;
uint32_t queued;
int fd; int fd;
}; };
.Ed .Ed


Loading…
Cancel
Save