git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] init-db: remove unused #includes

From
Jeff King <peff@peff.net>
Date
Jan 15, 2015, 10:55 UTC
Message-ID
<20150115105558.GA13536@peff.net>
In-Reply-To
<CANCZXo5UY80327pvjzYkJXroH_WZdW36LhSANK0O7GGVQLF=AA@mail.gmail.com>
On Thu, Jan 15, 2015 at 04:13:00PM +0600, Alexander Kuleshov wrote:
> yes right, missed system_path usage. But it's strange, code still
> compiles successfully without exec_cmd.h.
Sort of. With your patch I get:
builtin/init-db.c: In function ‘copy_templates’:
builtin/init-db.c:127:3: warning: implicit declaration of function ‘system_path’ [-Wimplicit-function-declaration]
   template_dir = to_free = system_path(DEFAULT_GIT_TEMPLATE_DIR);
   ^
builtin/init-db.c:127:26: warning: assignment makes pointer from integer without a cast
   template_dir = to_free = system_path(DEFAULT_GIT_TEMPLATE_DIR);

Those are just warnings, and on some platforms the resulting code will be fine, but it does violate the C standard to not have a valid declaration in this case (it defaults to an int return type, which is wrong; but simply as a matter of style we do not like implicit declarations even when they are technically correct).

If you are going to be doing refactoring, I'd recommend building with "-Werror" in your CFLAGS to catch such problems.

FWIW, the full set of CFLAGS I use (which I specify in config.mak) is:
    CFLAGS += -Wall -Werror
    CFLAGS += -Wno-format-zero-length
    CFLAGS += -Wdeclaration-after-statement
    CFLAGS += -Wpointer-arith
    CFLAGS += -Wstrict-prototypes
    CFLAGS += -Wold-style-declaration
-Peff
Previous: Alexander KuleshovNext: Junio C Hamano
Message 5 of 8 in “init-db: remove unused #includes”
  1. init-db: remove unused #includesAlexander Kuleshov, Jan 14, 2015
  2. Junio C HamanoJan 14, 2015
  3. Junio C HamanoJan 14, 2015
  4. Alexander KuleshovJan 15, 2015
  5. Jeff KingJan 15, 2015
  6. Junio C HamanoJan 15, 2015
  7. Jeff KingJan 15, 2015
  8. Junio C HamanoJan 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.