Clean up append_xml() and make it static.

Don't use a char to collect the output of getc().
Check the returns from fopen().
Check the return from getc(), as well as feof().
Do the loop test once, not twice.
Use more expressive names for FILE handles.
Make some functions more local, delete some bogus declarations.

Three functions were declared but nowhere defined; kill those.
Various cmockery functions are only actually used within cmockery.c;
so make them static and #if-out their declarations from cmockery.h
Handle socket()-failure like all others.

The child_cycle() test code neglected to check whether socket()
succeeded.  When it fails, handle it the same as all other failures.
Also, in other failures, don't bother saving write()'s return to a
variable when we're not going to do anything with it; and don't leave
space between a function's name and its parameter list.
Remove spurious casts.

Casting an int to Seq* and then back to int does nothing but provoke
compiler warnings !
Simplify GetAcpi().

Make various variables more local.
Make a conditional more readable.

Eliminate a buffer and the sprintf into it where all we needed was to
search for one digit in a string; adding the (singled-digit) int to
'0' will get the digit, with strchr replacing strstr to find it.
Replace a repetitive switch where indexing into a simple array can do
the same job more straightforwardly.

Discovered that a Log() was trying to output the contents of a path
buffer that hadn't actually been initialized; it should have contained
the name of the directory we'd just failed to open, so initialized it
that way.
Clean-up in verify_packages.c

Split some long lines.  Combined a decl with its init to move the
latter out of a loop's condition.  Use strlcpy in preference to
snprintf(,,"%s",); and give the true buffer size.  Reworked a for(;;)
loop that started with a block that break;s to a while loop with the
block moved after the loop; and asserted the the assumption a comment
was articulating.
Clean-up and simplification in processes_select.c

Make variables more local, initialize on declarations, avoid assigning
in conditionals.  Avoid duplication.  Split long lines.
Pass NULL rather than "" as classes for PrependItem.

The classes argument gets xstrdup()ed if non-NULL, so this saves a
pointless allocation and free.
Simplification and clarification in SearchAndReplace().

Simplify the loop logic from a for (;;) with a conditional return at
the start of its body to a suitable while (albeit with assignment in
its condition), so that we can have return at the end of the body.
Declare variables after the early returns that don't use them.
Only compute length of search string once.
Rename variables.  Simplify arithmetic.
Simplifications in string_lib.c

String{Ends,Starts}With could profitably use strcmp and strncmp.
MemSpan and its "inverse" (should be complement) were doing entirely
the wrong casts and using opaque code where plain code is easier to
read, involves less casting and shall be compiled to something at
least as performant by any half-way decent optimiser.  Also document
(in the implementations) why they need to cast away constness on their
return; and explain (in the header) how callers should deal with
constness.  Made the @brief docs brief, too.
Clean up in MakeParentDirectory().

Eliminate a Bad Cast by using a const char * local to traverse the
const char * parameter; and use a different (non-const) local for the
one other place that local was used before.

Using strncpy to copy part of a string leaves it unterminated; use
memcpy (to save checks for its end) and terminate it correctly.

Make variable declarations more local, split long lines, unfold a few
else { if ... } to else if (thereby losing some indentation; view with
git show -b or add a ?w=1 to the github URL for best results).
DRY-fix: clear a pointed to value once in each function.

Rather than having each premature return path clear *json_out
separately, in various functions - with one such path actually
clearing json_out by mistake so failing to clear *json_out -
do the clearing ine one place in each function.
Make CommandPrefix() know its buffer size and clean it up a bit.

It relied on its target buffer to be of size 20; but only copied up to
fifteen bytes into it.  Pass its actual size and copy a reasonable
chunk of the command into it.
Petty clean-up in conversion.c; and make IsRealNumber() sane.

Instead of initializing a value to a particular real and checking that
sscanf() changes it (which it won't when the given string happens to
be the given real), actually check the return from sscanf to know
whether it read a real.

Use the right cast on isspace()'s argument and simplify IsSpace().
Remove some wanton backslashes and put spaces where they belong.
Propagate IntFromString's long-ness through PromiseGetConstraintAsInt.

It makes no sense to truncate an int once we've successfully read it.
Assorted clean-up and simplification in policy.c
Clean up in CleanPidFile() and WritePID().

Simplify nested conditionals into a single condition.
Don't pass snprintf a wrong buffer size.
Combine initialization with declaration to avoid assignment in a
condition.  Split a long Log() line.
Improve a doxygen comment (and make it more truthful).
Shorten a long line.

Moved initialization of a variable referenced outside the loop to
before the loop; made some others more local.
DRY-fix: simplify ReadPolicyServerFile().

Avoid repeating code by using a local variable to hold a test while we
do tidy-up regardless of whether it passed, then act on it.