mailing list of musl libc
 help / color / mirror / code / Atom feed
* possible getopt stderr output changes
@ 2014-12-11  0:10 Rich Felker
  2014-12-11  3:53 ` Laurent Bercot
  2014-12-11 22:07 ` possible getopt stderr output changes Rich Felker
  0 siblings, 2 replies; 12+ messages in thread
From: Rich Felker @ 2014-12-11  0:10 UTC (permalink / raw)
  To: musl

The current getopt code uses some ugly write() sequences to generate
its output to stderr, and fails to support message translation. The
latter was an oversight when locale/translation support was added and
should absolutely be fixed. I'm not sure whether we should leave the
code using write() though or switch to fprintf.

The original motivation for write() was to avoid pulling in the printf
core and stdio in programs that use getopt but otherwise don't need
printf/stdio. However, the use of multiple write() calls splits the
messages up into multiple syscalls unnecessarily (increasing the
likelihood of getting output interleaved with other processes running
in parallel on the same stderr) and failure to use the stderr FILE
makes it so the output is not even atomic within the same process. I
don't think there's any formal requirement of atomicity here, but it
could be seen as a QoI issue.

Note that even converted to use fprintf, the code would still be
mildly ugly, since it would have to use multiple %s formats and locale
lookups to construct the message. This is because musl security policy
forbids use of translatable format strings in libc; instead,
translatable literals have to be used and processed by a fixed,
non-translated format string.

Thoughts on what color the bikeshed should be?

Rich


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-12-19 21:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11  0:10 possible getopt stderr output changes Rich Felker
2014-12-11  3:53 ` Laurent Bercot
2014-12-11  6:44   ` Rich Felker
2014-12-11 15:40     ` Laurent Bercot
2014-12-11 17:51       ` stdio [de]merits discussion [Re: [musl] possible getopt stderr output changes] Rich Felker
2014-12-11 23:05         ` Laurent Bercot
2014-12-11 23:35           ` Rich Felker
2014-12-12  2:33           ` Morten Welinder
2014-12-11 22:07 ` possible getopt stderr output changes Rich Felker
2014-12-13  0:02   ` Isaac Dunham
2014-12-13  3:11     ` Rich Felker
2014-12-19 21:49   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).