@@ -242,11 +242,7 @@ struct abbrev_table {
242242 struct uint8_vector insns ;
243243};
244244
245- static void abbrev_table_init (struct abbrev_table * abbrev )
246- {
247- uint32_vector_init (& abbrev -> decls );
248- uint8_vector_init (& abbrev -> insns );
249- }
245+ #define ABBREV_TABLE_INIT { VECTOR_INIT, VECTOR_INIT }
250246
251247static void abbrev_table_deinit (struct abbrev_table * abbrev )
252248{
@@ -1310,12 +1306,10 @@ static struct drgn_error *read_cus(struct drgn_dwarf_index *dindex,
13101306
13111307 #pragma omp parallel
13121308 {
1313- struct compilation_unit_vector cus ;
1314- size_t i ;
1309+ struct compilation_unit_vector cus = VECTOR_INIT ;
13151310
1316- compilation_unit_vector_init (& cus );
13171311 #pragma omp for schedule(dynamic)
1318- for (i = 0 ; i < num_unindexed ; i ++ ) {
1312+ for (size_t i = 0 ; i < num_unindexed ; i ++ ) {
13191313 struct drgn_error * module_err ;
13201314 const char * name ;
13211315
@@ -1723,25 +1717,22 @@ read_file_name_table(struct drgn_dwarf_index *dindex,
17231717 Elf_Data * debug_line = cu -> sections [SECTION_DEBUG_LINE ];
17241718 const char * ptr = section_ptr (debug_line , stmt_list );
17251719 const char * end = section_end (debug_line );
1726- struct siphash_vector directories ;
1727-
1728- siphash_vector_init (& directories );
17291720
17301721 err = skip_lnp_header (cu , & ptr , end );
17311722 if (err )
17321723 return err ;
17331724
1725+ struct siphash_vector directories = VECTOR_INIT ;
17341726 for (;;) {
1735- struct siphash * hash ;
17361727 const char * path ;
17371728 size_t path_len ;
1738-
17391729 if (!read_string (& ptr , end , & path , & path_len ))
17401730 return drgn_eof ();
17411731 if (!path_len )
17421732 break ;
17431733
1744- hash = siphash_vector_append_entry (& directories );
1734+ struct siphash * hash =
1735+ siphash_vector_append_entry (& directories );
17451736 if (!hash ) {
17461737 err = & drgn_enomem ;
17471738 goto out ;
@@ -1753,17 +1744,14 @@ read_file_name_table(struct drgn_dwarf_index *dindex,
17531744 for (;;) {
17541745 const char * path ;
17551746 size_t path_len ;
1756- uint64_t directory_index ;
1757- struct siphash hash ;
1758- uint64_t file_name_hash ;
1759-
17601747 if (!read_string (& ptr , end , & path , & path_len )) {
17611748 err = drgn_eof ();
17621749 goto out ;
17631750 }
17641751 if (!path_len )
17651752 break ;
17661753
1754+ uint64_t directory_index ;
17671755 if ((err = read_uleb128 (& ptr , end , & directory_index )))
17681756 goto out ;
17691757 /* mtime, size */
@@ -1779,13 +1767,14 @@ read_file_name_table(struct drgn_dwarf_index *dindex,
17791767 goto out ;
17801768 }
17811769
1770+ struct siphash hash ;
17821771 if (directory_index )
17831772 hash = directories .data [directory_index - 1 ];
17841773 else
17851774 siphash_init (& hash , siphash_key );
17861775 siphash_update (& hash , path , path_len );
17871776
1788- file_name_hash = siphash_final (& hash );
1777+ uint64_t file_name_hash = siphash_final (& hash );
17891778 if (!uint64_vector_append (file_name_table , & file_name_hash )) {
17901779 err = & drgn_enomem ;
17911780 goto out ;
@@ -2059,8 +2048,8 @@ static struct drgn_error *index_cu(struct drgn_dwarf_index *dindex,
20592048 struct compilation_unit * cu )
20602049{
20612050 struct drgn_error * err ;
2062- struct abbrev_table abbrev ;
2063- struct uint64_vector file_name_table ;
2051+ struct abbrev_table abbrev = ABBREV_TABLE_INIT ;
2052+ struct uint64_vector file_name_table = VECTOR_INIT ;
20642053 Elf_Data * debug_abbrev = cu -> sections [SECTION_DEBUG_ABBREV ];
20652054 const char * debug_abbrev_end = section_end (debug_abbrev );
20662055 const char * ptr = & cu -> ptr [cu -> is_64_bit ? 23 : 11 ];
@@ -2073,9 +2062,6 @@ static struct drgn_error *index_cu(struct drgn_dwarf_index *dindex,
20732062 unsigned int depth = 0 ;
20742063 uint64_t enum_die_offset = 0 ;
20752064
2076- abbrev_table_init (& abbrev );
2077- uint64_vector_init (& file_name_table );
2078-
20792065 if ((err = read_abbrev_table (section_ptr (debug_abbrev ,
20802066 cu -> debug_abbrev_offset ),
20812067 debug_abbrev_end , cu , & abbrev )))
@@ -2265,8 +2251,8 @@ drgn_dwarf_index_report_end_internal(struct drgn_dwarf_index *dindex,
22652251 bool report_from_dwfl )
22662252{
22672253 struct drgn_error * err ;
2268- struct drgn_dwarf_module_vector unindexed ;
2269- struct compilation_unit_vector cus ;
2254+ struct drgn_dwarf_module_vector unindexed = VECTOR_INIT ;
2255+ struct compilation_unit_vector cus = VECTOR_INIT ;
22702256
22712257 dwfl_report_end (dindex -> dwfl , NULL , NULL );
22722258 if (report_from_dwfl &&
@@ -2275,8 +2261,6 @@ drgn_dwarf_index_report_end_internal(struct drgn_dwarf_index *dindex,
22752261 err = & drgn_enomem ;
22762262 goto err ;
22772263 }
2278- drgn_dwarf_module_vector_init (& unindexed );
2279- compilation_unit_vector_init (& cus );
22802264 err = drgn_dwarf_index_get_unindexed (dindex , & unindexed );
22812265 if (err )
22822266 goto err ;
0 commit comments