Bug #99514 gcc-10 and clang-10 compilation warnings
Submitted: 11 May 2020 15:37 Modified: 20 May 2020 16:39
Reporter: Przemysław Skibiński (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7.30 OS:Any
Assigned to: CPU Architecture:Any

[11 May 2020 15:37] Przemysław Skibiński
Description:
There are some minor warnings for 5.7.30 with clang-10 and gcc-10.

clang-10 warning:
/data/mysql-server/mysql-5.7/storage/myisam/mi_rkey.c:194:5: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
    info->set_rnext_same_key= TRUE;
    ^
/data/mysql-server/mysql-5.7/storage/myisam/mi_rkey.c:190:3: note: previous statement is here
  else
  ^
1 error generated.

gcc-10 warnings:
In file included from /data/mysql-server/mysql-5.7/include/my_global.h:80,
                 from /data/mysql-server/mysql-5.7/sql/sql_parse.h:26,
                 from /data/mysql-server/mysql-5.7/sql/auth/sql_user.cc:22:
/data/mysql-server/mysql-5.7/sql/auth/sql_user.cc: In function ‘void append_user(THD*, String*, LEX_USER*, bool, bool)’:
/data/mysql-server/mysql-5.7/sql/auth/sql_user.cc:125:52: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
  125 |           DBUG_ASSERT(thd->variables.old_passwords = 2);
                                  

How to repeat:
compile server with clang-10 and gcc-10

Suggested fix:
diff --git a/sql/auth/sql_user.cc b/sql/auth/sql_user.cc
index 42bcdcd99f4..dc2e38538c9 100644
--- a/sql/auth/sql_user.cc
+++ b/sql/auth/sql_user.cc
@@ -122,7 +122,7 @@ void append_user(THD *thd, String *str, LEX_USER *user, bool comma= true,
           /*
             With old_passwords == 2 the scrambled password will be binary.
           */
-          DBUG_ASSERT(thd->variables.old_passwords = 2);
+          DBUG_ASSERT(thd->variables.old_passwords == 2);
           str->append("<secret>");
         }
         str->append("'");
diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c
index 70aae9b6016..b65419067d3 100644
--- a/storage/myisam/mi_rkey.c
+++ b/storage/myisam/mi_rkey.c
@@ -191,7 +191,7 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
     info->last_rkey_length= pack_key_length;
 
   /* Next call to mi_rnext_same should set rnext_same_key. */
-    info->set_rnext_same_key= TRUE;
+  info->set_rnext_same_key= TRUE;
 
   /* Check if we don't want to have record back, only error message */
   if (!buf)
[12 May 2020 7:43] MySQL Verification Team
Hello Przemysław,

Thank you for the report and feedback.

regards,
Umesh
[13 May 2020 7:10] Tor Didriksen
Posted by developer:
 
The gcc issue is fixed already, by the patch for:
    Bug #31074217 BROKEN DEBUG BUILD FOR MYSQL 5.7 WITH GCC 10
[20 May 2020 16:39] Paul DuBois
Posted by developer:
 
Fixed in 5.7.31, 8.0.21.

Configuration/build cleanup. No changelog entry required.