git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Edgar Toernig <froese@gmx.de>
To: "Robert Sütterlin" <robert@mpe.mpg.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH]: first take at cleanup of #include, xmalloc / xrealloc, git status report usage.
Date: Fri, 29 Apr 2005 18:24:07 +0200	[thread overview]
Message-ID: <20050429182407.5f6afd15.froese@gmx.de> (raw)
In-Reply-To: <bfbb1f23220e1918afe70d4cf3de24f5@mpe.mpg.de>

Robert Sütterlin wrote:
>[...]
> +static int
> +create_directories(const char *path)
>   {
> -	int len = strlen(path);
> -	char *buf = xmalloc(len + 1);
> -	const char *slash = path;
> +	char *buf = (char *)path;
> +	char *slash = buf;
> 
>   	while ((slash = strchr(slash+1, '/')) != NULL) {
> -		len = slash - path;
> -		memcpy(buf, path, len);
> -		buf[len] = 0;
> -		mkdir(buf, 0755);
> +		*slash = '\0';
> +		if (0 != mkdir(buf, 0755))
> +			return error("Unable to mkdir(``%s'', 0755)", buf);
> +		*slash = '/';

You need the temp buffer.  Simply casting the const away may
shut up the compiler but it's not correct.

> -		if (errno != EEXIST)
> +		if (EEXIST != errno)

Too much Star Wars?  Joda-speak?

Ciao, ET.


PS: the mkdir mode should be 0777 ...


  reply	other threads:[~2005-04-29 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-29 13:19 [PATCH]: first take at cleanup of #include, xmalloc / xrealloc, git status report usage Robert Sütterlin
2005-04-29 16:24 ` Edgar Toernig [this message]
2005-04-29 17:07   ` Klaus Robert Suetterlin

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=20050429182407.5f6afd15.froese@gmx.de \
    --to=froese@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=robert@mpe.mpg.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).