From 5c83a6989ceb64c61c72dd9fdfe219457900767a Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Jul 2023 16:04:31 +0200 Subject: [PATCH 1/4] loop: Remove unused variable loop.c:151:23: error: unused variable 'sys_path' [-Werror,-Wunused-variable] g_autofree gchar *sys_path = NULL; --- src/plugins/loop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/loop.c b/src/plugins/loop.c index 5c92123bb..a870f85ce 100644 --- a/src/plugins/loop.c +++ b/src/plugins/loop.c @@ -148,7 +148,6 @@ static gchar* _loop_get_backing_file (const gchar *dev_name, GError **error) { BDLoopInfo* bd_loop_info (const gchar *loop, GError **error) { BDLoopInfo *info = NULL; g_autofree gchar *dev_loop = NULL; - g_autofree gchar *sys_path = NULL; gint fd = -1; struct loop_info64 li64; GError *l_error = NULL; From 01a42b8c4f98a0812ce3badfddc5423792d25bde Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Jul 2023 16:06:30 +0200 Subject: [PATCH 2/4] crypto: Remove stray struct redefinition crypto.c:749:40: error: redefinition of typedef 'BDCryptoKeyslotContext' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct _BDCryptoKeyslotContext BDCryptoKeyslotContext; ^ ./crypto.h:234:40: note: previous definition is here typedef struct _BDCryptoKeyslotContext BDCryptoKeyslotContext; ^ --- src/plugins/crypto.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c index 503e1207b..c5f719ca7 100644 --- a/src/plugins/crypto.c +++ b/src/plugins/crypto.c @@ -746,7 +746,6 @@ struct _BDCryptoKeyslotContext { } volume_key; } u; }; -typedef struct _BDCryptoKeyslotContext BDCryptoKeyslotContext; void bd_crypto_keyslot_context_free (BDCryptoKeyslotContext *context) { if (context == NULL) From 0ee4438082ef9c10c18da1188f80c36d3e921394 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Jul 2023 17:11:38 +0200 Subject: [PATCH 3/4] boilerplate_generator: Annotate stub func args as G_GNUC_UNUSED --- scripts/boilerplate_generator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/boilerplate_generator.py b/scripts/boilerplate_generator.py index a7557b069..4a81bb3b6 100755 --- a/scripts/boilerplate_generator.py +++ b/scripts/boilerplate_generator.py @@ -144,6 +144,7 @@ def get_arg_names(args): def get_func_boilerplate(fn_info): call_args_str = ", ".join(get_arg_names(fn_info.args)) + args_ann_unused = fn_info.args.replace(",", " G_GNUC_UNUSED,") if "int" in fn_info.rtype: default_ret = "0" @@ -159,12 +160,12 @@ def get_func_boilerplate(fn_info): default_ret = 0 # first add the stub function doing nothing and just reporting error - ret = ("static {0.rtype} {0.name}_stub ({0.args}) {{\n" + + ret = ("static {0.rtype} {0.name}_stub ({2}) {{\n" + " g_critical (\"The function '{0.name}' called, but not implemented!\");\n" + " g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,\n"+ " \"The function '{0.name}' called, but not implemented!\");\n" " return {1};\n" - "}}\n\n").format(fn_info, default_ret) + "}}\n\n").format(fn_info, default_ret, args_ann_unused) # then add a variable holding a reference to the dynamically loaded function # (if any) initialized to the stub From 0d97224fc0b62428caf1100d03b57a2974ba1b96 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Jul 2023 18:05:21 +0200 Subject: [PATCH 4/4] fs: Simplify struct BDFSInfo Turned out this was a private struct and these two static-const-array cross-references were not really needed. generic.c:185:52: error: initializer element is not a compile-time constant .mkfs_options = fs_features[BD_FS_TECH_EXT2].mkfs, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ generic.c:187:51: error: initializer element is not a compile-time constant .resize_mode = fs_features[BD_FS_TECH_EXT2].resize, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ --- src/plugins/fs/generic.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/plugins/fs/generic.c b/src/plugins/fs/generic.c index b6a8a3783..4406d5cc0 100644 --- a/src/plugins/fs/generic.c +++ b/src/plugins/fs/generic.c @@ -155,10 +155,10 @@ static const BDFSFeatures fs_features[BD_FS_LAST_FS] = { /** * BDFSInfo: * @type: filesystem identifier, must be present + * @mkfs_util: required utility for filesystem creation, "" if not needed and NULL for no support * @check_util: required utility for consistency checking, "" if not needed and NULL for no support * @repair_util: required utility for repair, "" if not needed and NULL for no support * @resize_util: required utility for resize, "" if not needed and NULL for no support - * @resize_mode: resize availability flags, 0 if no support * @label_util: required utility for labelling, "" if not needed and NULL for no support * @info_util: required utility for getting information about the filesystem, "" if not needed and NULL for no support * @uuid_util: required utility for setting UUID, "" if not needed and NULL for no support @@ -166,137 +166,113 @@ static const BDFSFeatures fs_features[BD_FS_LAST_FS] = { typedef struct BDFSInfo { const gchar *type; const gchar *mkfs_util; - BDFSMkfsOptionsFlags mkfs_options; const gchar *check_util; const gchar *repair_util; const gchar *resize_util; - BDFSResizeFlags resize_mode; const gchar *label_util; const gchar *info_util; const gchar *uuid_util; } BDFSInfo; -static const BDFSInfo fs_info[BD_FS_LAST_FS] = { +const BDFSInfo fs_info[BD_FS_LAST_FS] = { /* padding for BD_FS_TECH_GENERIC and MOUNT to make accessing the FS techs simpler */ { 0 }, { 0 }, /* EXT2 */ { .type = "ext2", .mkfs_util = "mkfs.ext2", - .mkfs_options = fs_features[BD_FS_TECH_EXT2].mkfs, .check_util = "e2fsck", .repair_util = "e2fsck", .resize_util = "resize2fs", - .resize_mode = fs_features[BD_FS_TECH_EXT2].resize, .label_util = "tune2fs", .info_util = "dumpe2fs", .uuid_util = "tune2fs" }, /* EXT3 */ { .type = "ext3", .mkfs_util = "mkfs.ext3", - .mkfs_options = fs_features[BD_FS_TECH_EXT3].mkfs, .check_util = "e2fsck", .repair_util = "e2fsck", .resize_util = "resize2fs", - .resize_mode = fs_features[BD_FS_TECH_EXT3].resize, .label_util = "tune2fs", .info_util = "dumpe2fs", .uuid_util = "tune2fs" }, /* EXT4 */ { .type = "ext4", .mkfs_util = "mkfs.ext4", - .mkfs_options = fs_features[BD_FS_TECH_EXT4].mkfs, .check_util = "e2fsck", .repair_util = "e2fsck", .resize_util = "resize2fs", - .resize_mode = fs_features[BD_FS_TECH_EXT4].resize, .label_util = "tune2fs", .info_util = "dumpe2fs", .uuid_util = "tune2fs" }, /* XFS */ { .type = "xfs", .mkfs_util = "mkfs.xfs", - .mkfs_options = fs_features[BD_FS_TECH_XFS].mkfs, .check_util = "xfs_db", .repair_util = "xfs_repair", .resize_util = "xfs_growfs", - .resize_mode = fs_features[BD_FS_TECH_XFS].resize, .label_util = "xfs_admin", .info_util = "xfs_admin", .uuid_util = "xfs_admin" }, /* VFAT */ { .type = "vfat", .mkfs_util = "mkfs.vfat", - .mkfs_options = fs_features[BD_FS_TECH_VFAT].mkfs, .check_util = "fsck.vfat", .repair_util = "fsck.vfat", .resize_util = "vfat-resize", - .resize_mode = fs_features[BD_FS_TECH_VFAT].resize, .label_util = "fatlabel", .info_util = "fsck.vfat", .uuid_util = "fatlabel" }, /* NTFS */ { .type = "ntfs", .mkfs_util = "mkfs.ntfs", - .mkfs_options = fs_features[BD_FS_TECH_NTFS].mkfs, .check_util = "ntfsfix", .repair_util = "ntfsfix", .resize_util = "ntfsresize", - .resize_mode = fs_features[BD_FS_TECH_NTFS].resize, .label_util = "ntfslabel", .info_util = "ntfscluster", .uuid_util = "ntfslabel" }, /* F2FS */ { .type = "f2fs", .mkfs_util = "mkfs.f2fs", - .mkfs_options = fs_features[BD_FS_TECH_F2FS].mkfs, .check_util = "fsck.f2fs", .repair_util = "fsck.f2fs", .resize_util = "resize.f2fs", - .resize_mode = fs_features[BD_FS_TECH_F2FS].resize, .label_util = NULL, .info_util = "dump.f2fs", .uuid_util = NULL }, /* NILFS2 */ { .type = "nilfs2", .mkfs_util = "mkfs.nilfs2", - .mkfs_options = fs_features[BD_FS_TECH_NILFS2].mkfs, .check_util = NULL, .repair_util = NULL, .resize_util = "nilfs-resize", - .resize_mode = fs_features[BD_FS_TECH_NILFS2].resize, .label_util = "nilfs-tune", .info_util = "nilfs-tune", .uuid_util = "nilfs-tune" }, /* EXFAT */ { .type = "exfat", .mkfs_util = "mkfs.exfat", - .mkfs_options = fs_features[BD_FS_TECH_EXFAT].mkfs, .check_util = "fsck.exfat", .repair_util = "fsck.exfat", .resize_util = NULL, - .resize_mode = fs_features[BD_FS_TECH_EXFAT].resize, .label_util = "tune.exfat", .info_util = "tune.exfat", .uuid_util = "tune.exfat" }, /* BTRFS */ { .type = "btrfs", .mkfs_util = "mkfs.btrfs", - .mkfs_options = fs_features[BD_FS_TECH_BTRFS].mkfs, .check_util = "btrfsck", .repair_util = "btrfsck", .resize_util = "btrfs", - .resize_mode = fs_features[BD_FS_TECH_BTRFS].resize, .label_util = "btrfs", .info_util = "btrfs", .uuid_util = "btrfstune" }, /* UDF */ { .type = "udf", .mkfs_util = "mkudffs", - .mkfs_options = fs_features[BD_FS_TECH_UDF].mkfs, .check_util = NULL, .repair_util = NULL, .resize_util = NULL, - .resize_mode = fs_features[BD_FS_TECH_UDF].resize, .label_util = "udflabel", .info_util = "udfinfo", .uuid_util = "udflabel" }, @@ -1538,10 +1514,10 @@ static gboolean query_fs_operation (const gchar *fs_type, BDFSOpType op, gchar * } if (mode != NULL) - *mode = fsinfo->resize_mode; + *mode = fs_features[tech].resize; if (options != NULL) - *options = fsinfo->mkfs_options; + *options = fs_features[tech].mkfs; if (strlen (exec_util) == 0) { /* empty string if no util needed */ return TRUE;