Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
radekdoulik committed Sep 13, 2024
1 parent c4f7aee commit f4d584e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public static class Extensions
{
public static string Indent(this string str, string indent)
public static string Indent(this string str, string? indent)
{
return indent + str.Replace("\n", "\n" + indent);
}
Expand Down
5 changes: 2 additions & 3 deletions WasmReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,9 @@ void ReadFunctionSection()
return name;
}

public bool GetFunctionIdx(string name, out UInt32 idx)
public bool GetFunctionIdx(string? name, out UInt32 idx)
{
if (!nameToFunction.ContainsKey(name))
if (name == null || !nameToFunction.ContainsKey(name))
{
idx = 0;
return false;
Expand Down Expand Up @@ -1434,7 +1434,6 @@ protected void PrintFunctionWithPrefix(UInt32 idx, string? name, string? prefix
if (functions == null || functionTypes == null || funcsCode == null)
return;

//Console.WriteLine($"read func {name}");
var type = functionTypes[functions[idx].TypeIdx];
Console.WriteLine($"{prefix}{type.ToString(name, true)}\n{funcsCode[idx].ToString(this, type.Parameters.Types.Length).Indent(prefix)}");
}
Expand Down
6 changes: 3 additions & 3 deletions WasmStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public string ToString(WasmReader? reader)
}
}

static string FunctionName(UInt32 idx, WasmReader? reader)
static string? FunctionName(UInt32 idx, WasmReader? reader)
{
if (reader == null)
return $"[{idx.ToString()}]";
Expand Down Expand Up @@ -310,8 +310,8 @@ struct LocalsBlock

public string ToString(int idx)
{
string varName = idx == -1 ? null : $" ${idx}";
string count = Count == 1 ? null : $" {Count}";
string? varName = idx == -1 ? null : $" ${idx}";
string? count = Count == 1 ? null : $" {Count}";
return $"local{varName}{count} {Type}";
}

Expand Down
8 changes: 4 additions & 4 deletions wa-diff/WasmDiffReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void CompareDisassembledFunctions(UInt32 idx, string? name, object? data)
{
otherName = otherReader.GetFunctionName(otherIdx);
f2 = otherReader.functions[otherIdx];
processedIndexes.Add(otherIdx);
processedIndexes?.Add(otherIdx);
}

if (f2 == null)
Expand Down Expand Up @@ -226,7 +226,7 @@ void CompareFunctionSizes(UInt32 idx, string? name, object? data)
{
otherName = otherReader.GetFunctionName(otherIdx);
f2 = otherReader.functions[otherIdx];
processedIndexes.Add(otherIdx);
processedIndexes?.Add(otherIdx);
}

if (f2 == null)
Expand All @@ -241,7 +241,7 @@ void CompareFunctionSizes(UInt32 idx, string? name, object? data)
sizeDiffs[$" {name}"] = delta;
}

static bool GetOtherIndex(string name, uint idx, WasmDiffReader other, out uint otherIdx)
static bool GetOtherIndex(string? name, uint idx, WasmDiffReader other, out uint otherIdx)
{
otherIdx = idx;
return other.HasFunctionNames && other.GetFunctionIdx(name, out otherIdx);
Expand Down Expand Up @@ -276,7 +276,7 @@ public int CompareFunctions(WasmReader other)
return 0;
}

HashSet<uint> processedIndexes;
HashSet<uint>? processedIndexes;

protected override void FilterFunctions(ProcessFunction processFunction, object? data = null)
{
Expand Down

0 comments on commit f4d584e

Please sign in to comment.