Added __attribute__((format(printf, ...))) where appropriate.

Also, fixed various (mostly minor) issues identified this way.