Page MenuHomeFreeBSD

Avoid conditional references of PRINTF_BUFR_SIZE in headers.
ClosedPublic

Authored by markj on Nov 6 2018, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 23 2024, 9:44 PM
Unknown Object (File)
Sep 18 2024, 10:37 AM
Unknown Object (File)
Sep 12 2024, 5:15 AM
Unknown Object (File)
Sep 9 2024, 2:38 AM
Unknown Object (File)
Sep 7 2024, 2:58 AM
Unknown Object (File)
Sep 5 2024, 8:33 AM
Unknown Object (File)
Aug 31 2024, 6:21 PM
Unknown Object (File)
Aug 21 2024, 5:14 PM
Subscribers

Details

Summary

It turns out that PRINTF_BUFR_SIZE is always defined in opt_printf.h, but
most C files don't include that. However, subr_prf.c does, and it also
references struct tty. PRINTF_BUFR_SIZE defaults to 128, so the size of
t_prbuf varies depending on the compilation unit, resulting in duplicate
CTF type definitions.

Fix the problem by always using PRINTF_BUFR_SIZE to size t_prbuf.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cem added inline comments.
sys/sys/tty.h
136 ↗(On Diff #50086)

I think some universe configs don't define PRINTF_BUFR_SIZE.

137 ↗(On Diff #50086)

Is [0] or [] the preferred style? Either way, it's ok.

This revision is now accepted and ready to land.Nov 6 2018, 10:32 PM
markj added inline comments.
sys/sys/tty.h
136 ↗(On Diff #50086)

Hrm, ok. I'll restore the conditional definition then.

137 ↗(On Diff #50086)

I guess we might as well use C99. I'll change it.

markj marked 2 inline comments as done.
  • Handle PRINTF_BUFR_SIZE not being defined.
  • Ensure that the buffer size is consistent across all CUs. That is, don't rely on CUs to remember to include opt_printf.h.
This revision now requires review to proceed.Nov 6 2018, 11:07 PM
This revision was not accepted when it landed; it landed in state Needs Review.Nov 6 2018, 11:41 PM
This revision was automatically updated to reflect the committed changes.
head/sys/kern/tty.c
110

If PRINTF_BUFR_SIZE is always defined in opt_printf.h, why do we need the conditional code here?

head/sys/kern/tty.c
110

It's not always defined, IIRC. Hence similar logic in cam_xpt.c, subr_prf.c, and xen_console.c.

markj marked an inline comment as done.Nov 7 2018, 4:05 PM
markj added inline comments.
head/sys/kern/tty.c
110

Indeed, there is no fallback definition that gets used if it's omitted in the kernel configuration file.