vsprintf(9)
β¨ NAME β¨
vsprintf β bestie, this is the one that takes your format string and your va_list and just slaps the finished string straight into a buffer for you. It's from the Kernel API Manual side of town, section 9 (kernel API, iykyk) π
π SYNOPSIS π
int vsprintf (char *buf , const char *fmt , va_list args );
That's the whole vibe. Three args, one int coming back at you π¦
πΈ ARGUMENTS πΈ
bufβ the buffer where the final result gets dropped off. It's giving "the destination", the place the string actually lives πfmtβ the format string you wanna use. This is the one doing all the work, okurrr π₯argsβ the arguments for that format string, already wrapped up in ava_listπ
π§ DESCRIPTION π§
So the return value? It's the number of characters written into buf, and that count does not include the trailing ' '. Yes, that's literally what the page says, I'm not gonna gaslight you π
π¨ Real talk though: usevsnprintforvscnprintfif you wanna avoid buffer overflows.vsprintfdoes not know where your buffer ends, and she will keep writing. No cap. That's a whole dangerous situation and you do not want that energy in your kernel π«Ά
If you're not already dealing with a va_list, lowkey consider using sprintf instead β it's way less extra β¨
Also, for real, go check the vsnprintf documentation for the format string extensions over C99 β that's where the details live, bestie π
π SEE ALSO π
- Kernel file
./lib/vsprintf.cπ simple_strtoull(9)simple_strtoul(9)simple_strtol(9)simple_strtoll(9)vsnprintf(9)vscnprintf(9)snprintf(9)scnprintf(9)sprintf(9)vbin_printf(9)bstr_printf(9)vsscanf(9)sscanf(9)
okay that's the whole page, slay π β¨
Signed off from ./lib, dated October 2026, and yeah β it's still vsprintf(9) at the bottom, iconic as ever ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms