Closed nullrocket closed 2 years ago
Sorry about all the noise! Something was wrong with my local git repo, every time i commited changes, it would be a strange merge of an old commit with the new. Fixed now. I thought I was losing my mind!
I do remember why I had the full braces and return here. https://github.com/utelle/SQLite3MultipleCiphers/blob/cc7033eb6f88c68b5322e6fac3c1369aec554974/src/chacha20poly1305.c#L393
I was seeing this warning and thought I would clear it up.
warning: non-void function does not return a value in all control paths
I do remember why I had the full braces and return here.
I was seeing this warning and thought I would clear it up.
warning: non-void function does not return a value in all control paths
I already commented on the latter, but additionally the keyword static
should be dropped. That is, the final code for function entropy
should look like this:
extern size_t entropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
return (getentropy(buf, n) == 0) ? n : 0;
}
Ok, I removed the static keyword, just curious why? There is another definition further up where I believe I got the signature from when I was making the change that is static.
Also just to be sure, your code above is not what I have.
extern size_t entropy(void* buf, size_t n); size_t entropy(void* buf, size_t n) { return (getentropy(buf, n) == 0) ? n : 0; }
This is what I have. the extern decl is for getentropy.
extern size_t getentropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
return (getentropy(buf, n) == 0) ? n : 0;
}
Ok, I removed the static keyword, just curious why? There is another definition further up where I believe I got the signature from when I was making the change that is static.
Ouch, please revert this change. That is, the static
keyword should actually be used. Otherwise the symbol will be exported. Sorry for the confusion (it's late in the evening here in Germany 😉 ).
Also just to be sure, your code above is not what I have. [...] This is what I have. the extern decl is for getentropy.
extern size_t getentropy(void* buf, size_t n); size_t entropy(void* buf, size_t n) { return (getentropy(buf, n) == 0) ? n : 0; }
Yes, your version is correct. Sorry for my lack of concentration.
Added conditional WASM so that the entropy can be properly defined for wasm targets.