BasedOnStyle: GNU
ColumnLimit: 100
ForEachMacros: ['GLNX_HASH_TABLE_FOREACH', 'GLNX_HASH_TABLE_FOREACH_V', 'GLNX_HASH_TABLE_FOREACH_KV', 'GLNX_HASH_TABLE_FOREACH_IT']
+SpaceAfterCStyleCast: false
AlignEscapedNewlines: DontAlign
run: ./ci/ci-commitmessage-submodules.sh
clang-format:
name: "clang-format"
- runs-on: ubuntu-latest
+ runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
#define PRINT_CONSTANT(CONSTANT_NAME) \
printf ("%s;", #CONSTANT_NAME); \
printf (_Generic ((CONSTANT_NAME), \
- char *: "%s", \
- const char *: "%s", \
- char: "%c", \
- signed char: "%hhd", \
- unsigned char: "%hhu", \
- short int: "%hd", \
- unsigned short int: "%hu", \
- int: "%d", \
- unsigned int: "%u", \
- long: "%ld", \
- unsigned long: "%lu", \
- long long: "%lld", \
- unsigned long long: "%llu", \
- float: "%f", \
- double: "%f", \
- long double: "%ld"), \
+ char *: "%s", \
+ const char *: "%s", \
+ char: "%c", \
+ signed char: "%hhd", \
+ unsigned char: "%hhu", \
+ short int: "%hd", \
+ unsigned short int: "%hu", \
+ int: "%d", \
+ unsigned int: "%u", \
+ long: "%ld", \
+ unsigned long: "%lu", \
+ long long: "%lld", \
+ unsigned long long: "%llu", \
+ float: "%f", \
+ double: "%f", \
+ long double: "%ld"), \
CONSTANT_NAME); \
printf ("\n");
#define cROUNDS 2
#define dROUNDS 4
-#define ROTL(x, b) (uint64_t) (((x) << (b)) | ((x) >> (64 - (b))))
+// Different versions of clang-format fight over this, I don't know
+// what flag would make them agree
+// clang-format off
+#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
+// clang-format on
#define U32TO8_LE(p, v) \
(p)[0] = (uint8_t)((v)); \
*
* Use this to initialize an `OstreeDiffDirsOptions` structure.
*/
-#define OSTREE_DIFF_DIRS_OPTIONS_INIT \
- { \
- .owner_uid = -1, .owner_gid = -1, \
- }
+// Different versions of clang-format fight over this, I don't know
+// what flag would make them agree
+// clang-format off
+#define OSTREE_DIFF_DIRS_OPTIONS_INIT { .owner_uid = -1, .owner_gid = -1 }
+// clang-format on
_OSTREE_PUBLIC
gboolean ostree_diff_dirs_with_options (OstreeDiffFlags flags, GFile *a, GFile *b,
* system repo with verity on and are recreating the composefs
* image during deploy. */
union
- {
- struct fsverity_digest d;
- char buf[sizeof (struct fsverity_digest) + OSTREE_SHA256_DIGEST_LEN];
- } result;
+ {
+ struct fsverity_digest d;
+ char buf[sizeof (struct fsverity_digest) + OSTREE_SHA256_DIGEST_LEN];
+ } result;
guchar *known_digest = NULL;
if (G_IS_UNIX_INPUT_STREAM (input))
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <glib-unix.h>
+#include <linux/kexec.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/statvfs.h>
-#include <linux/kexec.h>
#ifdef HAVE_LIBMOUNT
#include <libmount.h>
#ifdef SYS_kexec_file_load
GLNX_AUTO_PREFIX_ERROR ("Loading kernel into kexec", error);
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
- const char *kargs = ostree_bootconfig_parser_get(bootconfig, "options");
+ const char *kargs = ostree_bootconfig_parser_get (bootconfig, "options");
g_autofree char *deployment_dirpath = ostree_sysroot_get_deployment_dirpath (self, deployment);
glnx_autofd int deployment_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_dirpath, FALSE, &deployment_dfd, error))
glnx_autofd int kernel_fd = -1;
glnx_autofd int initrd_fd = -1;
- if (!glnx_openat_rdonly (kernel_layout->boot_dfd, kernel_layout->kernel_srcpath,
- TRUE, &kernel_fd, error))
+ if (!glnx_openat_rdonly (kernel_layout->boot_dfd, kernel_layout->kernel_srcpath, TRUE, &kernel_fd,
+ error))
return FALSE;
/* initramfs is optional */
if (kernel_layout->initramfs_srcpath)
{
- if (!glnx_openat_rdonly (kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath,
- TRUE, &initrd_fd, error))
+ if (!glnx_openat_rdonly (kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath, TRUE,
+ &initrd_fd, error))
{
return FALSE;
}
}
if (syscall (SYS_kexec_file_load, kernel_fd, initrd_fd, strlen (kargs) + 1, kargs, flags))
- return glnx_throw_errno_prefix(error, "kexec_file_load");
+ return glnx_throw_errno_prefix (error, "kexec_file_load");
return TRUE;
#else
/* Experimental flag to enable staging */
gboolean stage = (self->flags & OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE) > 0
|| getenv ("OSTREE_EX_STAGE_DEPLOYMENTS") != NULL;
- OstreeSysrootSimpleWriteDeploymentFlags write_deployment_flags = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE;
+ OstreeSysrootSimpleWriteDeploymentFlags write_deployment_flags
+ = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE;
if (stage)
{
if (!ostree_sysroot_stage_tree (self->sysroot, self->osname, self->new_revision, self->origin,
return FALSE;
if (!ostree_sysroot_simple_write_deployment (self->sysroot, self->osname, new_deployment,
- self->merge_deployment, write_deployment_flags, cancellable, error))
+ self->merge_deployment, write_deployment_flags,
+ cancellable, error))
return FALSE;
-
if ((self->flags & OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC) > 0)
{
- if (!ostree_sysroot_deployment_kexec_load(self->sysroot, new_deployment, cancellable, error))
+ if (!ostree_sysroot_deployment_kexec_load (self->sysroot, new_deployment, cancellable,
+ error))
return FALSE;
}
}
if (g_once_init_enter (&static_g_define_type_id))
{
- static const GFlagsValue values[]
- = { { OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED,
- "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED", "ignore-unconfigured" },
- { OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE, "OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE",
- "stage" },
- { OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC, "OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC",
- "kexec" },
- { 0, NULL, NULL } };
+ static const GFlagsValue values[] = {
+ { OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED,
+ "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED", "ignore-unconfigured" },
+ { OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE, "OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE", "stage" },
+ { OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC, "OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC", "kexec" },
+ { 0, NULL, NULL }
+ };
GType g_define_type_id
= g_flags_register_static (g_intern_static_string ("OstreeSysrootUpgraderFlags"), values);
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
GCancellable *cancellable, GError **error);
_OSTREE_PUBLIC
-gboolean
-ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *deployment,
- GCancellable *cancellable, GError **error);
+gboolean ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *deployment,
+ GCancellable *cancellable, GError **error);
G_END_DECLS
#include <errno.h>
#include <fcntl.h>
+#include <linux/capability.h>
+#include <linux/prctl.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/prctl.h>
-#include <linux/prctl.h>
-#include <linux/capability.h>
+#include <sys/types.h>
#include <unistd.h>
/* Ensure that a pathname component @name does not contain the special Unix
gboolean
ot_util_process_privileged (void)
{
- if (geteuid() != 0)
+ if (geteuid () != 0)
return FALSE;
// https://github.com/containers/bootc/blob/c88fcfd6e145863408bde7d4706937dd323f64e2/lib/src/cli.rs#L621
BUILTINPROTO (status);
BUILTINPROTO (set_origin);
BUILTINPROTO (diff);
-BUILTINPROTO (switch);
BUILTINPROTO (upgrade);
BUILTINPROTO (kargs);
BUILTINPROTO (post_copy);
BUILTINPROTO (lock_finalization);
BUILTINPROTO (state_overlay);
+// Defined manually since "switch" is a keyword and that totally confuses clang-format
+gboolean ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error);
#undef BUILTINPROTO
err (EXIT_FAILURE, "realpath(%s) failed", destpath);
if (stat (deploy_path, &stbuf) < 0)
err (EXIT_FAILURE, "stat(%s) failed", deploy_path);
- /* Quiet logs if there's no journal */
+
+/* Quiet logs if there's no journal */
#ifdef USE_LIBSYSTEMD
const char *resolved_path = deploy_path + strlen (root_mountpoint);
sd_journal_send ("MESSAGE=Resolved OSTree target to: %s", deploy_path,