summaryrefslogtreecommitdiff
path: root/mysys/my_fopen.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_fopen.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_fopen.c')
-rw-r--r--mysys/my_fopen.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index cc1019365ac..99a9035c0c2 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -69,19 +69,13 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
DBUG_RETURN(fd); /* safeguard */
}
mysql_mutex_lock(&THR_LOCK_open);
- if ((my_file_info[filedesc].name= (char*)
- my_strdup(filename,MyFlags)))
- {
- my_stream_opened++;
- my_file_total_opened++;
- my_file_info[filedesc].type= STREAM_BY_FOPEN;
- mysql_mutex_unlock(&THR_LOCK_open);
- DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
- DBUG_RETURN(fd);
- }
+ my_file_info[filedesc].name= (char*) my_strdup(filename,MyFlags);
+ my_stream_opened++;
+ my_file_total_opened++;
+ my_file_info[filedesc].type= STREAM_BY_FOPEN;
mysql_mutex_unlock(&THR_LOCK_open);
- (void) my_fclose(fd,MyFlags);
- my_errno=ENOMEM;
+ DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
+ DBUG_RETURN(fd);
}
else
my_errno=errno;