confluentinc / librdkafka

The Apache Kafka C/C++ library
Other
284 stars 3.15k forks source link

Type cast issue on librdkafka/rdposix.h file #4309

Open swyo opened 1 year ago

swyo commented 1 year ago

Read the FAQ first: https://github.com/edenhill/librdkafka/wiki/FAQ

Do NOT create issues for questions, use the discussion forum: https://github.com/edenhill/librdkafka/discussions

Description & How to reproduce

I want to install librdkafka on [termux](https://f-droid.org/ko/packages/com.termux/) app(it is an andriod OS in mobile device) ``` # The command below is not supported on termux. pkg install librdkfaka ``` So, I tried to install it from source build (after running the command: `./configure --prefix=/data/data/com.termux/files/usr`). However, I encountered the following error message: > librdkafka (master !)$ make make[1]: Entering directory '/data/data/com.termux/files/home/workspace/librdkafka/src' gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v2.1.1-5-gf608e3-dirty\"" -I/data/data/com.termux/files/usr/include -I/data/data/com.termux/files/usr/include -I/data/data/com.termux/files/usr/include -I/data/data/co m.termux/files/usr/include -I/data/data/com.termux/files/usr/include -I/data/data/com.termux/files/usr/include -c rdkafka.c -o rdkafka.o In file included from rdkafka.c:42: In file included from ./rdkafka_int.h:46: In file included from ./rd.h:73: ./rdposix.h:119:11: error: incompatible pointer to integer conversion assigning to 'int' from 'char *' [-Wint-conversion] r = strerror_r(err, ret, sizeof(ret)); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. make[1]: *** [../mklove/Makefile.base:97: rdkafka.o] Error 1 make[1]: Leaving directory '/data/data/com.termux/files/home/workspace/librdkafka/src' make: *** [Makefile:27: libs] Error 2 Consequently, I was forced to edit the file rdposix.h as follows: ./rdposix.h:119:11: ``` - r = strerror_r(err, ret, sizeof(ret)); + r = (int)strerror_r(err, ret, sizeof(ret)); ``` After this modification, the make command can be executed, but with the following warning: > In file included from rdkafka_sasl_oauthbearer_oidc.c:33: In file included from ./rdkafka_int.h:46: In file included from ./rd.h:73: ./rdposix.h:119:13: warning: cast to smaller integer type 'int' from 'char *' [-Wpointer-to-int-cast] r = (int)strerror_r(err, ret, sizeof(ret)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Am I correct in editing this code? I am uncertain about the potential consequences of this forced type casting. If this code triggers errors in other parts, I believe it should be addressed.
swyo commented 1 year ago

How to handle this issue? If anyone guide to me, I will try to fix this issue! Adding type cast will solve the problem at line 119 https://github.com/confluentinc/librdkafka/blob/e75de5be191b6b8e9602efc969f4af64071550de/src/rdposix.h#L119

emasab commented 1 year ago

Hello, could you provide the output of ldd --version? to check glibc version

swyo commented 1 year ago

Hello, the ldd command does not exist. so, I installed pkg install ldd and then, when I execute ldd --version, I got this message.

ldd --version
readelf: Error: 'readlink (GNU coreutils) 9.3
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Dmitry V. Levin.': No such file
readelf: Error: 'readlink (GNU coreutils) 9.3
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Dmitry V. Levin.': No such file