Skip to content

Commit 77a3d7a

Browse files
committed
Fix GCC -Wmaybe-uninitialized
maria_open(): Always initialize open_mode, and remove the redundant local variable try_open_mode that commit 24821e9 had introduced. Also, optimize away any checks for s3 when WITH_S3_STORAGE_ENGINE is not defined.
1 parent 5c9c81e commit 77a3d7a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

storage/maria/ma_open.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
256256
S3_INFO *s3)
257257
{
258258
int save_errno;
259-
int open_mode, try_open_mode;
259+
int open_mode= mode;
260260
uint i,j,len,errpos,head_length,base_pos,keys, realpath_err,
261261
key_parts,base_key_parts,unique_key_parts,fulltext_keys,uniques;
262262
uint internal_table= MY_TEST(open_flags & HA_OPEN_INTERNAL_TABLE);
@@ -288,6 +288,11 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
288288

289289
#ifndef WITH_S3_STORAGE_ENGINE
290290
DBUG_ASSERT(!s3);
291+
# ifdef _MSC_VER
292+
__assume(!s3);
293+
# else
294+
if (s3) __builtin_unreachable();
295+
# endif
291296
#else
292297
if (!s3)
293298
#endif /* WITH_S3_STORAGE_ENGINE */
@@ -346,10 +351,11 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
346351
that the table is usable for future read and write queries in
347352
MariaDB. Only if the read-write mode fails we try to readonly.
348353
*/
349-
try_open_mode= (open_flags & HA_OPEN_FORCE_MODE) ? mode : O_RDWR;
354+
if (!(open_flags & HA_OPEN_FORCE_MODE))
355+
open_mode= O_RDWR;
350356

351357
if ((kfile=mysql_file_open(key_file_kfile, name_buff,
352-
(open_mode=try_open_mode) | O_SHARE |
358+
open_mode | O_SHARE |
353359
O_NOFOLLOW | O_CLOEXEC,
354360
MYF(common_flag | MY_NOSYMLINKS))) < 0)
355361
{
@@ -372,7 +378,6 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
372378
#ifdef WITH_S3_STORAGE_ENGINE
373379
else
374380
{
375-
open_mode= mode;
376381
errpos= 1;
377382
if (s3f.set_database_and_table_from_path(s3, name_buff))
378383
{

0 commit comments

Comments
 (0)