git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joachim Schmitz" <jojo@schmitz-digital.de>
To: "'Brandon Casey'" <drafnel@gmail.com>
Cc: "'Junio C Hamano'" <gitster@pobox.com>,
	"'Shawn Pearce'" <spearce@spearce.org>, <git@vger.kernel.org>,
	<rsbecker@nexbridge.com>
Subject: RE: Porting git to HP NonStop
Date: Wed, 22 Aug 2012 19:30:42 +0200	[thread overview]
Message-ID: <003101cd808b$db381e70$91a85b50$@schmitz-digital.de> (raw)
In-Reply-To: <CA+sFfMd5zzfZVrGJSMkr2ga8kTg6Tiun=HBdHkg6rV-stjDT8Q@mail.gmail.com>

> From: Brandon Casey [mailto:drafnel@gmail.com]
> Sent: Wednesday, August 22, 2012 7:23 PM
> To: Joachim Schmitz
> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;
> rsbecker@nexbridge.com
> Subject: Re: Porting git to HP NonStop
> 
> On Wed, Aug 22, 2012 at 10:18 AM, Joachim Schmitz <jojo@schmitz-digital.de>
> wrote:
> >> From: Brandon Casey [mailto:drafnel@gmail.com]
> >> Sent: Wednesday, August 22, 2012 7:01 PM
> >> To: Joachim Schmitz
> >> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;
> >> rsbecker@nexbridge.com
> >> Subject: Re: Porting git to HP NonStop
> >>
> >> On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz
> >> <jojo@schmitz-digital.de>
> >> wrote:
> >>
> >> > OK, so how about this:
> >> > /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c
> >> > --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500
> >> > +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500
> >> > @@ -0,0 +1,24 @@
> >> > +#include "../git-compat-util.h"
> >> > +#undef mkdir
> >> > +
> >> > +/* for platforms that can't deal with a trailing '/' */ int
> >> > +compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) {
> >> > +       int retval;
> >> > +       char *tmp_dir = NULL;
> >> > +       size_t len = strlen(dir);
> >> > +
> >> > +       if (len && dir[len-1] == '/') {
> >> > +               if ((tmp_dir = strdup(dir)) == NULL)
> >> > +                       return -1;
> >> > +               tmp_dir[len-1] = '\0';
> >> > +       }
> >> > +       else
> >> > +               tmp_dir = (char *)dir;
> >> > +
> >> > +       retval = mkdir(tmp_dir, mode);
> >> > +       if (tmp_dir != dir)
> >> > +               free(tmp_dir);
> >> > +
> >> > +       return retval;
> >> > +}
> >>
> >> Why not rearrange this so that you assign to dir the value of tmp_dir
> >> and then just pass dir to mkdir.  Then you can avoid the recast of
> >> dir to (char*) in the else branch.  Later, just call free(tmp_dir).
> >> Also, we have xstrndup.  So I think the body of your function can become
> something like:
> >>
> >>    if (len && dir[len-1] == '/')
> >>        dir = tmp_dir = xstrndup(dir, len-1);
> >
> > xstndup() can't fail?
> 
> Correct.  It will either succeed or die.  It will also try to free up some memory
> used by git if possible.

OK. So let's use that then.

Bye, Jojo

  reply	other threads:[~2012-08-22 17:31 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 15:04 Porting git to HP NonStop Joachim Schmitz
2012-08-10 16:27 ` Shawn Pearce
2012-08-10 17:32   ` Joachim Schmitz
2012-08-10 17:38     ` Shawn Pearce
2012-08-19  8:57       ` Joachim Schmitz
2012-08-19 17:23         ` Junio C Hamano
2012-08-20 10:22           ` Joachim Schmitz
2012-08-20 14:41             ` Junio C Hamano
2012-08-20 16:09               ` Joachim Schmitz
2012-08-20 16:53                 ` Junio C Hamano
2012-08-22 16:30                   ` Joachim Schmitz
2012-08-22 17:00                     ` Brandon Casey
2012-08-22 17:13                       ` Brandon Casey
2012-08-22 17:18                       ` Joachim Schmitz
2012-08-22 17:23                         ` Brandon Casey
2012-08-22 17:30                           ` Joachim Schmitz [this message]
2012-08-22 17:30                       ` Junio C Hamano
2012-08-22 18:01                         ` Joachim Schmitz
2012-08-22 18:24                           ` Junio C Hamano
2012-08-22 18:52                             ` Joachim Schmitz
2012-08-22 17:41                       ` Johannes Sixt
2012-08-22 18:02                         ` Joachim Schmitz
2012-08-22 18:09                           ` Johannes Sixt
2012-08-22 18:18                             ` Joachim Schmitz
2012-08-22 18:09                         ` Brandon Casey
2012-08-22 18:24                           ` Brandon Casey
2012-08-22 18:33                             ` Junio C Hamano
2012-08-22 18:38                               ` Brandon Casey
2012-08-22 20:18                                 ` Joachim Schmitz
2012-08-22 20:49                                   ` Junio C Hamano
2012-08-22 21:05                                     ` Joachim Schmitz
2012-08-22 21:12                                       ` Junio C Hamano
2012-08-22 21:22                                         ` Joachim Schmitz
2012-08-22 21:54                                           ` Junio C Hamano
2012-08-22 18:26                           ` Junio C Hamano
2012-08-10 20:08   ` Joachim Schmitz
2012-08-11  8:20   ` Johannes Sixt
2012-08-14  7:05   ` Joachim Schmitz
2012-08-14 14:56     ` Junio C Hamano

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='003101cd808b$db381e70$91a85b50$@schmitz-digital.de' \
    --to=jojo@schmitz-digital.de \
    --cc=drafnel@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rsbecker@nexbridge.com \
    --cc=spearce@spearce.org \
    /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).