Skip to content

Commit

Permalink
Maintenance: reduce the number of build warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uxmal committed Aug 9, 2024
1 parent 50762a2 commit e00cb37
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 150 deletions.
2 changes: 1 addition & 1 deletion src/Arch/Telink/TC32Architecture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public TC32Architecture(IServiceProvider services, string archId, Dictionary<str
this.InstructionBitSize = 16;
this.MemoryGranularity = 8;
this.PointerType = PrimitiveType.Ptr32;
this.StackRegister = null; //$TODO
this.StackRegister = null!; //$TODO
this.WordWidth = PrimitiveType.Word32;
}

Expand Down
4 changes: 0 additions & 4 deletions src/Core/IRFormat/ParserException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,5 @@ public ParserException(string? message) : base(message)
public ParserException(string? message, Exception? innerException) : base(message, innerException)
{
}

protected ParserException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
6 changes: 3 additions & 3 deletions src/Core/Lib/SuffixArray2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SuffixArray2
{

// Structure to store information of a suffix
struct suffix
struct Suffix
{
public int index; // Original index
public short rank0; // Rank
Expand All @@ -20,7 +20,7 @@ struct suffix

// A comparison function used by sort() to compare two suffixes
// Compares two pairs, returns 1 if first pair is smaller
static int cmp(suffix a, suffix b)
static int cmp(Suffix a, Suffix b)
{
return (a.rank0 == b.rank0)
? (a.rank1 - b.rank1)
Expand All @@ -33,7 +33,7 @@ static int[] buildSuffixArray(byte[] txt)
{
int n = txt.Length;
// A structure to store suffixes and their indexes
suffix[] suffixes = new suffix[n];
Suffix[] suffixes = new Suffix[n];
var sw = new Stopwatch();
sw.Start();
// Store suffixes and their indexes in an array of structures.
Expand Down
2 changes: 1 addition & 1 deletion src/Decompiler/Analysis/FpuStackReturnGuesser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public bool Transform(RegisterStorage fpuStack)
// that FPU stack was preserved. Assume that offset is -1
// otherwise.
int delta = WasUsed(sid) ? -1 : 0;
bool changed = ssam.AdjustRegisterAfterCall(callStm, ci, fpuStack, delta);
changed = ssam.AdjustRegisterAfterCall(callStm, ci, fpuStack, delta);
var fpuDefs = CreateFpuStackTemporaryBindings(delta);
changed |= fpuDefs.Count > 0;
AddFpuToCallDefs(fpuDefs, callStm, ci);
Expand Down
3 changes: 0 additions & 3 deletions src/Decompiler/Scanning/FetFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public class FetFinder : AbstractBaseAddressFinder
private readonly BigInteger wordMask;

private uint word_size;
private uint uAddrMax;
private uint uAddrMin;


public FetFinder(
IProcessorArchitecture arch,
Expand Down
18 changes: 9 additions & 9 deletions src/Decompiler/Scanning/ScanResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public ScanResults()
this.TransferTargets = new HashSet<Address>();
this.DirectlyCalledAddresses = new Dictionary<Address, int>();
this.Instructions = new Dictionary<Address, RtlInstructionCluster>();
this.FlatInstructions = new Dictionary<ulong, ScanResults.instr>();
this.FlatEdges = new List<link>();
this.FlatInstructions = new Dictionary<ulong, ScanResults.Instr>();
this.FlatEdges = new List<Link>();
this.IndirectCalls = new HashSet<Address>();
this.IndirectJumps = new HashSet<Address>();
this.Procedures = new List<RtlProcedure>();
Expand Down Expand Up @@ -98,8 +98,8 @@ public ScanResults()
/// This is a key end result of the scanning stage.
/// </summary>
public List<RtlProcedure> Procedures { get; set; }
public Dictionary<ulong, instr> FlatInstructions { get; set; }
public List<link> FlatEdges { get; set; }
public Dictionary<ulong, Instr> FlatInstructions { get; set; }
public List<Link> FlatEdges { get; set; }

/// <summary>
/// All the places that were identified as padding.
Expand Down Expand Up @@ -180,7 +180,7 @@ public void Dump(string caption = "Dump")
#endif
}

public class instr
public class Instr
{
public Address addr;
public int size;
Expand All @@ -191,14 +191,14 @@ public class instr
public RtlInstructionCluster rtl;
}

public class link
public class Link
{
public Address first;
public Address second;

public override bool Equals(object obj)
{
if (!(obj is link that))
if (!(obj is Link that))
return false;
return that.first == this.first && that.second == this.second;
}
Expand All @@ -214,11 +214,11 @@ public override string ToString()
}
}

public class block
public class Block
{
public Address id; // Address of block
public Address component_id; // Component we're part of.
public instr[] instrs; // The instructions of the block.
public Instr[] instrs; // The instructions of the block.
}

[Conditional("DEBUG")]
Expand Down
36 changes: 18 additions & 18 deletions src/Decompiler/Scanning/ScannerInLinq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

namespace Reko.Scanning
{
using block = ScanResults.block;
using instr = ScanResults.instr;
using link = ScanResults.link;
using Block = ScanResults.Block;
using Instr = ScanResults.Instr;
using Link = ScanResults.Link;

public class ScannerInLinq
{
Expand Down Expand Up @@ -307,7 +307,7 @@ public static void Probe(ScanResults sr)
/// 1 predecessor or successors. These instructions delimit the start and
/// end of the basic blocks.
/// </summary>
public static Dictionary<Address, block> BuildBasicBlocks(ScanResults sr)
public static Dictionary<Address, Block> BuildBasicBlocks(ScanResults sr)
{
// Count and save the # of successors for each instruction.
foreach (var cSucc in
Expand All @@ -328,14 +328,14 @@ group link by link.second into g
instr.pred = cPred.Count;
}

var the_excluded_edges = new HashSet<link>();
var the_excluded_edges = new HashSet<Link>();
foreach (var instr in sr.FlatInstructions.Values)
{
// All blocks must start with a linear instruction.
if ((instr.type & (ushort)InstrClass.Linear) == 0)
continue;
// Find the instruction that is located directly after instr.
if (!sr.FlatInstructions.TryGetValue(instr.addr.ToLinear() + (uint) instr.size, out instr? succ))
if (!sr.FlatInstructions.TryGetValue(instr.addr.ToLinear() + (uint) instr.size, out Instr? succ))
continue;
// If the first instruction was padding the next one must also be padding,
// otherwise we start a new block.
Expand All @@ -357,15 +357,15 @@ group link by link.second into g
!sr.DirectlyCalledAddresses.ContainsKey(succ.addr))
{
succ.block_id = instr.block_id;
the_excluded_edges.Add(new link { first = instr.addr, second = succ.addr });
the_excluded_edges.Add(new Link { first = instr.addr, second = succ.addr });
}
}

// Build the blocks by grouping the instructions.
var the_blocks =
(from i in sr.FlatInstructions.Values
group i by i.block_id into g
select new block
select new Block
{
id = g.Key,
instrs = g.OrderBy(ii => ii.addr).ToArray()
Expand All @@ -376,7 +376,7 @@ group i by i.block_id into g
(from link in sr.FlatEdges
join f in sr.FlatInstructions.Values on link.first equals f.addr
where !the_excluded_edges.Contains(link)
select new link { first = f.block_id, second = link.second })
select new Link { first = f.block_id, second = link.second })
.Distinct()
.ToList();
return the_blocks;
Expand All @@ -387,7 +387,7 @@ join f in sr.FlatInstructions.Values on link.first equals f.addr
/// are invalid.
/// </summary>
/// <returns>A (hopefully smaller) set of blocks.</returns>
public static Dictionary<Address, block> RemoveInvalidBlocks(ScanResults sr, Dictionary<Address, block> blocks)
public static Dictionary<Address, Block> RemoveInvalidBlocks(ScanResults sr, Dictionary<Address, Block> blocks)
{
// Find transitive closure of bad instructions

Expand Down Expand Up @@ -444,7 +444,7 @@ public static Dictionary<Address, block> RemoveInvalidBlocks(ScanResults sr, Dic
return blocks;
}

private static bool BlockEndsWithCall(block block)
private static bool BlockEndsWithCall(Block block)
{
int len = block.instrs.Length;
if (len < 1)
Expand All @@ -457,7 +457,7 @@ private static bool BlockEndsWithCall(block block)
public static DiGraph<RtlBlock> BuildIcfg(
ScanResults sr,
NamingPolicy namingPolicy,
Dictionary<Address, block> blocks)
Dictionary<Address, Block> blocks)
{
var icfg = new DiGraph<RtlBlock>();
var map = new Dictionary<Address, RtlBlock>();
Expand Down Expand Up @@ -501,13 +501,13 @@ select string.Format(
e)));
}

private void DumpBlocks(ScanResults sr, Dictionary<Address, block> blocks)
private void DumpBlocks(ScanResults sr, Dictionary<Address, Block> blocks)
{
DumpBlocks(sr, blocks, s => Debug.WriteLine(s));
}

// Writes the start and end addresses, size, and successor edges of each block,
public void DumpBlocks(ScanResults sr, Dictionary<Address, block> blocks, Action<string> writeLine)
public void DumpBlocks(ScanResults sr, Dictionary<Address, Block> blocks, Action<string> writeLine)
{
writeLine(
string.Join(Environment.NewLine,
Expand Down Expand Up @@ -546,7 +546,7 @@ static string RenderType(ushort type)
}
}

private static void DumpBadBlocks(ScanResults sr, Dictionary<long, block> blocks, IEnumerable<link> edges, HashSet<Address> bad_blocks)
private static void DumpBadBlocks(ScanResults sr, Dictionary<long, Block> blocks, IEnumerable<Link> edges, HashSet<Address> bad_blocks)
{
Debug.Print(
"{0}",
Expand All @@ -570,7 +570,7 @@ select string.Format(
}

[Conditional("DEBUG")]
private static void Dump(Dictionary<long, block> the_blocks)
private static void Dump(Dictionary<long, Block> the_blocks)
{
foreach (var block in the_blocks.Values)
{
Expand All @@ -579,7 +579,7 @@ private static void Dump(Dictionary<long, block> the_blocks)
}

[Conditional("DEBUG")]
private static void Dump(IEnumerable<link> edges)
private static void Dump(IEnumerable<Link> edges)
{
foreach (var link in edges)
{
Expand All @@ -588,7 +588,7 @@ private static void Dump(IEnumerable<link> edges)
}

[Conditional("DEBUG")]
private static void Dump(IEnumerable<instr> blocks)
private static void Dump(IEnumerable<Instr> blocks)
{
foreach (var i in blocks)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Decompiler/Scanning/ShingledScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public byte[] ScanRange(IProcessorArchitecture arch, MemoryArea mem, Address add

private void AddInstruction(RtlInstructionCluster i)
{
sr.FlatInstructions.Add(i.Address.ToLinear(), new ScanResults.instr
sr.FlatInstructions.Add(i.Address.ToLinear(), new ScanResults.Instr
{
addr = i.Address,
size = i.Length,
Expand All @@ -303,7 +303,7 @@ public void AddEdge(Address from, Address to)
{
if (from == Bad)
return;
sr.FlatEdges.Add(new ScanResults.link
sr.FlatEdges.Add(new ScanResults.Link
{
first = to,
second = from,
Expand Down
6 changes: 0 additions & 6 deletions src/Environments/PalmOS/Traps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,17 +1412,11 @@ private static DataType GetPointerParameter(ReadOnlySpan<char> a)

private static DataType CreateParameterType(string arg)
{
bool output;
int a = 0;
if (arg[0] == 'o')
{
output = true;
a++;
}
else
{
output = false;
}

DataType dt;
if (arg.Length == a + 1)
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/ISearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public interface ISearchResultView

void AddColumn(string columnTitle, int width);
void Invalidate();
Task<string> ShowTypeMarker(Program program, Address addr);
Task<string?> ShowTypeMarker(Program program, Address addr);
}
}
10 changes: 5 additions & 5 deletions src/Gui/TextViewing/DisassemblyFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class DisassemblyFormatter : MachineInstructionRenderer
private List<ITextSpan> line;
private List<string> annotations;
private string mnemonicStyle;
private Address addrInstr;

public DisassemblyFormatter(
TextSpanFactory factory,
Expand All @@ -57,11 +56,10 @@ public DisassemblyFormatter(
this.mnemonicStyle = Gui.Services.UiStyles.DisassemblerOpcode;
}

public Address Address => addrInstr;
public Address Address => instr.Address;

public void BeginInstruction(Address addr)
{
this.addrInstr = addr;
}

public void EndInstruction()
Expand Down Expand Up @@ -130,7 +128,7 @@ public void WriteUInt32(uint n)
sb.Append(n);
}

public void WriteString(string s)
public void WriteString(string? s)
{
sb.Append(s);
}
Expand All @@ -140,8 +138,10 @@ public void WriteFormat(string fmt, params object[] parms)
sb.AppendFormat(fmt, parms);
}

public void AddAnnotation(string annotation)
public void AddAnnotation(string? annotation)
{
if (annotation is null)
return;
this.annotations.Add(annotation);
}

Expand Down
12 changes: 6 additions & 6 deletions src/ImageLoaders/Coff/eCoff/BeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Reko.ImageLoaders.Coff.eCoff
{
public class BeLoader : ProgramImageLoader
{
private aouthdr? opthdr;
private AOuthdr? opthdr;

public BeLoader(IServiceProvider services, ImageLocation imageLocation, byte[] rawImage)
: base(services, imageLocation, rawImage)
Expand All @@ -46,17 +46,17 @@ public BeLoader(IServiceProvider services, ImageLocation imageLocation, byte[] r
public override Program LoadProgram(Address? addrLoad)
{
var rdr = new BeImageReader(RawImage);
var header = rdr.ReadStruct<filehdr>();
var header = rdr.ReadStruct<Filehdr>();
if (header.f_opthdr != 0)
{
var sectionOffset = rdr.Offset + header.f_opthdr;
opthdr = rdr.ReadStruct<aouthdr>();
opthdr = rdr.ReadStruct<AOuthdr>();
rdr.Offset = sectionOffset;
}
var sections = new scnhdr[header.f_nscns];
var sections = new Scnhdr[header.f_nscns];
for (int i = 0; i < sections.Length; ++i)
{
sections[i] = rdr.ReadStruct<scnhdr>();
sections[i] = rdr.ReadStruct<Scnhdr>();
}
var imgSegments = new ImageSegment[header.f_nscns];
for (int i = 0; i < sections.Length; ++i)
Expand All @@ -77,7 +77,7 @@ public override Program LoadProgram(Address? addrLoad)
return program;
}

private ImageSegment LoadImageSegment(in scnhdr scnhdr)
private ImageSegment LoadImageSegment(in Scnhdr scnhdr)
{
var bytes = new byte[scnhdr.s_size];
var availableBytes = RawImage.Length - scnhdr.s_scnptr;
Expand Down
Loading

0 comments on commit e00cb37

Please sign in to comment.