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

Re: [PATCH] kset.h, tar.h: add missing header guard to prevent multiple inclusion

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 7, 2019, 11:11 UTC
Message-ID
<xmqqeeykosa8.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191107101243.99744-1-gitter.spiros@gmail.com>
Elia Pinto <gitter.spiros@gmail.com> writes:
Show 9 quoted lines
> Add missing headers to prevent ill-effects from multiple inclusion.
>
> Found by the LGTM source code analyzer.
>
> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> ---
>  kwset.h | 4 ++++
>  tar.h   | 5 +++++
>  2 files changed, 9 insertions(+)
Makes sense; thanks.
Show 33 quoted lines
> diff --git a/kwset.h b/kwset.h
> index df99a92178..f50ecae573 100644
> --- a/kwset.h
> +++ b/kwset.h
> @@ -1,3 +1,6 @@
> +#ifndef KWSET_H
> +#define KWSET_H
> +
>  /* This file has been copied from commit e7ac713d^ in the GNU grep git
>   * repository. A few small changes have been made to adapt the code to
>   * Git.
> @@ -59,3 +62,4 @@ size_t kwsexec(kwset_t, char const *, size_t, struct kwsmatch *);
>  /* Deallocate the given keyword set and all its associated storage. */
>  void kwsfree(kwset_t);
>  
> +#endif /* KWSET_H */
> diff --git a/tar.h b/tar.h
> index 3467705e9b..6b258c4d4a 100644
> --- a/tar.h
> +++ b/tar.h
> @@ -1,3 +1,6 @@
> +#ifndef TAR_H
> +#define TAR_H
> +
>  #define TYPEFLAG_AUTO		'\0'
>  #define TYPEFLAG_REG		'0'
>  #define TYPEFLAG_LNK		'2'
> @@ -23,3 +26,5 @@ struct ustar_header {
>  	char devminor[8];	/* 337 */
>  	char prefix[155];	/* 345 */
>  };
> +
> +#endif /* TAR_H */
Previous: Elia Pinto
Message 2 of 2 in “kset.h, tar.h: add missing header guard to prevent multiple inclusion”
  1. kset.h, tar.h: add missing header guard to prevent multiple inclusionElia Pinto, Nov 7, 2019
  2. Junio C HamanoNov 7, 2019

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.