On Fri, May 8, 2020 at 11:18 AM Junio C Hamano <gitster@xxxxxxxxx> wrote: > + - Do not explicitly compare an integral value with constant 0 or a > + pointer value with constant NULL for equality; just say !value > + instead. To validate a counted array at ptr that has cnt elements > + in it, write: > + > + if (!ptr || !cnt) > + BUG("array should not be empty at this point"); > + > + and not: > + > + if (ptr == NULL || cnt == 0); > + BUG("array should not be empty at this point"); This talks only about '=='. People might still use 0 or NULL with '!='. I wonder if the example can include '!=', as well. Perhaps: if (!ptr) BUG("..."); if (cnt) foo(ptr, cnt); instead of: if (ptr == NULL) BUG("..."); if (cnt != 0) foo(ptr, cnt); or something. Also, would you want to talk about not comparing against NUL character? if (*s) foo(s); instead of: if (*s != '\0') foo(s); Maybe that's overkill since NUL is an integral value which is already covered by your earlier statement (but perhaps some people would overlook that).