]> git.ipfire.org Git - thirdparty/asterisk.git/commit
addons/chan_mobile: do not use strerror_r 85/4485/1
authorTimo Teräs <timo.teras@iki.fi>
Fri, 11 Nov 2016 06:29:40 +0000 (08:29 +0200)
committerJoshua Colp <jcolp@digium.com>
Tue, 22 Nov 2016 16:22:59 +0000 (11:22 -0500)
commit1dc4936c3884a02642a4739fd1f851f7aacd6d22
tree6268e3bbea3dc3bddba9c8326853df0159f0f824
parent34a763415f77f4cb17edc728fb51347e979d2fb5
addons/chan_mobile: do not use strerror_r

The two reasons why it might be used are that some systems do not
implement strerror in thread safe manner, and that strerror_r returns
the error code in the string in case there's no error message.

However, all of asterisk elsewhere uses strerror() and assumes it
to be thread safe. And in chan_mobile the errno is also explicitly
printed so neither of the above reasons are valid.

The reasoning to remove usage is that there are actually two versions
of strerror_r: XSI and GNU. They are incompatible in their return
value, and there's no easy way to figure out which one is being
used. glibc gives you the GNU version if _GNU_SOURCE is defined,
but the same feature test macro is needed for other symbols. On
all other systems you assumedly get XSI symbol, and compilation warnings
as well as non-working error printing.

Thus the easiest solution is to just remove strerror_r and use
strerror as rest of the code. Alternative is to introduce ast_strerror
in separate translation unit so it can request the XSI symbol in
glibc case, and replace all usage of strerror.

Change-Id: I84d35225b5642d85d48bc35fdf399afbae28a91d
addons/chan_mobile.c