Hi, I have added a clang-tidy check which proposed in this issue.
The check can finds sprintf usage like:
char buff[50]; sprintf(buff,"Hello, %s!\n","world");
And suggest counted version function instead:
warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer] sprintf(buff,"Hello, %s!\n","world"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ snprintf(buff, sizeof(buff), "Hello, %s!\n", "world")
Let template deduction handle this.