All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marius Storm-Olsen <marius@trolltech.com>
To: "Luiz Fernando N. Capitulino" <lcapitulino@mandriva.com.br>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] Introduces xmkstemp()
Date: Fri, 31 Aug 2007 10:27:35 +0200	[thread overview]
Message-ID: <46D7D0F7.1050302@trolltech.com> (raw)
In-Reply-To: <20070814164453.400b9c55@localhost>

[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]

Luiz Fernando N. Capitulino said the following on 14.08.2007 21:44:
> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]

  parent reply	other threads:[~2007-08-31  8:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-14 19:44 [PATCH 1/2] Introduces xmkstemp() Luiz Fernando N. Capitulino
2007-08-15 15:11 ` Carlos Rica
2007-08-15 16:17   ` Luiz Fernando N. Capitulino
2007-08-15 16:47     ` Carlos Rica
2007-08-31  8:27 ` Marius Storm-Olsen [this message]
2007-08-31  8:34   ` Johannes Sixt
2007-08-31  8:42     ` Marius Storm-Olsen
2007-08-31  8:49       ` Johannes Sixt
2007-08-31  9:00         ` Marius Storm-Olsen
2007-08-31 12:03           ` MinGW merge plans, was " Johannes Schindelin
2007-08-31 13:13             ` Johannes Sixt
2007-08-31 16:57         ` Luiz Fernando N. Capitulino
2007-08-31 12:48       ` Luiz Fernando N. Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46D7D0F7.1050302@trolltech.com \
    --to=marius@trolltech.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lcapitulino@mandriva.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.