MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sbuf_printf_drain

Function sbuf_printf_drain

freebsd/kern/subr_prf.c:1273–1310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271#endif
1272
1273int
1274sbuf_printf_drain(void *arg, const char *data, int len)
1275{
1276 size_t *retvalptr;
1277 int r;
1278#ifdef _KERNEL
1279 char *dataptr;
1280 char oldchr;
1281
1282 /*
1283 * This is allowed as an extra byte is always resvered for
1284 * terminating NUL byte. Save and restore the byte because
1285 * we might be flushing a record, and there may be valid
1286 * data after the buffer.
1287 */
1288 oldchr = data[len];
1289 dataptr = __DECONST(char *, data);
1290 dataptr[len] = '\0';
1291
1292 prf_putbuf(dataptr, TOLOG | TOCONS, -1);
1293 r = len;
1294
1295 dataptr[len] = oldchr;
1296
1297#else /* !_KERNEL */
1298
1299 r = printf("%.*s", len, data);
1300 if (r < 0)
1301 return (-errno);
1302
1303#endif
1304
1305 retvalptr = arg;
1306 if (retvalptr != NULL)
1307 *retvalptr += r;
1308
1309 return (r);
1310}

Callers

nothing calls this directly

Calls 2

prf_putbufFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected