Style Examples

The basics of good coding & patch submission style are described by e.g. and SubmittingPatches, but there's a lot more to good coding and patch generation than can easily be listed there.

Sometimes Alexandre silently improves patches while committing them - and this might be a useful window on how he likes code to look. So here's a list of a few patches that were silently improved on their way into the tree, and notes on the changes:

  • "gdi32: add test for SelectClipRgn in metafiles, make it pass" original, first part as committed -- AJ evidently thought the patch was too big, and committed a fix for just the worst part of the problem. He also removed a redundant, poorly named variable.

  • "gdi32: add test for SelectClipRgn in metafiles, make it pass" 2nd part, second part as committed -- AJ replaced the obscure expression "&mr->rdParm - 1" with a better name for the same location, "&mr->rdFunction".

  • "server: Access the completion from the file descriptor instead of the async object" original, as committed -- AJ reworked logic in add_async_commpletion to be less convoluted

  • "comdlg32: Widen buffer to accomodate Catalan translation" original, discussion, as committed -- AJ widened a buffer by a factor of four to handle languages with longer strings

  • "kernel32: if string arg to FormatMessage is NULL, use "(null)" instead of crashing" original, as committed -- AJ removed duplicated code in the patch, and made one variable const.

  • "msvcp100: Add _Container_base0::_Swap_all, _Container_base0::_Orphan_all" original, as committed -- AJ removed a null statement (";") from the empty function Container_base0_Swap_all

  • "msvcrt: memmove_s shouldn't zero its output buffer on error" original, as committed -- AJ switched from complex if statements to simple ones, and silently adapted to how wine's msvcrt parameter checking changed since the patch was submitted

  • "msvcp90: Fix cxx exception information for 64-bit" original, as committed -- AJ changed " (UINT)((intptr_t)ptr - (intptr_t)base) " to " (char *)ptr - base "

  • "setupapi: Fix buffer overflow in load_fake_dll" original, as committed -- AJ rewrote the patch. Original changed how the position was calculated. His commit changed how the maximum length was calculated.

  • "gdi32: Use HandleToULong inline function to convert handle to index instead of casting" original, as committed -- AJ changed the tests, splitting the 64-bit long in the table into two 32-bit longs, added another GDI call to the test and renamed the test itself


StyleExamples (last edited 2012-10-13 05:58:17 by DanKegel)