Skip to content

Commit

Permalink
tree-wide: Rerun clang-format, update ci
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cgwalters committed Jan 9, 2025
1 parent ce4e49e commit 014c965
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 54 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rust-bindings/sys/tests/.clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
32 changes: 16 additions & 16 deletions rust-bindings/sys/tests/constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
6 changes: 5 additions & 1 deletion src/libostree/ostree-bloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)); \
Expand Down
9 changes: 5 additions & 4 deletions src/libostree/ostree-diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/libostree/ostree-repo-composefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
14 changes: 7 additions & 7 deletions src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#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/mount.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/statvfs.h>
#include <linux/kexec.h>

#ifdef HAVE_LIBMOUNT
#include <libmount.h>
Expand Down Expand Up @@ -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))
Expand All @@ -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;
}
Expand All @@ -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
Expand Down
25 changes: 13 additions & 12 deletions src/libostree/ostree-sysroot-upgrader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
}
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/libostree/ostree-sysroot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions src/libotutil/ot-unix-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

#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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/ostree/ot-admin-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/switchroot/ostree-prepare-root-static.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 014c965

Please sign in to comment.