@@ -832,7 +832,8 @@ static int compute_generation_numbers(git_vector *commits)
832
832
* (size_t * )git_array_alloc (index_stack ) = i ;
833
833
834
834
while (git_array_size (index_stack )) {
835
- i = * git_array_pop (index_stack );
835
+ size_t * index_ptr = git_array_pop (index_stack );
836
+ i = * index_ptr ;
836
837
child_packed_commit = git_vector_get (commits , i );
837
838
838
839
if (commit_states [i ] == GENERATION_NUMBER_COMMIT_STATE_VISITED ) {
@@ -1017,6 +1018,7 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
1017
1018
uint64_t commit_time ;
1018
1019
uint32_t generation ;
1019
1020
uint32_t word ;
1021
+ size_t * packed_index ;
1020
1022
unsigned int parentcount = (unsigned int )git_array_size (packed_commit -> parents );
1021
1023
1022
1024
error = git_buf_put (
@@ -1026,30 +1028,38 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
1026
1028
if (error < 0 )
1027
1029
goto cleanup ;
1028
1030
1029
- if (parentcount == 0 )
1031
+ if (parentcount == 0 ) {
1030
1032
word = htonl (GIT_COMMIT_GRAPH_MISSING_PARENT );
1031
- else
1032
- word = htonl ((uint32_t )* git_array_get (packed_commit -> parent_indices , 0 ));
1033
+ } else {
1034
+ packed_index = git_array_get (packed_commit -> parent_indices , 0 );
1035
+ word = htonl ((uint32_t )* packed_index );
1036
+ }
1033
1037
error = git_buf_put (& commit_data , (const char * )& word , sizeof (word ));
1034
1038
if (error < 0 )
1035
1039
goto cleanup ;
1036
1040
1037
- if (parentcount < 2 )
1041
+ if (parentcount < 2 ) {
1038
1042
word = htonl (GIT_COMMIT_GRAPH_MISSING_PARENT );
1039
- else if (parentcount == 2 )
1040
- word = htonl ((uint32_t )* git_array_get (packed_commit -> parent_indices , 1 ));
1041
- else
1043
+ } else if (parentcount == 2 ) {
1044
+ packed_index = git_array_get (packed_commit -> parent_indices , 1 );
1045
+ word = htonl ((uint32_t )* packed_index );
1046
+ } else {
1042
1047
word = htonl (0x80000000u | extra_edge_list_count );
1048
+ }
1043
1049
error = git_buf_put (& commit_data , (const char * )& word , sizeof (word ));
1044
1050
if (error < 0 )
1045
1051
goto cleanup ;
1046
1052
1047
1053
if (parentcount > 2 ) {
1048
1054
unsigned int parent_i ;
1049
1055
for (parent_i = 1 ; parent_i < parentcount ; ++ parent_i ) {
1050
- word = htonl ((uint32_t )(
1051
- * git_array_get (packed_commit -> parent_indices , parent_i )
1052
- | (parent_i + 1 == parentcount ? 0x80000000u : 0 )));
1056
+ packed_index = git_array_get (
1057
+ packed_commit -> parent_indices , parent_i );
1058
+ word = htonl (
1059
+ (uint32_t )(* packed_index
1060
+ | (parent_i + 1 == parentcount
1061
+ ? 0x80000000u
1062
+ : 0 )));
1053
1063
error = git_buf_put (
1054
1064
& extra_edge_list ,
1055
1065
(const char * )& word ,
0 commit comments