From 6d77b155bcd4725e09837604e6ea86f5f124ba9c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 5 Dec 2023 20:10:48 +0100 Subject: Third commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- linux/symbols.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'linux/symbols.c') diff --git a/linux/symbols.c b/linux/symbols.c index cbc61f5..7a3c8e5 100644 --- a/linux/symbols.c +++ b/linux/symbols.c @@ -32,6 +32,11 @@ extract_linux_symbol_signal(struct libsyscalls_symbol_printer_data *data, unsign } +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + static const char * extract_linux_symbol_mode(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out) { @@ -128,6 +133,10 @@ extract_linux_symbol_umask(struct libsyscalls_symbol_printer_data *data, unsigne return data->buf; } +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + static const char * extract_linux_symbol_dev(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out) @@ -162,7 +171,7 @@ extract_linux_symbol_dev(struct libsyscalls_symbol_printer_data *data, unsigned static const char * extract_linux_symbol_clockid_t(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out) { - if (*valuep >= 0) + if ((long long int)*valuep >= 0) return NULL; else if ((*valuep & 7) == 2) sprintf(data->buf, "%lli (pid: %llu)", (long long int)*valuep, ~*valuep / 8); @@ -171,7 +180,8 @@ extract_linux_symbol_clockid_t(struct libsyscalls_symbol_printer_data *data, uns else if ((*valuep & 7) == 6) sprintf(data->buf, "%lli (tid: %llu)", (long long int)*valuep, ~*valuep / 8); else - sprintf(data->buf, "%lli (~%llu*8 + %u)", (long long int)*valuep, ~*valuep / 8, *valuep & 7); + sprintf(data->buf, "%lli (~%llu*8 + %llu)", (long long int)*valuep, ~*valuep / 8, *valuep & 7); + (void) fallback_out; *valuep = 0; return data->buf; } @@ -269,6 +279,11 @@ have_fun: } +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif + static struct libsyscalls_syscall_display_info * get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsyscalls_syscall_abi *syscall, long long int syscall_number, unsigned long long int *syscall_argument) @@ -277,7 +292,7 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca libsyscalls_symbol_printer_function **funcs; int i, nargs, nsyms; size_t data_size = offsetof(LIBSYSCALLS_SYMBOL_PRINTER_DATA, buf); - size_t data_align = alignof(*data); + size_t data_align = alignof(LIBSYSCALLS_SYMBOL_PRINTER_DATA); size_t bufspace, bufspace1, bufspace2; LIBSYSCALLS_SYMBOL_PRINTER first, second; @@ -299,9 +314,18 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca } { - char data_vla_buf[(nargs + 1) * data_size + data_align]; +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wvla" +#endif + + char data_vla_buf[(size_t)(nargs + 1) * data_size + data_align]; libsyscalls_symbol_printer_function *funcs_vla[nargs + 1]; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + data = (void *)ALIGN_BUF(data_vla_buf, data_align); funcs = funcs_vla; @@ -319,3 +343,7 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca return build_syscall_display_info(data, data_size, data_align, funcs, syscall, nargs, nsyms); } } + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif -- cgit v1.2.3-70-g09d2