Hacker News new | ask | show | jobs
by linuxlizard 4253 days ago
The Arduino embedded C library (which I'm assuming they're using) isn't as rich as a Glibc or uclibc. Sometimes I have to fall back on very old school methods to build complex strings.
1 comments

This is a very weak excuse to use strcat(). Writing something that actually tracks the length instead of recomputing it every time takes 5 minutes.
I'd hesitate at suggesting it only for efficiency in some embedded device that is fast enough, if it sacrificed readability at all.

Yes, I'm saying that I'm ok with the code above assuming that there are no user inputs that can exceed the bounds (though casting away the const is strange, I assume the stdlib is not correctly consted?)

It's not casting away const, the buffer is declared as uint8_t and they are casting that to char... Otherwise known as it should have been char to begin with.