News for hackers. Stuff that matters.
Re:Improvements to static analysis in GCC 14 by Borg3 on Wednesday April 03, 2024 @03:21PM (#39921823)
#define strncpyz(d,s,l) *(strncpy(d,s,l)+(l))=0

Of course this one is unsafe for macro expansion. But well, its C :)

Re:Improvements to static analysis in GCC 14 by teo_zero on Thursday April 04, 2024 @01:41AM (#39926933)
I'd rather put the final nul at d+l-1 than at d+l, so that l can be the size of d, not "one more than the size of d":

  strncpyz(buf,src,sizeof buf);