openlink / iODBC

An open-source ODBC driver manager and SDK that facilitates the development of database-independent applications on linux, freebsd, unix and MacOS X platforms.
http://www.iodbc.org/
Other
157 stars 53 forks source link

3.52.14: compile time warnings #58

Closed kloczek closed 3 years ago

kloczek commented 3 years ago

gcc 11.0.1

dlf.c:101:13: warning: 'sccsid' defined but not used [-Wunused-variable]
  101 | static char sccsid[] = "@(#)dynamic load interface -- SVR4 (dlfcn)";
      |             ^~~~~~
SQLGetPrivateProfileString.c: In function 'SQLGetPrivateProfileStringW':
SQLGetPrivateProfileString.c:363:19: warning: pointer targets in passing argument 5 of 'dm_StrCopyOut2_U8toW_d2m' differ in signedness [-Wpointer-sign]
  363 |                   &len, NULL);
      |                   ^~~~
      |                   |
      |                   WORD * {aka short unsigned int *}
In file included from SQLGetPrivateProfileString.c:78:
./unicode.h:228:54: note: expected 'SQLSMALLINT *' {aka 'short int *'} but argument is of type 'WORD *' {aka 'short unsigned int *'}
  228 |                 void *outStr, int size, SQLSMALLINT *result, int *copied);
      |                                         ~~~~~~~~~~~~~^~~~~~
SQLGetPrivateProfileString.c:382:48: warning: pointer targets in passing argument 5 of 'dm_StrCopyOut2_U8toW_d2m' differ in signedness [-Wpointer-sign]
  382 |               cbRetBuffer*DM_WCHARSIZE(&conv), &length, NULL);
      |                                                ^~~~~~~
      |                                                |
      |                                                WORD * {aka short unsigned int *}
In file included from SQLGetPrivateProfileString.c:78:
./unicode.h:228:54: note: expected 'SQLSMALLINT *' {aka 'short int *'} but argument is of type 'WORD *' {aka 'short unsigned int *'}
  228 |                 void *outStr, int size, SQLSMALLINT *result, int *copied);
      |                                         ~~~~~~~~~~~~~^~~~~~
SQLGetPrivateProfileString.c:388:44: warning: pointer targets in passing argument 5 of 'dm_StrCopyOut2_U8toW_d2m' differ in signedness [-Wpointer-sign]
  388 |           cbRetBuffer*DM_WCHARSIZE(&conv), &length, NULL);
      |                                            ^~~~~~~
      |                                            |
      |                                            WORD * {aka short unsigned int *}
In file included from SQLGetPrivateProfileString.c:78:
./unicode.h:228:54: note: expected 'SQLSMALLINT *' {aka 'short int *'} but argument is of type 'WORD *' {aka 'short unsigned int *'}
  228 |                 void *outStr, int size, SQLSMALLINT *result, int *copied);
      |                                         ~~~~~~~~~~~~~^~~~~~
misc.c: In function '_iodbcadm_getinifile':
misc.c:147:7: warning: unused variable 'i' [-Wunused-variable]
  147 |   int i, j;
      |       ^
SQLGetTranslator.c: In function 'GetTranslator':
SQLGetTranslator.c:222:9: warning: variable 'configMode' set but not used [-Wunused-but-set-variable]
  222 |   UWORD configMode;
      |         ^~~~~~~~~~
In file included from SQLInstallDriverEx.c:78:
SQLInstallDriverEx.c: In function 'InstallDriverPathLength':
../include/iodbc.h:113:31: warning: the address of 'path' will always evaluate as 'true' [-Waddress]
  113 | #define STRLEN(str)     ((str)? strlen((char*)(str)):0)
      |                               ^
SQLInstallDriverEx.c:198:17: note: in expansion of macro 'STRLEN'
  198 |           len = STRLEN (path);
      |                 ^~~~~~
SQLConfigDataSource.c: In function 'SQLConfigDataSource_Internal':
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:437:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  437 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:448:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  448 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:459:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  459 |               CALL_CONFIG_DSNW (_drv_u8);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:470:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  470 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:481:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  481 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:504:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  504 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:515:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  515 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:526:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  526 |               CALL_CONFIG_DSNW (_drv_u8);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:537:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  537 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:548:15: note: in expansion of macro 'CALL_CONFIG_DSNW'
  548 |               CALL_CONFIG_DSNW (pCfg->value);
      |               ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
