-
Notifications
You must be signed in to change notification settings - Fork 30
remove functions that only reimplement standard C functions #103
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
Conversation
|
To the best of my knowledge, too (which is probably a weaker claim than yours). I'm wishing we could have more confidence than that in these changes, though, and thinking we could have it by following these steps:
|
15acd4d to
3f0f2bf
Compare
93ecc78 to
6da2d63
Compare
6da2d63 to
7bc0ee9
Compare
842f456 to
53d3b5a
Compare
|
Looks all good, str_len now returns a size_t which generally is larger than unsigned int, but this should be truncated to an int fine (this will be another incoming patch...). |
josuah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt we will find any system that lack these basic <string.h> functions and still claim to support compiling C.
53d3b5a to
f473ad0
Compare
100090b to
577643d
Compare
Basically 2 things could happen here: -the custom implementation is used, which is probably slower than the one provided by the compiler -the compiler or linker notices that this is just strlen() and replaces it with the normal one In both cases we are better of just removing it altogether. It would in theory be possible that this implementation is faster than what your compiler or libc offers. But than your system is already slow, this few calls for your mailer daemon will not matter then anyway.
For the very same reasons as str_len() this can go away.
That's how that macro is defined, so use it.
This one is actually a bit special: byte_diff() was used only for implementing the byte_equal() macro and had only one direct callsite. And this in turn should have been calling byte_equal(), too. When touching it anyway change it to memcmp() directly.
577643d to
1d22422
Compare
This changes the return type, but noone ever looked at it anyway.
All of these functions are gone now and replaced by libc ones. This reverts commit 8654051.
1d22422 to
2bd5462
Compare
To the best of my knowledge all of these functions behave identical to their standard counterparts, so just use them instead.
In contrast to #65 this does not remove
byte_zero()as that is used to clear passwords in memory. Amemset()could be optimized out by the compiler as the value is not used afterwards anymore, so keeping that function has a slightly higher chance of getting things cleared. One could check for the existence ofexplicit_bzero()ormemset_s()and use that instead, but I think it overcomplicates things and just keeping it does no immediate harm. If we ever go to kill qmail-pop3d and qmail-popup we can go with a plain memset() then.