]> git.ipfire.org Git - pakfire.git/commitdiff
system: Fix determining architecture
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Nov 2017 16:08:26 +0000 (17:08 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Nov 2017 16:08:26 +0000 (17:08 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c
src/libpakfire/system.c

index fe063b2d57ec94d347466e81d3fd787dffc61905..c23cf0e4fa3489e260ca7e8e557a5036ee005487 100644 (file)
@@ -37,14 +37,13 @@ Pakfire pakfire_create(const char* path, const char* arch) {
                pakfire->nrefs = 1;
 
                pakfire->path = pakfire_strdup(path);
-               if (!arch) {
+               if (!arch)
                        arch = system_machine();
-               }
                pakfire->arch = pakfire_strdup(arch);
 
                DEBUG("Pakfire initialized at %p\n", pakfire);
-               DEBUG("  arch = %s\n", pakfire->arch);
-               DEBUG("  path = %s\n", pakfire->path);
+               DEBUG("  arch = %s\n", pakfire_get_arch(pakfire));
+               DEBUG("  path = %s\n", pakfire_get_path(pakfire));
 
                // Initialize the pool
                pakfire->pool = pakfire_pool_create(pakfire);
index cc0b9d2f3d2482ff753f5ac80cb88554d3ec5c71..cdbc30fc0921d15fd32e8af432212046b6cfacf7 100644 (file)
 #include <pakfire/util.h>
 
 const char* system_machine() {
-    static char __system_machine[STRING_SIZE] = "";
+    static const char* __system_machine = NULL;
 
-    if (!*__system_machine) {
+    if (!__system_machine) {
         struct utsname buf;
 
         int r = uname(&buf);
-        if (!r)
+        if (r)
             return NULL;
 
-        strncpy(__system_machine, buf.machine, sizeof(*__system_machine));
+        __system_machine = pakfire_strdup(buf.machine);
     }
 
     return __system_machine;