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

Re: Porting git to HP NonStop

From
Brandon Casey <drafnel@gmail.com>
Date
Aug 22, 2012, 17:23 UTC
Message-ID
<CA+sFfMd5zzfZVrGJSMkr2ga8kTg6Tiun=HBdHkg6rV-stjDT8Q@mail.gmail.com>
In-Reply-To
<002f01cd808a$2e027e90$8a077bb0$@schmitz-digital.de>

On Wed, Aug 22, 2012 at 10:18 AM, Joachim Schmitz <jojo@schmitz-digital.de> wrote:

Show 48 quoted lines
>> 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.

-Brandon
Previous: Joachim SchmitzNext: Joachim Schmitz
Message 15 of 39 in “RE: Porting git to HP NonStop”
  1. Joachim SchmitzAug 10, 2012
  2. Shawn PearceAug 10, 2012
  3. Joachim SchmitzAug 10, 2012
  4. Shawn PearceAug 10, 2012
  5. Joachim SchmitzAug 19, 2012
  6. Junio C HamanoAug 19, 2012
  7. Joachim SchmitzAug 20, 2012
  8. Junio C HamanoAug 20, 2012
  9. Joachim SchmitzAug 20, 2012
  10. Junio C HamanoAug 20, 2012
  11. Joachim SchmitzAug 22, 2012
  12. Brandon CaseyAug 22, 2012
  13. Brandon CaseyAug 22, 2012
  14. Joachim SchmitzAug 22, 2012
  15. Brandon CaseyAug 22, 2012
  16. Joachim SchmitzAug 22, 2012
  17. Junio C HamanoAug 22, 2012
  18. Joachim SchmitzAug 22, 2012
  19. Junio C HamanoAug 22, 2012
  20. Joachim SchmitzAug 22, 2012
  21. Johannes SixtAug 22, 2012
  22. Joachim SchmitzAug 22, 2012
  23. Johannes SixtAug 22, 2012
  24. Joachim SchmitzAug 22, 2012
  25. Brandon CaseyAug 22, 2012
  26. Brandon CaseyAug 22, 2012
  27. Junio C HamanoAug 22, 2012
  28. Brandon CaseyAug 22, 2012
  29. Joachim SchmitzAug 22, 2012
  30. Junio C HamanoAug 22, 2012
  31. Joachim SchmitzAug 22, 2012
  32. Junio C HamanoAug 22, 2012
  33. Joachim SchmitzAug 22, 2012
  34. Junio C HamanoAug 22, 2012
  35. Junio C HamanoAug 22, 2012
  36. Joachim SchmitzAug 10, 2012
  37. Johannes SixtAug 11, 2012
  38. Joachim SchmitzAug 14, 2012
  39. Junio C HamanoAug 14, 2012

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.