tree-wide: Rerun clang-format, update ci
authorColin Walters <walters@verbum.org>
Thu, 9 Jan 2025 16:47:26 +0000 (11:47 -0500)
committerColin Walters <walters@verbum.org>
Thu, 9 Jan 2025 18:29:51 +0000 (13:29 -0500)
We have drift again here because we're using an old clang-format
in CI, and some things have landed that it didn't catch.

And update clang-format to ubuntu-24.04 so we are running
against something more modern.

Signed-off-by: Colin Walters <walters@verbum.org>
13 files changed:
.clang-format
.github/workflows/tests.yml
rust-bindings/sys/tests/.clang-format-ignore [new file with mode: 0644]
rust-bindings/sys/tests/constant.c
src/libostree/ostree-bloom.c
src/libostree/ostree-diff.h
src/libostree/ostree-repo-composefs.c
src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-upgrader.c
src/libostree/ostree-sysroot.h
src/libotutil/ot-unix-utils.c
src/ostree/ot-admin-builtins.h
src/switchroot/ostree-prepare-root-static.c

index 6c64639a55d1099d901a3c492e6418223605afaa..2082209559cdfa50c2c7312ef3611d5f7cc33b44 100644 (file)
@@ -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
index aa99357b84e39ad5652c2823d99e6b69464191bd..a7942260c3106aaf546ff93b7777ce10b133169b 100644 (file)
@@ -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/.clang-format-ignore b/rust-bindings/sys/tests/.clang-format-ignore
new file mode 100644 (file)
index 0000000..72e8ffc
--- /dev/null
@@ -0,0 +1 @@
+*
index 7b3a9d7c570dcc72040965d126a2e7a6dfeebdb0..d16e3d0e575b0da743f6d3f1720e9ec9538f4a0a 100644 (file)
@@ -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");
 
index 6c1d1f14d8be45e7f8a42f525b3959f9bcfd9a06..a738b74e5e989394281238c39e38ca8938ccb901 100644 (file)
@@ -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)); \
index ba77ae6fa140b9ad04cffbad27c3fa948943e2cb..6a2c739943577b8945ffe428106319869803a67e 100644 (file)
@@ -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,
index 26fa7693a0a066f885a421ee4f9368e23dfa3730..7cfee38df1cb82a16429b71795917897df247cc4 100644 (file)
@@ -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))
index e3e333a1d40020dd3d884193f6c15b7adbd13eda..3d382a6fcfffa8676174f4d2ccaaa1bb4505f572 100644 (file)
@@ -23,6 +23,7 @@
 #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>
@@ -30,7 +31,6 @@
 #include <sys/poll.h>
 #include <sys/socket.h>
 #include <sys/statvfs.h>
-#include <linux/kexec.h>
 
 #ifdef HAVE_LIBMOUNT
 #include <libmount.h>
@@ -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
index ac7336daad08bff43fcc926e27735dcb3a900e01..c991f338a055578642fc256b7d5d524fe740f73e 100644 (file)
@@ -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);
index 73c2a408ac8aa13c39105c28faf055c252e6ec54..64a1207c0410b6c47ae37c9303a6b30192cff1ea 100644 (file)
@@ -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
index bf2310de03723767cde630933a715e2afe88966f..551cc8789da22787546da2a97635dfb39236650a 100644 (file)
 
 #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
@@ -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
index cd1472bf3d73da932c159ab6907076dafbb06b1e..5e94b8a6c76d5c5950f7e4b660f5c88fb206afd8 100644 (file)
@@ -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
 
index cf378910439dfbc389c18881f065514e96ae1465..f8a7a1491724e5da54f636b99b905680145ad7d4 100644 (file)
@@ -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,