Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an incorrect check #316

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Conversation

res2k
Copy link
Contributor

@res2k res2k commented Sep 7, 2023

...introduced in 0f5ef84

An input check condition required some tweaking which was missed when porting a commit.

An input check condition required some tweaking which was missed when porting a commit.
@apanteleev apanteleev merged commit 3e700ab into NVIDIA:master Sep 8, 2023
2 checks passed
@apanteleev
Copy link
Collaborator

Merged, but can you please explain what's the idea behind negative bits? I see its sign being removed right at the beginning of the function, but some places actually call MSG_WriteBits with negative bits. Why?

@res2k
Copy link
Contributor Author

res2k commented Sep 8, 2023

I think the answer can be found in MSG_ReadBits(): There, a negative count of bits indicates "sign extension".
Say, you have the bits "0xf000". MSG_ReadBits(16) would return 0x0000f000, MSG_ReadBits(-16) would return 0xfffff000.
The same scheme is used for MSG_WriteBits(). While it doesn't change the results, using negative number communicates that a signed value is being written, so the corresponding MSG_ReadBits() for the data should also use a negative bit count, lest the value may not be interpreted correctly.

@apanteleev
Copy link
Collaborator

That makes sense, thanks. It's quite an obscure solution though.

@res2k
Copy link
Contributor Author

res2k commented Sep 8, 2023

It's simultaneously obscure yet somehow strangely sensible ("You want a signed value? Put a sign in front of it's bit size.")

@res2k res2k deleted the fix-incorrect-check branch September 10, 2023 19:49
res2k pushed a commit to res2k/Q2RTX that referenced this pull request Nov 22, 2023
Apparently, mkdir("c:") is legal, but mkdir("c:/") gives EACCESS on
Windows. So if path has double slashes after drive part, such as
"c://foo/bar" FS_CreatePath() would attempt to mkdir("c:/") and fail.
Change it to always skip the drive part (and leading slashes).

Fixes NVIDIA#316.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants