[CONC-329] socket error paths never true on Power due to wrong type Created: 2018-05-09  Updated: 2018-08-08  Resolved: 2018-07-27

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.0.4
Fix Version/s: 3.0.6

Type: Bug Priority: Critical
Reporter: Daniel Black Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

PPC64/ PPC64LE



 Description   

The compile warning on Power and other architectures that defines char to be unsigned (which is allowed by C standard) causes there to be no error handling.

In this case the SOCKET_ERROR (-1) is never true.

plugins/pvio/pvio_socket.c:763:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:875:46: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:907:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)

warnings (from ppc64 RHEL / gcc 4.8.5):

/home/ozlabs/mariadb-server/libmariadb/libmariadb/ma_tls.c: In function ‘ma_pvio_tls_compare_fp’:
/home/ozlabs/mariadb-server/libmariadb/libmariadb/ma_tls.c:169:5: warning: comparison is always false due to limited range of data type [-Wtype-limits]
     if ((d1 = ma_hex2int(*p)) == - 1 ||
     ^
/home/ozlabs/mariadb-server/libmariadb/libmariadb/ma_tls.c:170:9: warning: comparison is always false due to limited range of data type [-Wtype-limits]
         (d2 = ma_hex2int(*(p+1))) == -1 ||
         ^

Fix:
https://github.com/MariaDB/mariadb-connector-c/pull/49

By being explicit about using signed char when negative values are used it creates a consistent API with x86_64 which is signed by default. PR also changes some times to void suspicious casting.


Generated at Thu Feb 08 03:04:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.