SQLConfigDataSource.c:271:48: warning: pointer targets in passing argument 2 of 'dm_StrCopyOut2_W2A' differ in signedness [-Wpointer-sign]
  271 |                       dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); \
      |                                                ^~~~~~
      |                                                |
      |                                                char *
SQLConfigDataSource.c:587:7: note: in expansion of macro 'CALL_CONFIG_DSNW'
  587 |       CALL_CONFIG_DSNW ("libdrvproxy.so.2");
      |       ^~~~~~~~~~~~~~~~
In file included from SQLConfigDataSource.c:80:
./unicode.h:174:53: note: expected 'SQLCHAR *' {aka 'unsigned char *'} but argument is of type 'char *'
  174 | int dm_StrCopyOut2_W2A (SQLWCHAR * inStr, SQLCHAR * outStr, SQLSMALLINT size,
      |                                           ~~~~~~~~~~^~~~~~
unicode.c: In function 'dm_SQL_W2A':
unicode.c:464:30: warning: pointer targets in passing argument 3 of 'dm_UWtoA' differ in signedness [-Wpointer-sign]
  464 |         dm_UWtoA(inStr, len, outStr, len * MB_CUR_MAX);
      |                              ^~~~~~
      |                              |
      |                              SQLCHAR * {aka unsigned char *}
unicode.c:131:54: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  131 | static size_t dm_UWtoA(wchar_t *src, int ilen, char *dest, int olen);
      |                                                ~~~~~~^~~~
unicode.c: In function 'dm_SQL_A2W':
unicode.c:491:18: warning: pointer targets in passing argument 1 of 'dm_AtoUW' differ in signedness [-Wpointer-sign]
  491 |         dm_AtoUW(inStr, len, outStr, len);
      |                  ^~~~~
      |                  |
      |                  SQLCHAR * {aka unsigned char *}
unicode.c:132:30: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  132 | static size_t dm_AtoUW(char *src, int ilen, wchar_t *dest, size_t olen);
      |                        ~~~~~~^~~
unicode.c: In function 'dm_StrCopyOut2_A2W':
unicode.c:521:27: warning: pointer targets in passing argument 1 of 'dm_AtoUW' differ in signedness [-Wpointer-sign]
  521 |         length = dm_AtoUW(inStr, length, outStr, length);
      |                           ^~~~~
      |                           |
      |                           SQLCHAR * {aka unsigned char *}
unicode.c:132:30: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  132 | static size_t dm_AtoUW(char *src, int ilen, wchar_t *dest, size_t olen);
      |                        ~~~~~~^~~
unicode.c:528:25: warning: pointer targets in passing argument 1 of 'dm_AtoUW' differ in signedness [-Wpointer-sign]
  528 |       length = dm_AtoUW(inStr, length, outStr, size);
      |                         ^~~~~
      |                         |
      |                         SQLCHAR * {aka unsigned char *}
unicode.c:132:30: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  132 | static size_t dm_AtoUW(char *src, int ilen, wchar_t *dest, size_t olen);
      |                        ~~~~~~^~~
unicode.c: In function 'dm_StrCopyOut2_W2A':
unicode.c:557:42: warning: pointer targets in passing argument 3 of 'dm_UWtoA' differ in signedness [-Wpointer-sign]
  557 |         length = dm_UWtoA(inStr, length, outStr, length);
      |                                          ^~~~~~
      |                                          |
      |                                          SQLCHAR * {aka unsigned char *}
unicode.c:131:54: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  131 | static size_t dm_UWtoA(wchar_t *src, int ilen, char *dest, int olen);
      |                                                ~~~~~~^~~~
unicode.c:564:40: warning: pointer targets in passing argument 3 of 'dm_UWtoA' differ in signedness [-Wpointer-sign]
  564 |       length = dm_UWtoA(inStr, length, outStr, size);
      |                                        ^~~~~~
      |                                        |
      |                                        SQLCHAR * {aka unsigned char *}
unicode.c:131:54: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  131 | static size_t dm_UWtoA(wchar_t *src, int ilen, char *dest, int olen);
      |                                                ~~~~~~^~~~
unicode.c: In function 'dm_strcpy_A2W':
unicode.c:582:23: warning: pointer targets in passing argument 1 of 'dm_AtoUW' differ in signedness [-Wpointer-sign]
  582 |     length = dm_AtoUW(sourStr, length, destStr, length);
      |                       ^~~~~~~
      |                       |
      |                       SQLCHAR * {aka unsigned char *}
unicode.c:132:30: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  132 | static size_t dm_AtoUW(char *src, int ilen, wchar_t *dest, size_t olen);
      |                        ~~~~~~^~~
unicode.c: In function 'dm_strcpy_W2A':
unicode.c:600:40: warning: pointer targets in passing argument 3 of 'dm_UWtoA' differ in signedness [-Wpointer-sign]
  600 |     length = dm_UWtoA(sourStr, length, destStr, length);
      |                                        ^~~~~~~
      |                                        |
      |                                        SQLCHAR * {aka unsigned char *}
unicode.c:131:54: note: expected 'char *' but argument is of type 'SQLCHAR *' {aka 'unsigned char *'}
  131 | static size_t dm_UWtoA(wchar_t *src, int ilen, char *dest, int olen);
      |                                                ~~~~~~^~~~
unicode.c: In function '_wcxntoutf8':
unicode.c:908:11: warning: variable 'mask' set but not used [-Wunused-but-set-variable]
  908 |       int mask;
      |           ^~~~
unicode.c: In function 'dm_AtoUW':
unicode.c:1561:16: warning: pointer targets in initialization of 'ucs4_t *' {aka 'unsigned int *'} from 'wchar_t *' {aka 'int *'} differ in signedness [-Wpointer-sign]
 1561 |   ucs4_t *us = dest;
      |                ^~~~
unicode.c: In function 'dm_U2toA':
unicode.c:1608:18: warning: unused variable 'sz_written' [-Wunused-variable]
 1608 |       size_t sz, sz_written = 0;
      |                  ^~~~~~~~~~
unicode.c: In function 'dm_U4toA':
unicode.c:1653:18: warning: unused variable 'sz_written' [-Wunused-variable]
 1653 |       size_t sz, sz_written = 0;
      |                  ^~~~~~~~~~
unicode.c: In function 'dm_UWtoA':
unicode.c:1696:18: warning: unused variable 'sz_written' [-Wunused-variable]
 1696 |       size_t sz, sz_written = 0;
      |                  ^~~~~~~~~~
unicode.c: In function '_SetWCharAt':
unicode.c:1980:15: warning: variable 'mask' set but not used [-Wunused-but-set-variable]
 1980 |           int mask, len;
      |               ^~~~
unicode.c: In function '_WCHARSIZE':
unicode.c:695:1: warning: control reaches end of non-void function [-Wreturn-type]
  695 | }
      | ^
