Re: [PATCH 1/2] introduce "banned function" list
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jul 20, 2018, 14:41 UTC
- Message-ID
- <CACsJy8BxXyY6h8iN-RExBHASB6FkFLKDkrE_h+gH0A1k2tVd6w@mail.gmail.com>
- In-Reply-To
- <20180719203901.GA8079@sigill.intra.peff.net>
On Thu, Jul 19, 2018 at 10:40 PM Jeff King <peff@peff.net> wrote:
Show 11 quoted lines
> > There are a few standard C functions (like strcpy) which are > easy to misuse. We generally discourage these in reviews, > but we haven't put advice in CodingGuidelines, nor provided > any automated enforcement. The latter is especially > important because it's more consistent, and it can often > save a round-trip of review. > > Let's start by banning strcpy() and sprintf(). It's not > impossible to use these correctly, but it's easy to do so > incorrectly, and there's always a better option.
Is it possible to extend this to ban variables as well? I'm still going to delete the_index from library code. Once that work is done I will ban it from entering again (it's only allowed in builtin/ for example). The next target after that would be the_repository.
Right now I will do this by not declaring the variable [2], which ends up with a much less friendly compile warning. I did something similar [1] in an earlier iteration but did not do extensive research on this topic like you did.
[1] https://public-inbox.org/git/20180606073933.14755-1-pclouds@gmail.com/T/ [2] https://public-inbox.org/git/20180616054157.32433-16-pclouds@gmail.com/
-- Duy