[PATCH 00/11] Xasprintf() and other string-handling cleanups

Alan Coopersmith alan.coopersmith at oracle.com
Mon Nov 29 20:57:37 PST 2010


The meat of this series is sandwiched right in the middle - patch #6
replaces the nifty, but unique, Xprintf() API with a local implementation
of the asprintf() family that's becoming widely adopted (found in
recent versions of the GNU, FreeBSD, NetBSD, OpenBSD, & Solaris
libc's, but not yet in all the versions & platforms we still support).
I believe I've relied on the least common denominator implementation
(i.e. always check for a -1 return for error, and don't rely on the
pointer being cleared to NULL on failure), so at some far future date,
when we no longer support pre-asprintf versions of these platforms,
we can simply do s/Xasprintf/asprintf/g and not break anything.

The crusty bits above it (patches 1-5) simply clean up various other issues
found when scanning the sources for places to replace existing more complex
string allocation/handling code with simpler asprintf calls.

Underneath is a second set of crusty bits (patches 7-11) that actually 
replace the existing calls with Xasprintf() variants as appropriate.

[PATCH 01/11] xf86ValidateModes: xnfalloc(strlen) + strcpy => xnfstrdup
[PATCH 02/11] xf86AutoConfig: make copyScreen memory allocation & error handling more sane
[PATCH 03/11] xf86VIDrvMsgVerb: print args, not format string
[PATCH 04/11] FindModuleInSubdir: Stop allocating one more byte than needed
[PATCH 05/11] Simplify Error() - don't allocate temporary copy of error string
[PATCH 06/11] Add X*asprintf() routines to mirror common asprintf() routines
[PATCH 07/11] Convert existing Xprintf style calls to Xasprintf style
[PATCH 08/11] Convert hw/xfree86/parser code to use Xasprintf() calls
[PATCH 09/11] Convert malloc+sprintf pairs into X*asprintf() calls
[PATCH 10/11] Replace alloc+strcpy+strcat with Xasprintf calls
[PATCH 11/11] Convert cvt code to use Xasprintf() calls

Hopefully this doesn't turn out to be a turkey of a patch sandwich,
but instead makes our string allocation code simpler to understand
and verify the correctness of for human developers and code analysis 
tools alike.

	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list