unicode.c: In function '_WCHARSIZE_ALLOC':
unicode.c:707:1: warning: control reaches end of non-void function [-Wreturn-type]
  707 | }
      | ^
unicode.c: In function 'DM_GetWCharAt':
unicode.c:2161:1: warning: control reaches end of non-void function [-Wreturn-type]
 2161 | }
      | ^
At top level:
unicode.c:342:1: warning: 'eh_encode_char__UTF16BE' defined but not used [-Wunused-function]
  342 | eh_encode_char__UTF16BE (unichar char_to_put, char *tgt_buf, char *tgt_buf_end, ...)
      | ^~~~~~~~~~~~~~~~~~~~~~~
unicode.c:301:1: warning: 'eh_decode_char__UTF16BE' defined but not used [-Wunused-function]
  301 | eh_decode_char__UTF16BE (__constcharptr *src_begin_ptr, const char *src_buf_end, ...)
      | ^~~~~~~~~~~~~~~~~~~~~~~
SQLRemoveDSNFromIni.c:87:13: warning: type of 'ValidDSNW' does not match original declaration [-Wlto-type-mismatch]
   87 | extern BOOL ValidDSNW (LPCSTR);
      |             ^
SQLValidDSN.c:105:1: note: 'ValidDSNW' was previously declared here
  105 | ValidDSNW (LPCWSTR lpszDSN)
      | ^
SQLValidDSN.c:105:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
In file included from henv.c:79:
henv.c: In function 'SQLAllocEnv':
henv.c:214:9: warning: variable 'genv' set but not used [-Wunused-but-set-variable]
  214 |   GENV (genv, NULL);
      |         ^~~~
../include/iodbc.h:248:17: note: in definition of macro 'GENV'
  248 |         GENV_t *genv = (GENV_t *)var
      |                 ^~~~
At top level:
henv.c:105:12: warning: '_iodbcdm_initialized' defined but not used [-Wunused-variable]
  105 | static int _iodbcdm_initialized = 0;
      |            ^~~~~~~~~~~~~~~~~~~~
