Skip to content

Commit

Permalink
dm vdo index: fix various small nits
Browse files Browse the repository at this point in the history
Add braces around multi-line while loops and if statements. Also
remove excess newlines.

Signed-off-by: Mike Snitzer <[email protected]>
Signed-off-by: Chung Chung <[email protected]>
  • Loading branch information
Mike Snitzer authored and C2Redhat committed Jan 25, 2024
1 parent e508a9f commit b992e3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/c++/uds/src/uds/index-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ static void define_sub_index_nonce(struct index_layout *layout)
encode_u64_le(buffer, &offset, sil->sub_index.start_block);
encode_u16_le(buffer, &offset, 0);
sil->nonce = generate_secondary_nonce(primary_nonce, buffer, sizeof(buffer));
if (sil->nonce == 0)
if (sil->nonce == 0) {
sil->nonce = generate_secondary_nonce(~primary_nonce + 1, buffer,
sizeof(buffer));
}
}

static void setup_sub_index(struct index_layout *layout, u64 start_block,
Expand Down Expand Up @@ -655,10 +656,11 @@ STATIC int discard_index_state_data(struct index_layout *layout)
saved_result = result;
}

if (saved_result != UDS_SUCCESS)
if (saved_result != UDS_SUCCESS) {
return uds_log_error_strerror(result,
"%s: cannot destroy all index saves",
__func__);
}

return UDS_SUCCESS;
}
Expand Down Expand Up @@ -1255,9 +1257,7 @@ static int __must_check read_super_block_data(struct buffered_reader *reader,
"unknown superblock magic label");

if ((super->version < SUPER_VERSION_MINIMUM) ||
(super->version == 4) ||
(super->version == 5) ||
(super->version == 6) ||
(super->version == 4) || (super->version == 5) || (super->version == 6) ||
(super->version > SUPER_VERSION_MAXIMUM)) {
return uds_log_error_strerror(UDS_UNSUPPORTED_VERSION,
"unknown superblock version number %u",
Expand Down
3 changes: 1 addition & 2 deletions src/c++/uds/src/uds/index-page-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ void uds_get_list_number_bounds(const struct index_page_map *map, u32 chapter_nu
u32 slot = chapter_number * map->entries_per_chapter;

*lowest_list = ((index_page_number == 0) ?
0 :
map->entries[slot + index_page_number - 1] + 1);
0 : map->entries[slot + index_page_number - 1] + 1);
*highest_list = ((index_page_number < map->entries_per_chapter) ?
map->entries[slot + index_page_number] :
map->geometry->delta_lists_per_chapter - 1);
Expand Down
12 changes: 8 additions & 4 deletions src/c++/uds/src/uds/index-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,10 @@ int uds_open_index(enum uds_open_index_type open_type,
static void wait_for_no_requests_in_progress(struct uds_index_session *index_session)
{
uds_lock_mutex(&index_session->request_mutex);
while (index_session->request_count > 0)
while (index_session->request_count > 0) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
uds_unlock_mutex(&index_session->request_mutex);
}

Expand Down Expand Up @@ -624,9 +625,10 @@ int uds_close_index(struct uds_index_session *index_session)
/* Wait for any current index state change to complete. */
uds_lock_mutex(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING))
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}

if (index_session->state & IS_FLAG_SUSPENDED) {
uds_log_info("Index session is suspended");
Expand Down Expand Up @@ -665,9 +667,10 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
/* Wait for any current index state change to complete. */
uds_lock_mutex(&index_session->request_mutex);
while ((index_session->state & IS_FLAG_WAITING) ||
(index_session->state & IS_FLAG_CLOSING))
(index_session->state & IS_FLAG_CLOSING)) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}

if (index_session->state & IS_FLAG_DESTROYING) {
uds_unlock_mutex(&index_session->request_mutex);
Expand All @@ -691,9 +694,10 @@ int uds_destroy_index_session(struct uds_index_session *index_session)

/* Wait until the load exits before proceeding. */
uds_lock_mutex(&index_session->request_mutex);
while (index_session->state & IS_FLAG_LOADING)
while (index_session->state & IS_FLAG_LOADING) {
uds_wait_cond(&index_session->request_cond,
&index_session->request_mutex);
}
uds_unlock_mutex(&index_session->request_mutex);
}

Expand Down
3 changes: 1 addition & 2 deletions src/c++/uds/src/uds/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,7 @@ int uds_save_index(struct uds_index *index)
uds_wait_for_idle_index(index);
index->prev_save = index->last_save;
index->last_save = ((index->newest_virtual_chapter == 0) ?
NO_LAST_SAVE :
index->newest_virtual_chapter - 1);
NO_LAST_SAVE : index->newest_virtual_chapter - 1);
uds_log_info("beginning save (vcn %llu)", (unsigned long long) index->last_save);

result = uds_save_index_state(index->layout, index);
Expand Down

0 comments on commit b992e3a

Please sign in to comment.