Skip to content

Commit

Permalink
rename some variables
Browse files Browse the repository at this point in the history
Signed-off-by: William Henderson <william.henderson@nutanix.com>
  • Loading branch information
w-henderson authored and jlevon committed Sep 15, 2023
1 parent 2348710 commit 2101ec4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions samples/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,19 @@ migration_read_data(vfu_ctx_t *vfu_ctx, void *buf, uint64_t size)
* more complex state tracking which exceeds the scope of this sample.
*/

uint32_t total_read = server_data->bar1_size;
uint32_t total_to_read = server_data->bar1_size;

if (server_data->migration.state == VFU_MIGR_STATE_STOP_AND_COPY) {
total_read += sizeof(server_data->bar0);
total_to_read += sizeof(server_data->bar0);
}

if (server_data->migration.bytes_transferred == total_read || size == 0) {
if (server_data->migration.bytes_transferred == total_to_read || size == 0) {
vfu_log(vfu_ctx, LOG_DEBUG, "no data left to read");
return 0;
}

uint32_t read_start = server_data->migration.bytes_transferred;
uint32_t read_end = MIN(read_start + size, total_read);
uint32_t read_end = MIN(read_start + size, total_to_read);
assert(read_end > read_start);

uint32_t bytes_read = read_end - read_start;
Expand Down Expand Up @@ -361,14 +361,14 @@ migration_write_data(vfu_ctx_t *vfu_ctx, void *data, uint64_t size)
assert(server_data != NULL);
assert(data != NULL);

uint32_t total_write = server_data->bar1_size + sizeof(server_data->bar0);
uint32_t total_to_write = server_data->bar1_size + sizeof(server_data->bar0);

if (server_data->migration.bytes_transferred == total_write || size == 0) {
if (server_data->migration.bytes_transferred == total_to_write || size == 0) {
return 0;
}

uint32_t write_start = server_data->migration.bytes_transferred;
uint32_t write_end = MIN(write_start + size, total_write); // exclusive
uint32_t write_end = MIN(write_start + size, total_to_write); // exclusive
assert(write_end > write_start);

uint32_t bytes_written = write_end - write_start;
Expand Down

0 comments on commit 2101ec4

Please sign in to comment.