diff --git a/.clang-format b/.clang-format index 6c64639a55..2082209559 100644 --- a/.clang-format +++ b/.clang-format @@ -2,4 +2,5 @@ Language: Cpp 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa99357b84..a7942260c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: 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 diff --git a/rust-bindings/sys/tests/constant.c b/rust-bindings/sys/tests/constant.c index 7b3a9d7c57..d16e3d0e57 100644 --- a/rust-bindings/sys/tests/constant.c +++ b/rust-bindings/sys/tests/constant.c @@ -8,22 +8,22 @@ #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"); diff --git a/src/libostree/ostree-bloom.c b/src/libostree/ostree-bloom.c index 6c1d1f14d8..a738b74e5e 100644 --- a/src/libostree/ostree-bloom.c +++ b/src/libostree/ostree-bloom.c @@ -411,7 +411,11 @@ ostree_bloom_get_hash_func (OstreeBloom *bloom) #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)); \ diff --git a/src/libostree/ostree-diff.h b/src/libostree/ostree-diff.h index ba77ae6fa1..6a2c739943 100644 --- a/src/libostree/ostree-diff.h +++ b/src/libostree/ostree-diff.h @@ -91,10 +91,11 @@ typedef struct * * 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, diff --git a/src/libostree/ostree-repo-composefs.c b/src/libostree/ostree-repo-composefs.c index 26fa7693a0..7cfee38df1 100644 --- a/src/libostree/ostree-repo-composefs.c +++ b/src/libostree/ostree-repo-composefs.c @@ -328,10 +328,10 @@ checkout_one_composefs_file_at (OstreeRepo *repo, OtTristate verity, const char * 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)) diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index e3e333a1d4..3d382a6fcf 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #ifdef HAVE_LIBMOUNT #include @@ -4283,7 +4283,7 @@ ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *dep #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)) @@ -4298,15 +4298,15 @@ ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *dep 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; } @@ -4317,7 +4317,7 @@ ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *dep } 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 diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c index ac7336daad..c991f338a0 100644 --- a/src/libostree/ostree-sysroot-upgrader.c +++ b/src/libostree/ostree-sysroot-upgrader.c @@ -601,7 +601,8 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self, GCancellable *cance /* 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, @@ -617,13 +618,14 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader *self, GCancellable *cance 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; } } @@ -638,14 +640,13 @@ ostree_sysroot_upgrader_flags_get_type (void) 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); diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h index 73c2a408ac..64a1207c04 100644 --- a/src/libostree/ostree-sysroot.h +++ b/src/libostree/ostree-sysroot.h @@ -269,8 +269,7 @@ gboolean ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot, const c 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 diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c index bf2310de03..551cc8789d 100644 --- a/src/libotutil/ot-unix-utils.c +++ b/src/libotutil/ot-unix-utils.c @@ -29,12 +29,12 @@ #include #include +#include +#include #include #include -#include #include -#include -#include +#include #include /* Ensure that a pathname component @name does not contain the special Unix @@ -110,7 +110,7 @@ ot_util_path_split_validate (const char *path, GPtrArray **out_components, GErro 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 diff --git a/src/ostree/ot-admin-builtins.h b/src/ostree/ot-admin-builtins.h index cd1472bf3d..5e94b8a6c7 100644 --- a/src/ostree/ot-admin-builtins.h +++ b/src/ostree/ot-admin-builtins.h @@ -45,12 +45,14 @@ BUILTINPROTO (unlock); 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 diff --git a/src/switchroot/ostree-prepare-root-static.c b/src/switchroot/ostree-prepare-root-static.c index cf37891043..f8a7a14917 100644 --- a/src/switchroot/ostree-prepare-root-static.c +++ b/src/switchroot/ostree-prepare-root-static.c @@ -132,7 +132,8 @@ resolve_deploy_path (const char *root_mountpoint) 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,