]> git.ipfire.org Git - pakfire.git/commitdiff
Move all static buffers into Thread-local storage
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 16:28:48 +0000 (16:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 16:28:48 +0000 (16:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c
src/libpakfire/cgroup.c
src/libpakfire/util.c

index 5fb8420560eb70d9d5fd6e5e8404d05ecb96e63a..2dc62585ca742b09e2acef511ce948f2abdf2aea 100644 (file)
@@ -163,19 +163,19 @@ int __pakfire_arch_buildtarget(char* buffer, size_t length, const char* arch, co
        return 0;
 }
 
-static const char* __pakfire_arch_native = NULL;
-
 PAKFIRE_EXPORT const char* pakfire_arch_native() {
        struct utsname buf;
 
-       if (!__pakfire_arch_native) {
+       static __thread const char* arch_native = NULL;
+
+       if (!arch_native) {
                if (uname(&buf) < 0)
                        return NULL;
 
-               __pakfire_arch_native = strdup(buf.machine);
+               arch_native = strdup(buf.machine);
        }
 
-       return __pakfire_arch_native;
+       return arch_native;
 }
 
 int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) {
index 3f6e058541dc9dc1337d02b5f6d530a924a432ec..ed00f6df31f29264aae2cf942623d7bff6d88556 100644 (file)
@@ -34,7 +34,7 @@
 #include <pakfire/string.h>
 #include <pakfire/util.h>
 
-static char bpf_log_buffer[BPF_LOG_BUF_SIZE];
+static __thread char bpf_log_buffer[BPF_LOG_BUF_SIZE];
 
 #define BUFFER_SIZE                    64 * 1024
 
index 2faefe5739234fa76376fdfab3d1d59824f49c50..090be50e19ef3137efc0bd5cceb665b29b77e9f5 100644 (file)
@@ -372,14 +372,14 @@ char* pakfire_remove_trailing_newline(char* str) {
        return str;
 }
 
-static char __hostname[256];
-
 const char* pakfire_hostname() {
-       int r = gethostname(__hostname, sizeof(__hostname));
+       static __thread char hostname[256];
+
+       int r = gethostname(hostname, sizeof(hostname));
        if (r)
                return NULL;
 
-       return __hostname;
+       return hostname;
 }
 
 int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len) {