In file included from info.c:79:
info.c: In function 'SQLGetInfo_Internal':
../include/iodbc.h:113:31: warning: the address of 'buf' will always evaluate as 'true' [-Waddress]
  113 | #define STRLEN(str)     ((str)? strlen((char*)(str)):0)
      |                               ^
info.c:788:34: note: in expansion of macro 'STRLEN'
  788 |           len = (waMode != 'W' ? STRLEN (buf) : DM_WCSLEN(conv, buf));
      |                                  ^~~~~~
../include/iodbc.h:113:31: warning: the address of 'buf' will always evaluate as 'true' [-Waddress]
  113 | #define STRLEN(str)     ((str)? strlen((char*)(str)):0)
      |                               ^
info.c:1006:21: note: in expansion of macro 'STRLEN'
 1006 |               len = STRLEN (buf);
      |                     ^~~~~~
In file included from hstmt.c:79:
hstmt.c: In function '_iodbcdm_conv_var':
hstmt.c:1258:9: warning: unused variable 'penv' [-Wunused-variable]
 1258 |   ENVR (penv, pdbc->henv);
      |         ^~~~
../include/iodbc.h:251:16: note: in definition of macro 'ENVR'
  251 |         ENV_t *env = (ENV_t *)var
      |                ^~~
hstmt.c: In function '_iodbcdm_ConvBindData':
hstmt.c:1546:9: warning: unused variable 'penv' [-Wunused-variable]
 1546 |   ENVR (penv, pdbc->henv);
      |         ^~~~
../include/iodbc.h:251:16: note: in definition of macro 'ENVR'
  251 |         ENV_t *env = (ENV_t *)var
      |                ^~~
hstmt.c: In function '_iodbcdm_ConvBindData_m2d':
hstmt.c:1664:9: warning: unused variable 'penv' [-Wunused-variable]
 1664 |   ENVR (penv, pdbc->henv);
      |         ^~~~
../include/iodbc.h:251:16: note: in definition of macro 'ENVR'
  251 |         ENV_t *env = (ENV_t *)var
      |                ^~~
hstmt.c: In function '_iodbcdm_FixColBindData':
hstmt.c:1803:15: warning: unused variable 'odbc_ver' [-Wunused-variable]
 1803 |   SQLUINTEGER odbc_ver = ((GENV_t *) pdbc->genv)->odbc_ver;
      |               ^~~~~~~~
At top level:
hstmt.c:99:25: warning: 'desc_attrs' defined but not used [-Wunused-const-variable=]
   99 | static const SQLINTEGER desc_attrs[4] =
      |                         ^~~~~~~~~~
In file included from herr.c:79:
herr.c: In function '_iodbcdm_sqlerror':
../include/iodbc.h:113:31: warning: the address of 'msgbuf' will always evaluate as 'true' [-Waddress]
  113 | #define STRLEN(str)     ((str)? strlen((char*)(str)):0)
      |                               ^
herr.c:566:13: note: in expansion of macro 'STRLEN'
  566 |       len = STRLEN (msgbuf);
      |             ^~~~~~
herr.c:276:13: warning: variable 'handle3' set but not used [-Wunused-but-set-variable]
  276 |   SQLHANDLE handle3;
      |             ^~~~~~~
In file included from herr.c:79:
herr.c: In function 'SQLGetDiagRec_Internal':
../include/iodbc.h:113:31: warning: the address of 'msgbuf' will always evaluate as 'true' [-Waddress]
  113 | #define STRLEN(str)     ((str)? strlen((char*)(str)):0)
      |                               ^
herr.c:1035:17: note: in expansion of macro 'STRLEN'
 1035 |           len = STRLEN (msgbuf);
      |                 ^~~~~~
execute.c: In function '_SQLExecute_ConvParams':
execute.c:677:15: warning: unused variable 'odbc_ver' [-Wunused-variable]
  677 |   SQLUINTEGER odbc_ver = ((GENV_t *) pdbc->genv)->odbc_ver;
      |               ^~~~~~~~
In file included from execute.c:79:
execute.c: In function 'SQLPutData_Internal':
execute.c:1540:9: warning: unused variable 'penv' [-Wunused-variable]
 1540 |   ENVR (penv, pdbc->henv);
      |         ^~~~
