Remove wrong asserts
jbkempf opened this issue · comments
I will veto almost all commits now, until we remove the wrong asserts.
Is this assigned to anyone ? If not I can make some assert hunting ...
It's not assigned to anyone, because it's quite difficult to do correctly.
And requires quite a bit of knowledge. Especially since some assert are correct, and some are not :D
Can you give me a bit of details about the 'wrong asserts' ? Any example ?
Sure. Most of the use of asserts are wrong. For example, many exposed function start with assert(s).
For example, smb_share_get_list is an exposed function to the API, and starts with assert(s != NULL && list != NULL); which will break any calling application. Same for smb_find and tid.
netbios_session_packet_send is an internal function which starts with assert, which means that in release it will just explode. It should just return a failure.
Same for many other parts.
Asserts are for case that should be impossible to reach, not for malformed answers, calls or non-conforming servers.
Fail fast. I believe most of those are reasonable use of assert. I also
don't think we should remove assert from release builds
On Wed, Dec 16, 2015 at 11:42 AM, Jean-Baptiste Kempf <
notifications@github.com> wrote:
Asserts are for case that should be impossible to reach, not for
malformed answers, calls or non-conforming servers.—
Reply to this email directly or view it on GitHub
#50 (comment).
Absolutely not. Assert are not for production. Never, Ever.
Especially for a library. You don't assert or abort in library in cases that can happen.
Assert is not a replacement for normal error-checking of user input.
This is fixed, I believe.