From: Edgar Toernig Date: Fri, 29 Apr 2005 16:24:07 GMT Subject: Re: [PATCH]: first take at cleanup of #include, xmalloc / xrealloc, git status report usage. Message-ID: <20050429182407.5f6afd15.froese@gmx.de> In-Reply-To: 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 ...