News for hackers. Stuff that matters.
Re:Baby Steps: Slowly Porting Musl to Rust by _pmf_ on Monday June 13, 2016 @06:07AM (#11892706)
> The right line of code isn't "return usize::MAX", but "abort()".

No, it's not. Assertions and aborts at the library level make a library completely unusable for embedded systems. The caller checks the result for plausibility and then decides to restart or simply not to perform the guarded action.

Re:Baby Steps: Slowly Porting Musl to Rust by tremon on Monday June 13, 2016 @08:23AM (#11893116)
If the caller didn't verify the plausibility of the parameters before calling the function, why is it safe to assume the caller will verify the plausibility of the function result?

Especially for embedded systems, I want the system to blow up on the developer's desk, not in the field, so I'd prefer to fail early.

Re:Baby Steps: Slowly Porting Musl to Rust by nwmcsween on Monday June 13, 2016 @09:02PM (#11899055)
Because the caller shouldn't know specifics on what is valid for the callee unless the caller has a specific and different value of valid. You don't leak information from separate functions this is how you get brittle garbage code.
Re:Baby Steps: Slowly Porting Musl to Rust by programmer_dude on Wednesday June 15, 2016 @08:11AM (#11908775)
> caller shouldn't know specifics on what is valid for the callee

Why? How do you even use an API if you don't know what you can pass into it?

Re:Baby Steps: Slowly Porting Musl to Rust by nwmcsween on Wednesday June 15, 2016 @01:21PM (#11910638)
For example strtol, you may pass whatever (implicitly nul terminated, which is bad) and it either returns a value or an error. I wasnt advocating _you_ don't know what to pass but that the caller doesn't include specifics of the callee.
Re:Baby Steps: Slowly Porting Musl to Rust by rkangel on Monday June 13, 2016 @08:16AM (#11893098)
There's a difference between handling all possible error cases (however unlikely) and handling impossible cases.

The moment you hit the latter case you can no longer make any assumptions about the state of the device and an abort/assert is an entirely appropriate thing to do.