Re: Porting git to HP NonStop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Joachim Schmitz" <jojo@xxxxxxxxxxxxxxxxxx> writes:

>> Nice.  And we have xmemdupz() would be even better as you followed-up.
>
> How's that one used?

I forgot that we frown upon use of any x<allocate>() wrapper in the
compat/ layer as J6t mentioned.

So probably something along these lines...

	int retval;
	char *dir_to_free = NULL;
	size_t len = strlen(dir);

        if (len && dir[len - 1] == '/') {
		dir_to_free = malloc(len);
                if (!dir_to_free) {
			fprintf(stderr, "malloc failed!\n");
			exit(1);
		}
                memcpy(dir_to_free, dir, len - 1);
                dir_to_free[len - 1] = '\0';
                dir = dir_to_free;
	}                
	retval = mkdir(dir, mode);
	free(dir_to_free);
        return retval;

It might be possible to for the error path to get away with
something like:

	if (!dir_to_free)
		return -1;

if we know the callers are prepared to see mkdir() failing with
ENOMEM, but that is not very likely.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]