=================================================================== RCS file: /cvs/mandoc/compat_mkdtemp.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -p -r1.3 -r1.4 --- mandoc/compat_mkdtemp.c 2020/06/15 01:37:15 1.3 +++ mandoc/compat_mkdtemp.c 2021/09/19 15:02:55 1.4 @@ -1,6 +1,6 @@ -/* $Id: compat_mkdtemp.c,v 1.3 2020/06/15 01:37:15 schwarze Exp $ */ +/* $Id: compat_mkdtemp.c,v 1.4 2021/09/19 15:02:55 schwarze Exp $ */ /* - * Copyright (c) 2015 Ingo Schwarze + * Copyright (c) 2015, 2021 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -36,16 +36,14 @@ mkdtemp(char *path) start--; for (tries = INT_MAX; tries; tries--) { - if (mktemp(path) == NULL) { - errno = EEXIST; + if (mktemp(path) == NULL) return NULL; - } if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) return path; - if (errno != EEXIST) - return NULL; for (cp = start; *cp != '\0'; cp++) *cp = 'X'; + if (errno != EEXIST) + return NULL; } errno = EEXIST; return NULL;