Fix condition in Debug.Assert in TarEntry.cs#100860
Merged
stephentoub merged 3 commits intodotnet:mainfrom Jul 22, 2024
Merged
Conversation
The precedence of `not` is higher than of `or`, so without parentheses the actual condition was `((not RegularFile) or V7RegularFile or ContigousFile)`, which is not what this function actually expects (see switch cases and the condition in caller function).
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar |
Similar to previous commit
am11
reviewed
Apr 10, 2024
| private void CreateNonRegularFile(string filePath, string? linkTargetPath) | ||
| { | ||
| Debug.Assert(EntryType is not TarEntryType.RegularFile or TarEntryType.V7RegularFile or TarEntryType.ContiguousFile); | ||
| Debug.Assert(EntryType is not (TarEntryType.RegularFile or TarEntryType.V7RegularFile or TarEntryType.ContiguousFile)); |
Member
There was a problem hiding this comment.
nit: alternative fix is what we are using in number of places (including this file):
Suggested change
| Debug.Assert(EntryType is not (TarEntryType.RegularFile or TarEntryType.V7RegularFile or TarEntryType.ContiguousFile)); | |
| Debug.Assert(EntryType is not TarEntryType.RegularFile and not TarEntryType.V7RegularFile or TarEntryType.ContiguousFile); |
Member
|
Good catch! C# doesn't have There is another instance in the repo: could you fix it as well while at it? |
stephentoub
approved these changes
Apr 10, 2024
Contributor
Author
I fixed it before you asked (by adding second commit into this pull request). Regarding Debug.Assert (provider isn't ModuleDefinition or AssemblyDefinition);where |
3 tasks
Member
|
Thanks |
This was referenced Jul 22, 2024
Build failure: Static graph-based restore failed with exit code .* but did not log an error.
#103526
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The precedence of
notis higher than ofor, so without parentheses the actual condition was((not RegularFile) or V7RegularFile or ContigousFile), which is not what this function actually expects (see switch cases and the condition in caller function).The issue was found by Svace static analyzer: https://www.ispras.ru/en/technologies/svace/