Ingo Schwarze wrote: > So i say in all cases above, return -1, set ENOMEM, and it doesn't > matter much whether anything is printed, except that asprintf(3) > must of course free(3) any allocated memory before returning and > set the pointer to NULL.
yeah. the number of bytes returned seems like a mistake in the api design. there is almost nothing one can do with this information. unlike write(), you can't call printf again after incrementing the pointer. while (n < whatever) n += printf(format + n, args); i mean, what? only in the case of snprintf can the return be used, and the idea of "short" write there is only harmful. returning -1 to indicate error, ignoring the possibility of short output, seems like the option that results in less damage. as an application author, it's the only behavior i can reasonably code against.