-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Curious makedev function signature mismatch on macOS #4360
Comments
I don't think this was done on purpose, probably just a difference that got overlooked. A fix would be welcome if you are interested. |
That fix would effectively be a breaking change at this point, right? Isn't that problematic? I don't even understand why there is a mismatch in the makedev/major/minor signatures in the first place. It doesn't make much sense in my opinion. |
We have 1.0 coming out so breaking changes can land for that version, we just likely can't backport it (though that is still on the table depending on how bad breakage actually is). I don't know why there would be a mismatch either and that is kind of unfortunate, but it's probably better for us to match the platform API as-written. |
It's even more unfortunate when you consider it should probably match the FreeBSD implementation but Apple made a mistake in their documentation (can't prove it but that would be my guess). |
It's not just their docs, but the implementation is unsigned right? https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/sys/types.h#L154 |
Oh, you're right. I completely overlooked this even though I had the same header file opened on my system. Only saw the macros. In that case, I could submit a fix. |
I want to ask about the
makedev
function signature. In the macOS implementation oflibc
crate,major
andminor
arguments are signed. This is consistent with the return type ofmajor
andminor
functions.However, Apple declares
major
andminor
arguments as unsigned in their documentation.https://developer.apple.com/documentation/kernel/1547212-makedev
While the
major
/minor
return types are still signed.https://developer.apple.com/documentation/kernel/1547203-major
https://developer.apple.com/documentation/kernel/1547204-minor
It is technically Objective-C documentation and also the actual definitions in <sys/types.h> are just macros, so strictly speaking the argument types to
makedev
are not well defined.I suppose it would be logical to assume they're signed since
major
andminor
macros use an explicit cast to a signed type, but here we have a contradicting documentation by Apple.Interestingly, if I compare this to the Android implementation, it also has this exact input/output type mismatch but this time it is also reflected in
libc
.I guess my question is whether this has been done on purpose or if there's any room for improvement (maybe just mention these ambiguities and inconsistencies in
libc
documentation).The text was updated successfully, but these errors were encountered: