From 3169cd6591d7ee5939c7a5e96cf3c2cbf18866d3 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 6 Nov 2022 21:38:42 -0800 Subject: [PATCH] Let private methods be simpler --- BurnOutSharp.Builder/MSDOS.cs | 32 --------------------------- BurnOutSharp.Builder/NewExecutable.cs | 16 -------------- 2 files changed, 48 deletions(-) diff --git a/BurnOutSharp.Builder/MSDOS.cs b/BurnOutSharp.Builder/MSDOS.cs index 458928d2..66f8a8f9 100644 --- a/BurnOutSharp.Builder/MSDOS.cs +++ b/BurnOutSharp.Builder/MSDOS.cs @@ -63,14 +63,6 @@ namespace BurnOutSharp.Builder /// Filled executable header on success, null on error private static ExecutableHeader ParseExecutableHeader(byte[] data, int offset) { - // If we don't have enough data - if (data.Length < 28) - return null; - - // If the offset means we don't have enough data - if (data.Length - offset < 28) - return null; - // TODO: Use marshalling here instead of building var header = new ExecutableHeader(); @@ -134,14 +126,6 @@ namespace BurnOutSharp.Builder /// Filled relocation table on success, null on error private static RelocationEntry[] ParseRelocationTable(byte[] data, int offset, int count) { - // If we don't have enough data - if (data.Length < (count * 4)) - return null; - - // If the offset means we don't have enough data - if (data.Length - offset < (count * 4)) - return null; - // TODO: Use marshalling here instead of building var relocationTable = new RelocationEntry[count]; @@ -214,14 +198,6 @@ namespace BurnOutSharp.Builder /// Filled executable header on success, null on error private static ExecutableHeader ParseExecutableHeader(Stream data) { - // If we don't have enough data - if (data.Length < 28) - return null; - - // If the offset means we don't have enough data - if (data.Length - data.Position < 28) - return null; - // TODO: Use marshalling here instead of building var header = new ExecutableHeader(); @@ -284,14 +260,6 @@ namespace BurnOutSharp.Builder /// Filled relocation table on success, null on error private static RelocationEntry[] ParseRelocationTable(Stream data, int count) { - // If we don't have enough data - if (data.Length < (count * 4)) - return null; - - // If the offset means we don't have enough data - if (data.Length - data.Position < (count * 4)) - return null; - // TODO: Use marshalling here instead of building var relocationTable = new RelocationEntry[count]; diff --git a/BurnOutSharp.Builder/NewExecutable.cs b/BurnOutSharp.Builder/NewExecutable.cs index 0762cdc0..a1f8e8b8 100644 --- a/BurnOutSharp.Builder/NewExecutable.cs +++ b/BurnOutSharp.Builder/NewExecutable.cs @@ -58,14 +58,6 @@ namespace BurnOutSharp.Builder /// Filled executable header on success, null on error private static ExecutableHeader ParseExecutableHeader(byte[] data, int offset) { - // If we don't have enough data - if (data.Length < 0x40) - return null; - - // If the offset means we don't have enough data - if (data.Length - offset < 0x40) - return null; - // TODO: Use marshalling here instead of building var header = new ExecutableHeader(); @@ -176,14 +168,6 @@ namespace BurnOutSharp.Builder /// Filled executable header on success, null on error private static ExecutableHeader ParseExecutableHeader(Stream data) { - // If we don't have enough data - if (data.Length < 0x40) - return null; - - // If the offset means we don't have enough data - if (data.Length - data.Position < 0x40) - return null; - // TODO: Use marshalling here instead of building var header = new ExecutableHeader();