X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Documentation%2FCodingGuidelines;h=227f46ae403ea85a1bea17892aa4b038820b5f9b;hb=73d9f96b4790e16335a30380f97d46bd065dc07b;hp=390ceece523ed9ec2221563d991f8ec0bf83b461;hpb=82fa169d551d71fd21d8a6368040e19d209f79ab;p=thirdparty%2Fgit.git diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 390ceece52..227f46ae40 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -95,10 +95,6 @@ For shell scripts specifically (not exhaustive): - We use Arithmetic Expansion $(( ... )). - - Inside Arithmetic Expansion, spell shell variables with $ in front - of them, as some shells do not grok $((x)) while accepting $(($x)) - just fine (e.g. dash older than 0.5.4). - - We do not use Process Substitution <(list) or >(list). - Do not write control structures on a single line with semicolon. @@ -236,6 +232,18 @@ For C programs: while( condition ) func (bar+1); + - Do not explicitly compare an integral value with constant 0 or '\0', + or a pointer value with constant NULL. For instance, to validate that + counted array is initialized but has no elements, write: + + if (!ptr || cnt) + BUG("empty array expected"); + + and not: + + if (ptr == NULL || cnt != 0); + BUG("empty array expected"); + - We avoid using braces unnecessarily. I.e. if (bla) {