From 1e1e386752c95d1a1b106f5c92732d9a049e41ce Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 26 Sep 2020 11:38:51 +0200 Subject: Avoid -Werror=nonnull with glibc-headers-x86-2.32-1.fc33.noarch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...on Fedora 33: > ~/lo/core/vcl/unx/generic/app/i18n_cb.cxx: In function ‘void Preedit_InsertText(preedit_text_t*, XIMText*, int)’: > ~/lo/core/vcl/unx/generic/app/i18n_cb.cxx:149:34: error: argument 1 is null but the corresponding size argument 3 value is 1024 [-Werror=nonnull] > 149 | size_t nBytes = wcstombs ( nullptr, pWCString, 1024 /* don't care */); > | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from ~/gcc/trunk/inst/include/c++/11.0.0/cstdlib:75, > from ~/lo/core/include/sal/log.hxx:15, > from ~/lo/core/vcl/unx/generic/app/i18n_cb.cxx:25: > /usr/include/stdlib.h:937:15: note: in a call to function ‘size_t wcstombs(char*, const wchar_t*, size_t)’ declared with attribute ‘access (write_only, 1, 3)’ > 937 | extern size_t wcstombs (char *__restrict __s, > | ^~~~~~~~ (Allowing the first argument to wcstombs to be null, and in which case the third argument is ignored, is a POSIX extension.) Change-Id: Ic078623643010b7539bc5bc1b498f18977ae77ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103473 Tested-by: Jenkins Reviewed-by: Stephan Bergmann (cherry picked from commit 782d160458d319c6c77fffa4c003c519afffaa17) --- vcl/unx/generic/app/i18n_cb.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/unx/generic/app/i18n_cb.cxx b/vcl/unx/generic/app/i18n_cb.cxx index e9861dca51d8..4f05e11a5845 100644 --- a/vcl/unx/generic/app/i18n_cb.cxx +++ b/vcl/unx/generic/app/i18n_cb.cxx @@ -142,7 +142,7 @@ Preedit_InsertText(preedit_text_t *pText, XIMText *pInsertText, int where) if (pInsertText->encoding_is_wchar) { wchar_t *pWCString = pInsertText->string.wide_char; - size_t nBytes = wcstombs ( nullptr, pWCString, 1024 /* don't care */); + size_t nBytes = wcstombs ( nullptr, pWCString, 0 /* don't care */); pMBString = static_cast(alloca( nBytes + 1 )); nMBLength = wcstombs ( pMBString, pWCString, nBytes + 1); } @@ -476,7 +476,7 @@ StatusDrawCallback (XIC, XPointer, XIMStatusDrawCallbackStruct *call_data) if( call_data->data.text->string.wide_char ) { wchar_t* pWString = call_data->data.text->string.wide_char; - size_t nBytes = wcstombs( nullptr, pWString, 1024 ); + size_t nBytes = wcstombs( nullptr, pWString, 0 /*don't care*/ ); pMBString = static_cast(alloca( nBytes+1 )); nLength = wcstombs( pMBString, pWString, nBytes+1 ); } -- cgit