From 707449adc90c80e68176c8df873803ff2f6f70f2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 10 Nov 2022 09:21:21 +0100 Subject: -Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): soltools These occurrences of sprintf in C code don't normally trigger the deprecation warning at least with recent macOS, because macOS by default now enables _FORTIFY_SOURCE (see the code setting it in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/_types.h when originally unset), which for C code hides the declaration of sprintf (along with its deprecation annotation) in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/stdio.h with a macro (expanding to __builtin___sprintf_chk) in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/secure/_stdio.h. But they started to trigger when I did an experimental -fsanitize=address build, because "Disable source fortification on Darwin with AddressSanitizer" predefines -D_FORTIFY_SOURCE=0 in that case. While there might be ways to clean this code up to use something better than the deprecated sprintf, don't bother too much with this 3rd-party, build-time--only code and just silence any potential deprecation warnings. Change-Id: I9f223a0ad50b2729b5d9af2db588fe9f82d0b07f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142534 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- soltools/cpp/_macro.c | 4 ++++ soltools/mkdepend/include.c | 4 ++++ soltools/mkdepend/pr.c | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'soltools') diff --git a/soltools/cpp/_macro.c b/soltools/cpp/_macro.c index ef41b992edae..fbf496b8f781 100644 --- a/soltools/cpp/_macro.c +++ b/soltools/cpp/_macro.c @@ -27,6 +27,8 @@ #endif #include +#include + #include "cpp.h" #define NCONCAT 16384 @@ -143,7 +145,9 @@ void { if (cp != location) *cp++ = ' '; + SAL_WNODEPRECATED_DECLARATIONS_PUSH /* sprintf (macOS 13 SDK) */ sprintf((char *)cp, "%s:%d", s->filename, s->line); + SAL_WNODEPRECATED_DECLARATIONS_POP cp += strlen((char *)cp); } diff --git a/soltools/mkdepend/include.c b/soltools/mkdepend/include.c index d05a8fd75a7f..7f7955a68984 100644 --- a/soltools/mkdepend/include.c +++ b/soltools/mkdepend/include.c @@ -32,6 +32,8 @@ in this Software without prior written authorization from the X Consortium. #include #include +#include + static void remove_dotdot( char * ); static int isdot( char const * ); static int isdotdot( char const * ); @@ -128,7 +130,9 @@ struct inclist *inc_path(char *file, char *include, boolean dot, struct Includes */ if (!found) for (pp = includedirs; *pp; pp++) { + SAL_WNODEPRECATED_DECLARATIONS_PUSH /* sprintf (macOS 13 SDK) */ sprintf(path, "%s/%s", *pp, include); + SAL_WNODEPRECATED_DECLARATIONS_POP remove_dotdot(path); if ((exists_path(incCollection, path)) && stat(path, &st) == 0 && !(st.st_mode & S_IFDIR)) { ip = newinclude(path, include); diff --git a/soltools/mkdepend/pr.c b/soltools/mkdepend/pr.c index 7911502ed813..4d30dd3839bd 100644 --- a/soltools/mkdepend/pr.c +++ b/soltools/mkdepend/pr.c @@ -29,6 +29,9 @@ in this Software without prior written authorization from the X Consortium. #include "def.h" #include + +#include + static size_t pr( struct inclist *ip, char *file,char *base); extern int width; @@ -117,8 +120,10 @@ size_t pr(struct inclist *ip, char *file, char *base) len = (int)strlen(ip->i_file)+4; if (file != lastfile) { lastfile = file; + SAL_WNODEPRECATED_DECLARATIONS_PUSH /* sprintf (macOS 13 SDK) */ sprintf(buf, "\n%s%s%s: \\\n %s", objprefix, base, objsuffix, ip->i_file); + SAL_WNODEPRECATED_DECLARATIONS_POP len = (int)strlen(buf); } else { -- cgit