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(ext/node): remove unnecessary and incorrect type priority_t #20276

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

jirutka
Copy link
Contributor

@jirutka jirutka commented Aug 25, 2023

getpriority and setpriority on musl libc accepts int / c_int / i32 as the first argument, not u32.

Since the PRIO_PROCESS constant is imported from the same crate (libc) as the getpriority and setpriority functions, this type cast seems to be completely unnecessary here.

It was introduced in aa8078b by @crowlKats.

Relevant sources:

@jirutka jirutka force-pushed the fix-priority_t branch 2 times, most recently from 24f2184 to b2db072 Compare August 25, 2023 00:15
`getpriority` and `setpriority` on musl libc accepts `int` / `c_int` /
`i32` as the first argument, not `u32`.

Since the `PRIO_PROCESS` constant is imported from the same crate (libc)
as the `getpriority` and `setpriority` functions, this type cast seems
to be completely unnecessary here.

It was introduced in aa8078b.

Relevant sources:

- https://github.com/rust-lang/libc/blob/835661543db1ec42a6d9a809d69c3c5b5b978b81/src/unix/linux_like/linux/musl/mod.rs#L739-L740
- https://git.musl-libc.org/cgit/musl/tree/src/misc/setpriority.c
- https://git.musl-libc.org/cgit/musl/tree/src/misc/getpriority.c
@bartlomieju
Copy link
Member

Hey @jirutka and sorry for a slow response. I think someone opened another PR (#20286) that addressed the same issue already? It's a bummer because you were first to open yours.

@jirutka
Copy link
Contributor Author

jirutka commented Aug 30, 2023

No, it’s not exactly the same issue and the resolution is different, that PR doesn’t fix the bug on musl libc

@bartlomieju
Copy link
Member

@aapoalas could you take a look at this PR?

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me: I checked that at least all the most common freebsd, openbsd, musl and linux-gnu platform libc packages indeed match setpriority and PRIO_PROCESS types and thus as said, the type assert should be entirely unnecessary.

Thank you for the nice fix!

@bartlomieju bartlomieju merged commit 3436f65 into denoland:main Sep 1, 2023
@jirutka jirutka deleted the fix-priority_t branch September 1, 2023 09:33
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.

3 participants