Skip to content

Commit

Permalink
Maintenance: fewer compiler warnings
Browse files Browse the repository at this point in the history
Removed compiler warnings from PowerPC.Design and Gui projects.
  • Loading branch information
uxmal committed Nov 6, 2023
1 parent 7dd251e commit abd1f6b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
10 changes: 6 additions & 4 deletions src/Arch/PowerPC.Design/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PowerPC.Design")]
[assembly: AssemblyTitle("Reko UI components for PowerPC architecture.")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PowerPC.Design")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCompany(AssemblyMetadata.Company)]
[assembly: AssemblyProduct(AssemblyMetadata.Product)]
[assembly: AssemblyCopyright(AssemblyMetadata.Copyright)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
8 changes: 4 additions & 4 deletions src/Gui/AddressSearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public SearchResultItem GetItem(int i)
var program = hit.Program;
var addr = hits[i].Address;
program.ImageMap.TryFindItem(addr, out var item);
if (program.Architecture == null)
if (program.Architecture is null)
{
return new SearchResultItem(
new string[] {
Expand All @@ -118,17 +118,17 @@ public SearchResultItem GetItem(int i)
new string[] {
program.Name ?? "<Program>",
addr.ToString(),
item.DataType != null ? item.DataType.ToString() : "<null>",
item?.DataType?.ToString() ?? "<null>",
sData,
},
ImageIndex: 0,
BackgroundColor: bgColor);
}


private static int SelectBgColor(ImageMapItem item)
private static int SelectBgColor(ImageMapItem? item)
{
if (item.DataType is UnknownType)
if (item is null || item.DataType is UnknownType)
return -1;
//$TODO: colors should come from settings.
if (item.DataType is CodeType)
Expand Down
14 changes: 7 additions & 7 deletions src/Gui/TextViewing/AbstractMixedCodeDataModel.SpanGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public LineSpan[] GetLineSpans(int count)
program.SegmentMap.TryFindSegment(curPos.Address, out var seg);
program.ImageMap.TryFindItem(curPos.Address, out var item);

SpanGenerator? sp = CreateSpanifier(item, seg.MemoryArea, curPos);
SpanGenerator? sp = CreateSpanifier(item, seg?.MemoryArea, curPos);
while (count != 0 && seg != null && item != null)
{
if (TryReadComment(out var commentLine))
Expand Down Expand Up @@ -116,7 +116,7 @@ public LineSpan[] GetLineSpans(int count)
break;
}
}
sp = CreateSpanifier(item, seg.MemoryArea, curPos);
sp = CreateSpanifier(item, seg?.MemoryArea, curPos);
}
}
curPos = SanitizePosition(curPos);
Expand All @@ -125,8 +125,8 @@ public LineSpan[] GetLineSpans(int count)
}

private SpanGenerator CreateSpanifier(
ImageMapItem item,
MemoryArea mem,
ImageMapItem? item,
MemoryArea? mem,
ModelPosition pos)
{
SpanGenerator sp;
Expand All @@ -142,7 +142,7 @@ private SpanGenerator CreateSpanifier(
}
else
{
sp = new MemSpanifyer(this,program, mem, item, pos);
sp = new MemSpanifyer(this,program, mem!, item!, pos);
}
return sp;
}
Expand Down Expand Up @@ -172,15 +172,15 @@ private class AsmSpanifyer : SpanGenerator
private readonly MachineInstruction[] instrs;
private int offset;
private ModelPosition position;
private readonly Address addrSelected;
private readonly Address? addrSelected;

public AsmSpanifyer(
AbstractMixedCodeDataModel model,
Program program,
IProcessorArchitecture arch,
MachineInstruction[] instrs,
ModelPosition pos,
Address addrSelected)
Address? addrSelected)
{
this.model = model;
this.instrs = instrs;
Expand Down
14 changes: 9 additions & 5 deletions src/Gui/TextViewing/AbstractMixedCodeDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,16 @@ public override string ToString()

public class DataItemNode
{
public Address StartAddress { get; internal set; }
public Address EndAddress { get; internal set; }
public Address? StartAddress { get; set; }
public Address? EndAddress { get; set; }
public Procedure? Proc { get; private set; }
public int NumLines { get; internal set; }
public TextModelNode ModelNode { get; set; }
public DataItemNode(Procedure? proc, int numLines) { this.Proc = proc; this.NumLines = numLines; }
public int NumLines { get; set; }
public TextModelNode? ModelNode { get; set; }
public DataItemNode(Procedure? proc, int numLines)
{
this.Proc = proc;
this.NumLines = numLines;
}
}

public Collection<DataItemNode> GetDataItemNodes()
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/ViewModels/Dialogs/SearchAreaViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void ChangeAreas(IEnumerable selectedItems)
foreach (SegmentListItemViewModel sitem in selectedItems)
{
var segment = sitem.Segment;
this.Areas.Add(SearchArea.FromSegment(program, segment));
this.Areas.Add(SearchArea.FromSegment(program, segment!));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/ViewModels/Dialogs/SegmentEditorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public bool ExecuteAccess
}
private bool executeAccess;

public object DataView
public object? DataView
{
get { return dataView; }
set { this.RaiseAndSetIfChanged(ref this.dataView, value); }
}
private object dataView;
private object? dataView;


public object? Disassembly
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/ViewModels/Documents/SegmentListItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public static SegmentListItemViewModel FromImageSegment(ImageSegment seg)
public bool IsSelected { get; set; }

public string Access { get => $"{Read}{Write}{Execute}"; }
public ImageSegment Segment { get; set; }
public ImageSegment? Segment { get; set; }
}
}

0 comments on commit abd1f6b

Please sign in to comment.