../include/iodbc.h:251:16: note: in definition of macro 'ENVR'
  251 |         ENV_t *env = (ENV_t *)var
      |                ^~~
connect.c: In function '_iodbcdm_driverload':
connect.c:1313:39: warning: unused variable 'len' [-Wunused-variable]
 1313 |                       SQLINTEGER val, len;
      |                                       ^~~
connect.c: In function 'SQLDriverConnect_Internal':
connect.c:2595:8: warning: unused variable 'bCallDmDlg' [-Wunused-variable]
 2595 |   BOOL bCallDmDlg = FALSE;
      |        ^~~~~~~~~~
At top level:
connect.c:109:13: warning: 'sccsid' defined but not used [-Wunused-variable]
  109 | static char sccsid[] = "@(#)iODBC driver manager " VERSION "\n";
      |             ^~~~~~
odbc3.c: In function 'SQLSetConnectAttr_Internal':
odbc3.c:1871:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 1871 |               switch((SQLINTEGER)ValuePtr)
      |                      ^
connect.c:493:18: warning: type of 'SQLFreeConnect_Internal' does not match original declaration [-Wlto-type-mismatch]
  493 | extern SQLRETURN SQLFreeConnect_Internal (SQLHDBC hdbc);
      |                  ^
hdbc.c:265:1: note: type mismatch in parameter 2
  265 | SQLFreeConnect_Internal (SQLHDBC hdbc, int ver)
      | ^
hdbc.c:265:1: note: type 'int' should match type 'void'
hdbc.c:265:1: note: 'SQLFreeConnect_Internal' was previously declared here
In function 'strncpy',
    inlined from 'SQLColAttribute_Internal' at odbc3.c:3187:8:
/usr/include/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified size between 18446744073709518847 and 0 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^
susnux commented 3 years ago

On openSUSE

unicode.c: In function '_WCHARSIZE': unicode.c:695:1: warning: control reaches end of non-void function [-Wreturn-type] 695 | } | ^ unicode.c: In function '_WCHARSIZE_ALLOC': unicode.c:707:1: warning: control reaches end of non-void function [-Wreturn-type] 707 | } | ^ unicode.c: In function 'DM_GetWCharAt': unicode.c:2161:1: warning: control reaches end of non-void function [-Wreturn-type] 2161 | } | ^

are treated as error, so they breaks building iODBC. I use this patch to fix the warnings by setting UTF8 as default:

diff -Nur libiodbc-3.52.14/iodbcinst/unicode.c new/iodbcinst/unicode.c
--- libiodbc-3.52.14/iodbcinst/unicode.c    2021-02-17 14:39:22.000000000 +0100
+++ new/iodbcinst/unicode.c 2021-05-31 18:26:17.332781996 +0200
@@ -688,9 +688,10 @@
 {
   switch(charset)
     {
-    case CP_UTF8: return 1;
     case CP_UTF16: return sizeof(ucs2_t);
     case CP_UCS4: return sizeof(ucs4_t);
+    case CP_UTF8:
+    default: return 1;
     }
 }

@@ -700,9 +701,10 @@
 {
   switch(charset)
     {
-    case CP_UTF8: return UTF8_MAX_CHAR_LEN;
     case CP_UTF16: return sizeof(ucs2_t) * 2;
     case CP_UCS4: return sizeof(ucs4_t);
+    case CP_UTF8:
+    default: return UTF8_MAX_CHAR_LEN;
     }
 }

@@ -2131,13 +2133,16 @@

   switch(charset)
     {
+    case CP_UTF16: return (SQLWCHAR)u2[pos];
+    case CP_UCS4: return (SQLWCHAR)u4[pos];
     case CP_UTF8:
-      {
+    default:
+      { 
         int mask, len, i=0;
         SQLWCHAR wc = 0;
         SQLCHAR *u8str = (SQLCHAR*)str;
         while(i < pos)
-        {
+        { 
           UTF8_COMPUTE(*u8str, mask, len);
           if (len == -1)
             break;
@@ -2155,8 +2160,6 @@
           }
         return wc;
       }
-    case CP_UTF16: return (SQLWCHAR)u2[pos];
-    case CP_UCS4: return (SQLWCHAR)u4[pos];
     }
 }
TallTed commented 3 years ago

@pkleef @smalinin @timhaynesopenlink -- Please take a look at this.

smalinin commented 3 years ago

The default charset is UCS4, so the pacth was changed for use CP_UCS4 as default and applied.