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 {...@@ -755,8 +755,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
755 return cap * 2 / 3 + 1;755 return cap * 2 / 3 + 1;
756 }756 }
757 };757 };
758 var hash_tbl_hdr: HashTableHeader = undefined;758 const hash_tbl_hdr = try pdb_stream.stream.readStruct(HashTableHeader);
759 try pdb_stream.stream.readStruct(HashTableHeader, &hash_tbl_hdr);
760 if (hash_tbl_hdr.Capacity == 0)759 if (hash_tbl_hdr.Capacity == 0)
761 return error.InvalidDebugInfo;760 return error.InvalidDebugInfo;
762761
...@@ -790,8 +789,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {...@@ -790,8 +789,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
790 const dbi = di.pdb.dbi;789 const dbi = di.pdb.dbi;
791790
792 // Dbi Header791 // Dbi Header
793 var dbi_stream_header: pdb.DbiStreamHeader = undefined;792 const dbi_stream_header = try dbi.stream.readStruct(pdb.DbiStreamHeader);
794 try dbi.stream.readStruct(pdb.DbiStreamHeader, &dbi_stream_header);
795 const mod_info_size = dbi_stream_header.ModInfoSize;793 const mod_info_size = dbi_stream_header.ModInfoSize;
796 const section_contrib_size = dbi_stream_header.SectionContributionSize;794 const section_contrib_size = dbi_stream_header.SectionContributionSize;
797795
...@@ -800,8 +798,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {...@@ -800,8 +798,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
800 // Module Info Substream798 // Module Info Substream
801 var mod_info_offset: usize = 0;799 var mod_info_offset: usize = 0;
802 while (mod_info_offset != mod_info_size) {800 while (mod_info_offset != mod_info_size) {
803 var mod_info: pdb.ModInfo = undefined;801 const mod_info = try dbi.stream.readStruct(pdb.ModInfo);
804 try dbi.stream.readStruct(pdb.ModInfo, &mod_info);
805 var this_record_len: usize = @sizeOf(pdb.ModInfo);802 var this_record_len: usize = @sizeOf(pdb.ModInfo);
806803
807 const module_name = try dbi.readNullTermString(allocator);804 const module_name = try dbi.readNullTermString(allocator);
...@@ -845,7 +842,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {...@@ -845,7 +842,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
845 }842 }
846 while (sect_cont_offset != section_contrib_size) {843 while (sect_cont_offset != section_contrib_size) {
847 const entry = try sect_contribs.addOne();844 const entry = try sect_contribs.addOne();
848 try dbi.stream.readStruct(pdb.SectionContribEntry, entry);845 entry.* = try dbi.stream.readStruct(pdb.SectionContribEntry);
849 sect_cont_offset += @sizeOf(pdb.SectionContribEntry);846 sect_cont_offset += @sizeOf(pdb.SectionContribEntry);
850847
851 if (sect_cont_offset > section_contrib_size)848 if (sect_cont_offset > section_contrib_size)
std/io.zig+1-1
...@@ -192,7 +192,7 @@ pub fn InStream(comptime ReadError: type) type {...@@ -192,7 +192,7 @@ pub fn InStream(comptime ReadError: type) type {
192 // Only extern and packed structs have defined in-memory layout.192 // Only extern and packed structs have defined in-memory layout.
193 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);193 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
194 var res: [1]T = undefined;194 var res: [1]T = undefined;
195 return self.readNoEof(@sliceToBytes(res[0..]));195 try self.readNoEof(@sliceToBytes(res[0..]));
196 return res[0];196 return res[0];
197 }197 }
198 };198 };