Skip to content

Commit

Permalink
Address John's review comment.
Browse files Browse the repository at this point in the history
Signed-off-by: Mattias Nissler <[email protected]>
  • Loading branch information
mnissler-rivos authored and tmakatos committed Aug 30, 2023
1 parent e642111 commit 95e756a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions include/vfio-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ struct vfio_user_header {
uint16_t cmd;
uint32_t msg_size;
uint32_t flags;
#define VFIO_USER_F_TYPE 0xf
#define VFIO_USER_F_TYPE_COMMAND 0x0
#define VFIO_USER_F_TYPE_REPLY 0x1
#define VFIO_USER_F_NO_REPLY 0x10
#define VFIO_USER_F_ERROR 0x20
#define VFIO_USER_F_TYPE_MASK (0xf)
#define VFIO_USER_F_TYPE_COMMAND (0x0)
#define VFIO_USER_F_TYPE_REPLY (0x1)
#define VFIO_USER_F_NO_REPLY (0x10)
#define VFIO_USER_F_ERROR (0x20)
uint32_t error_no;
} __attribute__((packed));

Expand Down
2 changes: 1 addition & 1 deletion lib/libvfio-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ get_request_header(vfu_ctx_t *vfu_ctx, vfu_msg_t **msgp)
static bool
is_valid_header(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
{
if ((msg->hdr.flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) {
if ((msg->hdr.flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: not a command req",
msg->hdr.msg_id);
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/tran_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ tran_pipe_recv(int fd, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(EPROTO);
}

if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_REPLY) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) {
return ERROR_INT(EINVAL);
}

Expand All @@ -142,7 +142,7 @@ tran_pipe_recv(int fd, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(hdr->error_no);
}
} else {
if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
return ERROR_INT(EINVAL);
}
if (msg_id != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions lib/tran_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ tran_sock_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(EPROTO);
}

if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_REPLY) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) {
return ERROR_INT(EINVAL);
}

Expand All @@ -222,7 +222,7 @@ tran_sock_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(hdr->error_no);
}
} else {
if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
return ERROR_INT(EINVAL);
}
if (msg_id != NULL) {
Expand Down

0 comments on commit 95e756a

Please sign in to comment.