This sort of thing would be exactly what should go into the "Friendly C" dialect being chatted about the other day--for things like zeroing memory, it's very unexpected that a compiler would be like "nah, not feeling it...nobody will notice anyways".
If you're not worried about writing in a language which is widely supported, just use memset_s and tell people to find a C11 compiler.
How to zero a buffer
21–30 of 216 posts
Re: How to zero a buffer
#22Can someone explain this line: static void * (* const volatile memset_ptr)(void *, int, size_t) = memset; I've written some C but that is utter gibberish to me.
So, first, the name:
memset_ptr
Then, try going to the right, but aha! before we can really gain speed, a parenthesis is immediately blocking us. We shrug off the bruises and turn to the left: (* const volatile memset_ptr)
"Hey guys, memset_ptr is a volatile const pointer..." Now, we hit left parenthesis, so we're again allowed to go right, yay!... (* const volatile memset_ptr)(void *, int, size_t)
"...to a function taking such-and-such arguments..." Uh, oh, the equal sign, so no more to read to the right; disappointed, we turn back to the left for the final run: static void * (* const volatile memset_ptr)(void *, int, size_t)
"...returning a pointer to void! Hah, got you! Simple, really. No arrays, no pointers to pointers, not even a function pointer returning a function pointer, meh. Uh, oh, aaaaand, yes, by the way, the variable is static, so, like, file-local, um. Yeah, yeah, I saw it from the beginning, oh, go away, you're just picky. And, and, you wouldn't recognize a function returning a pointer to an array of pointers to functions returning anonymous struct even if it hit you in the face, pfff!"Re: How to zero a buffer
#23Re: How to zero a buffer
#24Earlier quoted context omitted.
humble attitude I'm guessing you haven't seen the "comeback of all time" thread...
Colin, if you don't me asking (and this is extremely off topic), do you know of any resources to read up on the differences between FreeBSD and DragonflyBSD now 11 years after the split. I'm not looking for you to take sides on the matter. I just enjoy reading history and would like to read a recent review of the two BSD now 11 years later and how they compare. I've looked and looked for the past few months and can't…
On the other hand, I wouldn't want to run DragonflyBSD in production... because skunkworks projects often don't work.
Re: How to zero a buffer
#25Nice teaser at the end there. Does it have something to do with the fact that the OS may have paged the memory containing the sensitive data to disk?
But no, I'm not talking about VM paging.
Re: How to zero a buffer
#26Why would the compiler be allowed optimize away a call to a perfectly valid function? This seems like it's allowing to compiler to make judgement calls on whether or not your code is worthy of being executed.
Re: How to zero a buffer
#27Earlier quoted context omitted.
Colin, if you don't me asking (and this is extremely off topic), do you know of any resources to read up on the differences between FreeBSD and DragonflyBSD now 11 years after the split. I'm not looking for you to take sides on the matter. I just enjoy reading history and would like to read a recent review of the two BSD now 11 years later and how they compare. I've looked and looked for the past few months and can't…
DragonflyBSD is less mature. This allows them to play around with things in ways which we can't do in FreeBSD because we don't want to break production systems. In many ways DragonflyBSD acts as a skunkworks for FreeBSD -- we import a lot of cool stuff from there, once it has been proven to work. On the other hand, I wouldn't want to run DragonflyBSD in production... because skunkworks projects often don't work.
Re: How to zero a buffer
#28This sort of thing would be exactly what should go into the "Friendly C" dialect being chatted about the other day--for things like zeroing memory, it's very unexpected that a compiler would be like "nah, not feeling it...nobody will notice anyways".
Re: How to zero a buffer
#29Re: How to zero a buffer
#30Can someone explain this line: static void * (* const volatile memset_ptr)(void *, int, size_t) = memset; I've written some C but that is utter gibberish to me.
cdecl is really handy for stuff like this. Try it out: http://cdecl.ridiculousfish.com/?q=static+void+*+%28*+const+...