[vlc-devel] [PATCH 3/3] libvlc: use strerror_r() on Solaris

Rémi Denis-Courmont remi at remlab.net
Sat Jan 3 19:07:12 CET 2015


Le 2015-01-03 21:02, Sean McGovern a écrit :
> Solaris libc does not implement strerror_l().
> ---
>  src/Makefile.am     |   16 ++++++++++++++++
>  src/solaris/error.c |   39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 55 insertions(+)
>  create mode 100644 src/solaris/error.c
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index e200669..e884afe 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -232,6 +232,9 @@ else
>  if HAVE_OS2
>  libvlccore_la_SOURCES += $(SOURCES_libvlc_os2)
>  else
> +if HAVE_SOLARIS
> +libvlccore_la_SOURCES += $(SOURCES_libvlc_solaris)
> +else
>  libvlccore_la_SOURCES += $(SOURCES_libvlc_other)
>  endif
>  endif
> @@ -239,6 +242,7 @@ endif
>  endif
>  endif
>  endif
> +endif
>  if BUILD_HTTPD
>  libvlccore_la_SOURCES += $(SOURCES_libvlc_httpd)
>  endif
> @@ -320,6 +324,18 @@ SOURCES_libvlc_os2 = \
>  	os2/rand.c \
>  	$(NULL)
>
> +SOURCES_libvlc_solaris = \
> +	posix/dirs.c \
> +	solaris/error.c \
> +	posix/filesystem.c \
> +	posix/netconf.c \
> +	posix/thread.c \
> +	posix/timer.c \
> +	posix/plugin.c \
> +	posix/specific.c \
> +	posix/rand.c \
> +	$(NULL)
> +
>  SOURCES_libvlc_other = \
>  	posix/dirs.c \
>  	posix/error.c \
> diff --git a/src/solaris/error.c b/src/solaris/error.c
> new file mode 100644
> index 0000000..b7e4faa
> --- /dev/null
> +++ b/src/solaris/error.c
> @@ -0,0 +1,39 @@
> 
> +/*****************************************************************************
> + * error.c: POSIX error messages formatting
> +
> 
> *****************************************************************************
> + * This program is free software; you can redistribute it and/or 
> modify it
> + * under the terms of the GNU Lesser General Public License as 
> published by
> + * the Free Software Foundation; either version 2.1 of the License, 
> or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public 
> License
> + * along with this program; if not, write to the Free Software 
> Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> +
> 
> *****************************************************************************/
> +
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +#endif
> +
> +#include <errno.h>
> +
> +#include <vlc_common.h>
> +
> +
> +const char* vlc_strerror(int errnum)
> +{
> +    return vlc_strerror_c(errnum);
> +}
> +
> +const char* vlc_strerror_c(int errnum)
> +{
> +    static char message_buf[100];

That's not thread-safe.

> +    strerror_r(errnum, message_buf, 100);
> +    return message_buf;

Even aside from thread safety, that will return uninitialized memory if 
strerror_r fails.

> +}
> +

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list