@@ -52,8 +52,11 @@ static void write_table(char ***names, struct strbuf *buf, int N,
5252 int i ;
5353
5454 REFTABLE_CALLOC_ARRAY (* names , N + 1 );
55+ check (* names != NULL );
5556 REFTABLE_CALLOC_ARRAY (refs , N );
57+ check (refs != NULL );
5658 REFTABLE_CALLOC_ARRAY (logs , N );
59+ check (logs != NULL );
5760
5861 for (i = 0 ; i < N ; i ++ ) {
5962 refs [i ].refname = (* names )[i ] = xstrfmt ("refs/heads/branch%02d" , i );
@@ -150,23 +153,25 @@ static void t_log_overflow(void)
150153
151154static void t_log_write_read (void )
152155{
153- int N = 2 ;
154- char * * names = reftable_calloc (N + 1 , sizeof (* names ));
155- int err ;
156156 struct reftable_write_options opts = {
157157 .block_size = 256 ,
158158 };
159159 struct reftable_ref_record ref = { 0 };
160- int i = 0 ;
161160 struct reftable_log_record log = { 0 };
162- int n ;
163161 struct reftable_iterator it = { 0 };
164162 struct reftable_reader * reader ;
165163 struct reftable_block_source source = { 0 };
166164 struct strbuf buf = STRBUF_INIT ;
167165 struct reftable_writer * w = t_reftable_strbuf_writer (& buf , & opts );
168166 const struct reftable_stats * stats = NULL ;
167+ int N = 2 , err , i , n ;
168+ char * * names ;
169+
170+ names = reftable_calloc (N + 1 , sizeof (* names ));
171+ check (names != NULL );
172+
169173 reftable_writer_set_limits (w , 0 , N );
174+
170175 for (i = 0 ; i < N ; i ++ ) {
171176 char name [256 ];
172177 struct reftable_ref_record ref = { 0 };
@@ -178,6 +183,7 @@ static void t_log_write_read(void)
178183 err = reftable_writer_add_ref (w , & ref );
179184 check (!err );
180185 }
186+
181187 for (i = 0 ; i < N ; i ++ ) {
182188 struct reftable_log_record log = { 0 };
183189
@@ -476,24 +482,23 @@ static void t_table_read_write_seek_index(void)
476482
477483static void t_table_refs_for (int indexed )
478484{
479- int N = 50 ;
480- char * * want_names = reftable_calloc (N + 1 , sizeof (* want_names ));
485+ char * * want_names ;
481486 int want_names_len = 0 ;
482487 uint8_t want_hash [GIT_SHA1_RAWSZ ];
483488
484489 struct reftable_write_options opts = {
485490 .block_size = 256 ,
486491 };
487492 struct reftable_ref_record ref = { 0 };
488- int i = 0 ;
489- int n ;
490- int err ;
491493 struct reftable_reader * reader ;
492494 struct reftable_block_source source = { 0 };
493495 struct strbuf buf = STRBUF_INIT ;
494496 struct reftable_writer * w = t_reftable_strbuf_writer (& buf , & opts );
495497 struct reftable_iterator it = { 0 };
496- int j ;
498+ int N = 50 , n , j , err , i ;
499+
500+ want_names = reftable_calloc (N + 1 , sizeof (* want_names ));
501+ check (want_names != NULL );
497502
498503 t_reftable_set_hash (want_hash , 4 , GIT_SHA1_FORMAT_ID );
499504
0 commit comments