diff --git a/lib/libxpc/buffer.c b/lib/libxpc/buffer.c index 594b218..9a6da88 100644 --- a/lib/libxpc/buffer.c +++ b/lib/libxpc/buffer.c @@ -52,14 +52,10 @@ kern_status_t xpc_buffer_write( return KERN_OK; } - kern_status_t status - = xpc_msg_write(buf->buf_origin, buf->buf_offset, in, to_write); - if (status != KERN_OK) { - return status; - } - - /* TODO */ - *nr_written = to_write; - - return KERN_OK; + return xpc_msg_write( + buf->buf_origin, + buf->buf_offset, + in, + to_write, + nr_written); } diff --git a/lib/libxpc/include/xpc/buffer.h b/lib/libxpc/include/xpc/buffer.h index 519cf10..47051b0 100644 --- a/lib/libxpc/include/xpc/buffer.h +++ b/lib/libxpc/include/xpc/buffer.h @@ -16,14 +16,13 @@ .buf_flags = XPC_BUFFER_F_OUT | XPC_BUFFER_F_REMOTE, \ .buf_origin = (msg), \ .buf_offset = (offset), \ - .buf_len = (size), \ + .buf_max = (size), \ } #define XPC_LOCAL_BUFFER_OUT(ptr, size) \ { \ .buf_flags = XPC_BUFFER_F_OUT, \ .buf_ptr = (ptr), \ .buf_max = (size), \ - .buf_len = (size), \ } struct xpc_msg; @@ -46,27 +45,18 @@ typedef enum xpc_buffer_flags { typedef struct xpc_buffer { xpc_buffer_flags_t buf_flags; - union { - /* fields that are only valid if F_OUT is set */ - struct { - /* only valid if F_OUT is set. specifies the maximum - * number of chars that can be written to buf_buf, - * including the null terminator. */ - size_t buf_max; - /* only valid if F_OUT is set. - * if F_FREE_ON_DISCARD is set, must be either NULL or - * allocated via xpc_context_alloc */ - void *buf_ptr; - }; - - /* fields that are only valid if F_IN is set */ - struct { - /* only valid if F_IN is set. offset of the buffer data - * within the associated message. used when reading - * buffer data from a message. */ - size_t buf_offset; - }; - }; + /* only valid if F_OUT is set. specifies the maximum + * number of chars that can be written to buf_buf, + * including the null terminator. */ + size_t buf_max; + /* only valid if F_OUT is set. + * if F_FREE_ON_DISCARD is set, must be either NULL or + * allocated via xpc_context_alloc */ + void *buf_ptr; + /* valid for F_IN and F_OUT. offset of the buffer data + * within the associated message. used when reading + * buffer data from a message. */ + size_t buf_offset; /* only valid if F_REMOTE is set. * used to read/write buffer data from/to the sender's address