summaryrefslogtreecommitdiffstats
path: root/libsyscalls_get_syscall_display_info.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
committerMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
commit6d77b155bcd4725e09837604e6ea86f5f124ba9c (patch)
tree7cfdf466bb94bbbe3e7929432bc048da5eaa2349 /libsyscalls_get_syscall_display_info.c
parentSecond commit (diff)
downloadlibsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.gz
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.bz2
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.xz
Third commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libsyscalls_get_syscall_display_info.c')
-rw-r--r--libsyscalls_get_syscall_display_info.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/libsyscalls_get_syscall_display_info.c b/libsyscalls_get_syscall_display_info.c
index 4d59f5c..f9bbf1a 100644
--- a/libsyscalls_get_syscall_display_info.c
+++ b/libsyscalls_get_syscall_display_info.c
@@ -5,13 +5,17 @@
#include <stdlib.h>
#include <string.h>
+#if defined(__GNUC__)
+# pragma GCC diagnostic ignored "-Winline"
+#endif
+
#define LOWEST_BIT(X) ((X) & ~((X) - 1))
#define POST_HIGHEST_OF_CONSECUTIVELY_BITS(X) ((X) + LOWEST_BIT(X))
static inline signed char
-trailing_zeroes(unsigned long long int x) {
+trailing_zeroes(unsigned long long int x) { /* TODO use builtin function if available */
int r = 0;
if (x == 0)
return -1;
@@ -53,11 +57,18 @@ extract_signal(enum libsyscalls_os os, enum libsyscalls_arch arch,
if (!found)
return NULL;
+ (void)fallback_out;
+
*valuep = 0;
return found->name;
}
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+#endif
+
static struct libsyscalls_syscall_display_info *
build_syscall_display_info(void *data, size_t data_size, size_t data_align,
libsyscalls_symbol_printer_function **funcs,
@@ -74,14 +85,14 @@ build_syscall_display_info(void *data, size_t data_size, size_t data_align,
size += 1;
}
dataoff = size;
- size += nsyms * data_size;
+ size += (size_t)nsyms * data_size;
- if (size & (alignof(*ret->params) - 1)) {
- size |= alignof(*ret->params) - 1;
+ if (size & (alignof(struct libsyscalls_syscall_type_info) - 1)) {
+ size |= alignof(struct libsyscalls_syscall_type_info) - 1;
size += 1;
}
paramoff = size;
- size += (nargs + 1) * sizeof(*ret->params);
+ size += (size_t)(nargs + 1) * sizeof(*ret->params);
ret = calloc(1, size);
if (!ret)
@@ -96,8 +107,8 @@ build_syscall_display_info(void *data, size_t data_size, size_t data_align,
ret->params[i].type = syscall->parameters_types[i];
if (funcs[i]) {
ret->params[i].function = funcs[i];
- ret->params[i].data = (void *)&((char *)ret)[dataoff + nsyms * data_size];
- memcpy(ret->params[i].data, &((char *)data)[i * data_size], data_size);
+ ret->params[i].data = (void *)&((char *)ret)[dataoff + (size_t)nsyms * data_size];
+ memcpy(ret->params[i].data, &((char *)data)[(size_t)i * data_size], data_size);
nsyms++;
}
}
@@ -105,17 +116,26 @@ build_syscall_display_info(void *data, size_t data_size, size_t data_align,
ret->retvalue->expect_zero = syscall->expect_zero;
if (funcs[i]) {
ret->retvalue->function = funcs[i];
- ret->retvalue->data = (void *)&((char *)ret)[dataoff + nsyms * data_size];
- memcpy(ret->retvalue->data, &((char *)data)[i * data_size], data_size);
+ ret->retvalue->data = (void *)&((char *)ret)[dataoff + (size_t)nsyms * data_size];
+ memcpy(ret->retvalue->data, &((char *)data)[(size_t)i * data_size], data_size);
}
return ret;
}
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
#include "generated/symbols.c"
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wnonnull-compare" /* Why should I trust that the user is using the same compiler? */
+#endif
+
enum libsyscalls_error
libsyscalls_get_syscall_display_info(enum libsyscalls_os os, enum libsyscalls_arch arch,
const struct libsyscalls_syscall_abi *syscall,