Skip to content

Commit

Permalink
rpmem: early return from rpmem_read if len is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
krzycz committed Apr 10, 2018
1 parent 7876719 commit 475ec27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librpmem/rpmem_fip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,6 @@ rpmem_fip_persist(struct rpmem_fip *fip, size_t offset, size_t len,
return 0;
}


int ret = 0;
while (len > 0) {
size_t tmp_len = len < fip->fi->ep_attr->max_msg_size ?
Expand Down Expand Up @@ -1306,6 +1305,10 @@ rpmem_fip_read(struct rpmem_fip *fip, void *buff, size_t len,
if (unlikely(lane >= fip->nlanes))
return EINVAL; /* it will be passed to errno */

if (unlikely(len == 0)) {
return 0;
}

size_t rd_buff_len = len < fip->fi->ep_attr->max_msg_size ?
len : fip->fi->ep_attr->max_msg_size;

Expand Down

0 comments on commit 475ec27

Please sign in to comment.