summaryrefslogtreecommitdiff
path: root/mysys/my_create.c
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-02-18 10:08:49 +0100
committerSergei Golubchik <serg@mariadb.org>2017-02-27 12:35:10 +0100
commit24d8bc707a3d3161229b1cfc94b34dc50473bc59 (patch)
treec0888de5a98676b88cff98f2dd5acd79147d5b5a /mysys/my_create.c
parent3cba74e032050b126eaf1fd27072b1afaeef79b3 (diff)
downloadmariadb-git-24d8bc707a3d3161229b1cfc94b34dc50473bc59.tar.gz
cleanup: my_register_filename()
Don't let my_register_filename() fail because strdup() failed. Better to have NULL for a filename, then to fail the already successful open(). Filenames are only used for error reporting and there was already code to ignore OOMs (my_fdopen()) and to cope with missing filenames (my_filename()).
Diffstat (limited to 'mysys/my_create.c')
-rw-r--r--mysys/my_create.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/mysys/my_create.c b/mysys/my_create.c
index 2e4e8eb1af2..e9a1365ca19 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -36,7 +36,7 @@
File my_create(const char *FileName, int CreateFlags, int access_flags,
myf MyFlags)
{
- int fd, rc;
+ int fd;
DBUG_ENTER("my_create");
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
FileName, CreateFlags, access_flags, MyFlags));
@@ -54,21 +54,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
fd= -1;
}
- rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
+ fd= my_register_filename(fd, FileName, FILE_BY_CREATE,
EE_CANTCREATEFILE, MyFlags);
- /*
- my_register_filename() may fail on some platforms even if the call to
- *open() above succeeds. In this case, don't leave the stale file because
- callers assume the file to not exist if my_create() fails, so they don't
- do any cleanups.
- */
- if (unlikely(fd >= 0 && rc < 0))
- {
- int tmp= my_errno;
- my_close(fd, MyFlags);
- my_delete(FileName, MyFlags);
- my_errno= tmp;
- }
-
- DBUG_RETURN(rc);
+ DBUG_RETURN(fd);
} /* my_create */