Skip to content

Conversation

@DerDakon
Copy link
Member

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. A memset() 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 of explicit_bzero() or memset_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.

@schmonz
Copy link
Member

schmonz commented Sep 12, 2019

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:

  1. Add unit tests (see Add a test target and one unit test, using Check. #102 for early thoughts on organizing them) on the DJB functions for important expected behaviors and edge cases
  2. Swap out the DJB functions for their standard counterparts (as you've done), making sure all the same tests continue to pass

@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch from 15acd4d to 3f0f2bf Compare October 3, 2019 18:55
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch 2 times, most recently from 93ecc78 to 6da2d63 Compare December 27, 2019 23:50
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch from 6da2d63 to 7bc0ee9 Compare March 7, 2020 08:31
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch 3 times, most recently from 842f456 to 53d3b5a Compare May 14, 2020 16:02
@DerDakon DerDakon requested a review from leahneukirchen May 18, 2020 06:05
@leahneukirchen
Copy link
Contributor

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...).

@DerDakon DerDakon added this to the 1.09 milestone May 18, 2020
Copy link

@josuah josuah left a 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.

@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch from 53d3b5a to f473ad0 Compare May 24, 2020 10:26
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch 2 times, most recently from 100090b to 577643d Compare May 24, 2020 12:06
DerDakon added 6 commits May 24, 2020 14:17
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.
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch from 577643d to 1d22422 Compare May 24, 2020 12:17
DerDakon added 2 commits May 24, 2020 14:52
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.
@DerDakon DerDakon force-pushed the Dakon-remove-std-functions branch from 1d22422 to 2bd5462 Compare May 24, 2020 12:53
@schmonz schmonz self-requested a review May 24, 2020 13:09
@DerDakon DerDakon merged commit 2bd5462 into master May 24, 2020
@DerDakon DerDakon deleted the Dakon-remove-std-functions branch May 24, 2020 13:13
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.

6 participants