mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
cp: improve umask caching
* src/copy.c (cached_umask): Avoid syscalls when cached umask is 0. This can also help the compiler’s static analysis.
This commit is contained in:
1 parent
f4dcc2a495
commit
8339970b15
1 file changed
+4
-2
+4
-2
@@ -3456,9 +3456,11 @@ owner_failure_ok (struct cp_options const *x)
|
||||
extern mode_t
|
||||
cached_umask (void)
|
||||
{
|
||||
static mode_t mask = (mode_t) -1;
|
||||
if (mask == (mode_t) -1)
|
||||
static mode_t mask;
|
||||
static bool cached;
|
||||
if (!cached)
|
||||
{
|
||||
cached = true;
|
||||
mask = umask (0);
|
||||
umask (mask);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user