From 6aa496e3128321f911dae10bf1a0f32c5e9a11fd Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jonathan@jlebon.com>
Date: Tue, 29 Oct 2019 16:38:56 -0400
Subject: [PATCH 1/2] libpriv/kernel: Use g_build_filename instead of
g_strconcat
It's much easier to mess up with the latter than the former when
building filenames. There's a bunch more all over the codebase; just did
this bit to be consistent with the next commit which also uses it.
---
src/libpriv/rpmostree-kernel.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libpriv/rpmostree-kernel.c b/src/libpriv/rpmostree-kernel.c
index 9eb052bd..2266f9c7 100644
--- a/src/libpriv/rpmostree-kernel.c
+++ b/src/libpriv/rpmostree-kernel.c
@@ -353,7 +353,7 @@ rpmostree_finalize_kernel (int rootfs_dfd,
GError **error)
{
const char slash_bootdir[] = "boot";
- g_autofree char *modules_bootdir = g_strconcat ("usr/lib/modules/", kver, NULL);
+ g_autofree char *modules_bootdir = g_build_filename ("usr/lib/modules", kver, NULL);
/* Calculate the sha256sum of the kernel+initramfs (called the "boot
* checksum"). We checksum the initramfs from the tmpfile fd (via mmap()) to
@@ -371,7 +371,7 @@ rpmostree_finalize_kernel (int rootfs_dfd,
}
const char *boot_checksum_str = g_checksum_get_string (boot_checksum);
- g_autofree char *kernel_modules_path = g_strconcat (modules_bootdir, "/vmlinuz", NULL);;
+ g_autofree char *kernel_modules_path = g_build_filename (modules_bootdir, "vmlinuz", NULL);
/* It's possible the bootdir is already the modules directory; in that case,
* we don't need to rename.
*/
@@ -394,7 +394,7 @@ rpmostree_finalize_kernel (int rootfs_dfd,
}
/* Replace the initramfs */
- g_autofree char *initramfs_modules_path = g_strconcat (modules_bootdir, "/initramfs.img", NULL);
+ g_autofree char *initramfs_modules_path = g_build_filename (modules_bootdir, "initramfs.img", NULL);
if (unlinkat (rootfs_dfd, initramfs_modules_path, 0) < 0)
{
if (errno != ENOENT)
--
2.21.0