authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-15 16:16:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-15 16:16:08-05:00
logba361f31c610bb97958201391f929696afd7f5aa
treec51734973b75638a87c7feaad965cf3d0b4fa1ad
parent3090f83800f936118dfd4145a5e5754b8e899f23
signaturelock-open Commit is signed but in an unrecognized format.

more fixes related to readStruct API


2 files changed, 5 insertions(+), 8 deletions(-)

std/debug/index.zig+4-7
......@@ -755,8 +755,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
755755 return cap * 2 / 3 + 1;
756756 }
757757 };
758 var hash_tbl_hdr: HashTableHeader = undefined;
759 try pdb_stream.stream.readStruct(HashTableHeader, &hash_tbl_hdr);
758 const hash_tbl_hdr = try pdb_stream.stream.readStruct(HashTableHeader);
760759 if (hash_tbl_hdr.Capacity == 0)
761760 return error.InvalidDebugInfo;
762761
......@@ -790,8 +789,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
790789 const dbi = di.pdb.dbi;
791790
792791 // Dbi Header
793 var dbi_stream_header: pdb.DbiStreamHeader = undefined;
794 try dbi.stream.readStruct(pdb.DbiStreamHeader, &dbi_stream_header);
792 const dbi_stream_header = try dbi.stream.readStruct(pdb.DbiStreamHeader);
795793 const mod_info_size = dbi_stream_header.ModInfoSize;
796794 const section_contrib_size = dbi_stream_header.SectionContributionSize;
797795
......@@ -800,8 +798,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
800798 // Module Info Substream
801799 var mod_info_offset: usize = 0;
802800 while (mod_info_offset != mod_info_size) {
803 var mod_info: pdb.ModInfo = undefined;
804 try dbi.stream.readStruct(pdb.ModInfo, &mod_info);
801 const mod_info = try dbi.stream.readStruct(pdb.ModInfo);
805802 var this_record_len: usize = @sizeOf(pdb.ModInfo);
806803
807804 const module_name = try dbi.readNullTermString(allocator);
......@@ -845,7 +842,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
845842 }
846843 while (sect_cont_offset != section_contrib_size) {
847844 const entry = try sect_contribs.addOne();
848 try dbi.stream.readStruct(pdb.SectionContribEntry, entry);
845 entry.* = try dbi.stream.readStruct(pdb.SectionContribEntry);
849846 sect_cont_offset += @sizeOf(pdb.SectionContribEntry);
850847
851848 if (sect_cont_offset > section_contrib_size)
std/io.zig+1-1
......@@ -192,7 +192,7 @@ pub fn InStream(comptime ReadError: type) type {
192192 // Only extern and packed structs have defined in-memory layout.
193193 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
194194 var res: [1]T = undefined;
195 return self.readNoEof(@sliceToBytes(res[0..]));
195 try self.readNoEof(@sliceToBytes(res[0..]));
196196 return res[0];
197197 }
198198 };