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

Re: [PATCH 1/2] Introduces xmkstemp()

From
Marius Storm-Olsen <marius@trolltech.com>
Date
Aug 31, 2007, 08:27 UTC
Message-ID
<46D7D0F7.1050302@trolltech.com>
In-Reply-To
<20070814164453.400b9c55@localhost>
Luiz Fernando N. Capitulino said the following on 14.08.2007 21:44:
Show 29 quoted lines
> This is a wrapper for mkstemp() that performs error checking and
> calls die() when an error occur.
> 
> Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
> ---
>  git-compat-util.h |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 362e040..ca0a597 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -303,6 +303,16 @@ static inline FILE *xfdopen(int fd, const char *mode)
>  	return stream;
>  }
>  
> +static inline int xmkstemp(char *template)
> +{
> +	int fd;
> +
> +	fd = mkstemp(template);
> +	if (fd < 0)
> +		die("Unable to create temporary file: %s", strerror(errno));
> +	return fd;
> +}
> +
>  static inline size_t xsize_t(off_t len)
>  {
>  	return (size_t)len;

This functions needs to be further down in the file for MinGW builds, since mkstemp() is forward declared later in the file. So, something like this:

diff --git a/git-compat-util.h b/git-compat-util.h
index 9e075b7..f9ba8b0 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -477,4 +477,14 @@ extern __attribute__((noreturn)) int git_exit(int code);

 #endif /* __MINGW32__ */

+static inline int xmkstemp(char *template)
+{
+       int fd;
+
+       fd = mkstemp(template);
+       if (fd < 0)
+               die("Unable to create temporary file: %s", strerror(errno));
+       return fd;
+}
+
 #endif
-- 
.marius
Previous: Carlos RicaNext: Johannes Sixt
Message 5 of 13 in “Introduces xmkstemp()”
  1. 1/2 Introduces xmkstemp()Luiz Fernando N. Capitulino, Aug 14, 2007
  2. Carlos RicaAug 15, 2007
  3. Luiz Fernando N. CapitulinoAug 15, 2007
  4. Carlos RicaAug 15, 2007
  5. Marius Storm-OlsenAug 31, 2007
  6. Johannes SixtAug 31, 2007
  7. Marius Storm-OlsenAug 31, 2007
  8. Johannes SixtAug 31, 2007
  9. Marius Storm-OlsenAug 31, 2007
  10. MinGW merge plans, was Re: [PATCH 1/2] Introduces xmkstemp()Johannes Schindelin, Aug 31, 2007
  11. Johannes SixtAug 31, 2007
  12. Luiz Fernando N. CapitulinoAug 31, 2007
  13. Luiz Fernando N. CapitulinoAug 31, 2007

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.