[MDEV-24577] Fix warnings generated during compilation of plugin/auth_pam/testing/pam_mariadb_mtr.c on FreeBSD Created: 2021-01-12  Updated: 2021-01-19  Resolved: 2021-01-19

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.4.15, 10.4.17
Fix Version/s: 10.4.18, 10.5.9, 10.6.0

Type: Bug Priority: Major
Reporter: Marcin Gryszkalis Assignee: Dmitry Shulga
Resolution: Fixed Votes: 0
Labels: None
Environment:

FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd11.4


Issue Links:
Relates
relates to MDEV-23935 Fix warnings generated during compila... Closed

 Description   

This is the same bug as MDEV-23935 (OS X) but for FreeBSD. I cloned it thus the "fix version" is invalid, sorry.

The fix was ifdef apple so maybe we need something like ifdef llvm/clang?

copy of original report:
following warnings are generated on compiling the file plugin/auth_pam/testing/pam_mariadb_mtr.c

server-10.4/plugin/auth_pam/testing/pam_mariadb_mtr.c:25:22: error:
      initializing 'char *' with an expression of type 'const char [23]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    { PAM_TEXT_INFO, "Challenge input first." },
                     ^~~~~~~~~~~~~~~~~~~~~~~~
server-10.4/plugin/auth_pam/testing/pam_mariadb_mtr.c:26:28: error:
      initializing 'char *' with an expression of type 'const char [7]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    { PAM_PROMPT_ECHO_OFF, "Enter:" },
                           ^~~~~~~~
server-10.4/plugin/auth_pam/testing/pam_mariadb_mtr.c:27:22: error:
      initializing 'char *' with an expression of type 'const char [23]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    { PAM_ERROR_MSG, "Now, the magic number!" }
                     ^~~~~~~~~~~~~~~~~~~~~~~~
server-10.4/plugin/auth_pam/testing/pam_mariadb_mtr.c:49:16: error:
      assigning to 'char *' from 'const char [5]' discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    msg[0].msg = "PIN:";
               ^ ~~~~~~

In case MariaDB serer is build with -DCMAKE_BUILD_TYPE=Debug it results in build error.
In other words, debug build can't be finished successfully on MacOS 10.4 and higher.



 Comments   
Comment by Dmitry Shulga [ 2021-01-14 ]

I've just committed a patch to fix this issue on BSD. After the patch be approved I will push it.
The patch checks whether a compiler used for building is clang instead of checking a platform is macos.

Comment by Marcin Gryszkalis [ 2021-01-14 ]

I applied the patch and stopped on another one:

include/my_alarm.h

 34 #elif defined(SOLARIS) || defined(__sun) || defined(__APPLE__)
 35 typedef void (*sig_return)(int); /* Returns type from signal */
 36 #else
 37 typedef void (*sig_return)(void); /* Returns type from signal */
 38 #endif

Comment by Marcin Gryszkalis [ 2021-01-14 ]

moved forward with

-#elif defined(SOLARIS) || defined(__sun) || defined(__APPLE__)
+#elif defined(SOLARIS) || defined(__sun) || defined(__APPLE__) || defined(__clang__)

Comment by Marcin Gryszkalis [ 2021-01-14 ]

Next one is

sql/sql_prepare.cc:128:19: error: unused variable 'PARAMETER_FLAG_UNSIGNED' [-Werror,-Wunused-const-variable]

fixed with

+#ifndef EMBEDDED_LIBRARY
 /* Constants defining bits in parameter type flags. Flags are read from high byte of short value */
 static const uint PARAMETER_FLAG_UNSIGNED = 128U << 8;
+#endif

And after that compilation succeeded.

Comment by Oleksandr Byelkin [ 2021-01-19 ]

OK to push.

Comment by Marcin Gryszkalis [ 2021-01-19 ]

@Oleksandr what about 2 other problems (in my_alarm.h and sql_prepare.cc)? Do you want me to fill another issue(s) (as you closed this one)?

Generated at Thu Feb 08 09:31:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.