Skip to content

Commit

Permalink
Use glib2 G_GNUC_UNUSED in place of UNUSED locally defined
Browse files Browse the repository at this point in the history
Signed-off-by: Giulio Benetti <[email protected]>
  • Loading branch information
giuliobenetti committed Jan 22, 2024
1 parent 65f50bf commit 78cf9e6
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 93 deletions.
3 changes: 1 addition & 2 deletions src/plugins/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ void bd_btrfs_close (void) {
}


#define UNUSED __attribute__((unused))

/**
* bd_btrfs_is_tech_avail:
Expand All @@ -165,7 +164,7 @@ void bd_btrfs_close (void) {
* Returns: whether the @tech-@mode combination is available -- supported by the
* plugin implementation and having all the runtime dependencies available
*/
gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech UNUSED, guint64 mode UNUSED, GError **error) {
gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech G_GNUC_UNUSED, guint64 mode G_GNUC_UNUSED, GError **error) {
/* all tech-mode combinations are supported by this implementation of the plugin */
return check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) &&
check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error);
Expand Down
23 changes: 12 additions & 11 deletions src/plugins/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#define DEFAULT_LUKS2_SECTOR_SIZE 512
#endif

#define UNUSED __attribute__((unused))

/**
* SECTION: crypto
Expand Down Expand Up @@ -304,7 +303,7 @@ BDCryptoLUKSTokenInfo* bd_crypto_luks_token_info_copy (BDCryptoLUKSTokenInfo *in
/* "C" locale to get the locale-agnostic error messages */
static locale_t c_locale = (locale_t) 0;

static void crypto_log_redirect (gint level, const gchar *msg, void *usrptr UNUSED) {
static void crypto_log_redirect (gint level, const gchar *msg, void *usrptr G_GNUC_UNUSED) {
gchar *message = NULL;

switch (level) {
Expand Down Expand Up @@ -465,7 +464,7 @@ GQuark bd_crypto_error_quark (void)
*
* Tech category: always available
*/
gchar* bd_crypto_generate_backup_passphrase (GError **error UNUSED) {
gchar* bd_crypto_generate_backup_passphrase (GError **error G_GNUC_UNUSED) {
guint8 i = 0;
guint8 offset = 0;
guint8 charset_length = strlen (BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET);
Expand Down Expand Up @@ -833,7 +832,7 @@ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_passphrase (const guint8 *
*
* Tech category: always available
*/
BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile (const gchar *keyfile, guint64 keyfile_offset, gsize key_size, GError **error UNUSED) {
BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile (const gchar *keyfile, guint64 keyfile_offset, gsize key_size, GError **error G_GNUC_UNUSED) {
BDCryptoKeyslotContext *context = NULL;

context = g_new0 (BDCryptoKeyslotContext, 1);
Expand All @@ -860,7 +859,7 @@ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile (const gchar *keyf
*
* Tech category: always available
*/
BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyring (const gchar *key_desc, GError **error UNUSED) {
BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyring (const gchar *key_desc, GError **error G_GNUC_UNUSED) {
BDCryptoKeyslotContext *context = NULL;

context = g_new0 (BDCryptoKeyslotContext, 1);
Expand Down Expand Up @@ -2392,7 +2391,7 @@ BDCryptoIntegrityInfo* bd_crypto_integrity_info (const gchar *device, GError **e

/* added in cryptsetup 2.4.0 */
#ifndef LIBCRYPTSETUP_24
static int crypt_token_max (const char *type UNUSED) {
static int crypt_token_max (const char *type G_GNUC_UNUSED) {
return 32;
}
#endif
Expand Down Expand Up @@ -2941,11 +2940,11 @@ gboolean bd_crypto_tc_close (const gchar *tc_device, GError **error) {
}

#ifdef WITH_BD_ESCROW
static gchar *always_fail_cb (gpointer data UNUSED, const gchar *prompt UNUSED, int echo UNUSED) {
static gchar *always_fail_cb (gpointer data G_GNUC_UNUSED, const gchar *prompt G_GNUC_UNUSED, int echo G_GNUC_UNUSED) {
return NULL;
}

static gchar *give_passphrase_cb (gpointer data, const gchar *prompt UNUSED, unsigned failed_attempts) {
static gchar *give_passphrase_cb (gpointer data, const gchar *prompt G_GNUC_UNUSED, unsigned failed_attempts) {
if (failed_attempts == 0)
/* Return a copy of the passphrase that will be freed by volume_key */
return g_strdup (data);
Expand Down Expand Up @@ -3046,7 +3045,8 @@ static gboolean write_escrow_data_file (struct libvk_volume *volume, struct libv
* Tech category: %BD_CRYPTO_TECH_ESCROW-%BD_CRYPTO_TECH_MODE_CREATE
*/
#ifndef WITH_BD_ESCROW
gboolean bd_crypto_escrow_device (const gchar *device UNUSED, const gchar *passphrase UNUSED, const gchar *cert_data UNUSED, const gchar *directory UNUSED, const gchar *backup_passphrase UNUSED, GError **error) {
gboolean bd_crypto_escrow_device (const gchar *device G_GNUC_UNUSED, const gchar *passphrase G_GNUC_UNUSED,const gchar *cert_data G_GNUC_UNUSED,
const gchar *directory G_GNUC_UNUSED, const gchar *backup_passphrase G_GNUC_UNUSED, GError **error) {
/* this will return FALSE and set error, because escrow technology is not available */
return bd_crypto_is_tech_avail (BD_CRYPTO_TECH_ESCROW, BD_CRYPTO_TECH_MODE_CREATE, error);
}
Expand Down Expand Up @@ -3307,7 +3307,8 @@ gboolean bd_crypto_bitlk_close (const gchar *bitlk_device, GError **error) {
* Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
*/
#ifndef LIBCRYPTSETUP_26
gboolean bd_crypto_fvault2_open (const gchar *device UNUSED, const gchar *name UNUSED, BDCryptoKeyslotContext *context UNUSED, gboolean read_only UNUSED, GError **error) {
gboolean bd_crypto_fvault2_open (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED,
gboolean read_only G_GNUC_UNUSED, GError **error) {
/* this will return FALSE and set error, because FVAULT2 technology is not available */
return bd_crypto_is_tech_avail (BD_CRYPTO_TECH_FVAULT2, BD_CRYPTO_TECH_MODE_OPEN_CLOSE, error);
#else
Expand Down Expand Up @@ -3401,7 +3402,7 @@ gboolean bd_crypto_fvault2_open (const gchar *device, const gchar *name, BDCrypt
* Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
*/
#ifndef LIBCRYPTSETUP_26
gboolean bd_crypto_fvault2_close (const gchar *fvault2_device UNUSED, GError **error) {
gboolean bd_crypto_fvault2_close (const gchar *fvault2_device G_GNUC_UNUSED, GError **error) {
/* this will return FALSE and set error, because FVAULT2 technology is not available */
return bd_crypto_is_tech_avail (BD_CRYPTO_TECH_FVAULT2, BD_CRYPTO_TECH_MODE_OPEN_CLOSE, error);
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#define DM_MIN_VERSION "1.02.93"

#define UNUSED __attribute__((unused))

/**
* SECTION: dm
Expand Down Expand Up @@ -100,7 +99,7 @@ void bd_dm_close (void) {
* Returns: whether the @tech-@mode combination is available -- supported by the
* plugin implementation and having all the runtime dependencies available
*/
gboolean bd_dm_is_tech_avail (BDDMTech tech, guint64 mode UNUSED, GError **error) {
gboolean bd_dm_is_tech_avail (BDDMTech tech, guint64 mode G_GNUC_UNUSED, GError **error) {
/* all combinations are supported by this implementation of the plugin, but
BD_DM_TECH_MAP requires the 'dmsetup' utility */
switch (tech) {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_BTRFSTUNE_MASK, /* set-uuid */
};

#define UNUSED __attribute__((unused))

/**
* bd_fs_btrfs_is_tech_avail:
Expand All @@ -69,7 +68,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_btrfs_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_btrfs_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/exfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
#define CLUSTERS_PREFIX_LEN 25


#define UNUSED __attribute__((unused))

/**
* bd_fs_exfat_is_tech_avail:
Expand All @@ -75,7 +74,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_exfat_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_exfat_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_TUNE2FS_MASK /* set-uuid */
};

#define UNUSED __attribute__((unused))

static gint8 compute_percents (guint8 pass_cur, guint8 pass_total, gint val_cur, gint val_total) {
gint perc;
Expand Down Expand Up @@ -157,7 +156,7 @@ static gboolean extract_e2fsck_progress (const gchar *line, guint8 *completion)
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_ext_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_ext_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;
for (i = 0; i <= BD_FS_MODE_LAST; i++)
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/f2fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
0 /* set-uuid */
};

#define UNUSED __attribute__((unused))

/* option to get version was added in 1.11.0 so we need to cover situation
where the version is too old to check the version */
Expand Down Expand Up @@ -110,7 +109,7 @@ static gboolean can_check_f2fs_version (UtilDep dep, GError **error) {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_f2fs_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_f2fs_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "ntfs.h"
#include "f2fs.h"

#define UNUSED __attribute__((unused))


typedef enum {
Expand Down Expand Up @@ -305,7 +304,7 @@ const BDFSInfo fs_info[BD_FS_LAST_FS] = {
*
* Tech category: always available
*/
const gchar** bd_fs_supported_filesystems (GError **error UNUSED) {
const gchar** bd_fs_supported_filesystems (GError **error G_GNUC_UNUSED) {
const gchar **filesystems = g_new0 (const gchar *, BD_FS_LAST_FS - BD_FS_OFFSET + 1);
gint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_NILFSTUNE_MASK, /* set-uuid */
};

#define UNUSED __attribute__((unused))

#ifdef __clang__
#define ZERO_INIT {}
Expand All @@ -72,7 +71,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_nilfs2_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_nilfs2_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/ntfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_NTFSLABEL_MASK /* set-uuid */
};

#define UNUSED __attribute__((unused))

/**
* bd_fs_ntfs_is_tech_avail:
Expand All @@ -73,7 +72,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_ntfs_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_ntfs_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;
for (i = 0; i <= BD_FS_MODE_LAST; i++)
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_UDFLABEL_MASK, /* set-uuid */
};

#define UNUSED __attribute__((unused))

/**
* bd_fs_udf_is_tech_avail:
Expand All @@ -72,7 +71,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_udf_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_udf_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/vfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_FATLABELUUID_MASK, /* set-uuid */
};

#define UNUSED __attribute__((unused))

#ifdef __clang__
#define ZERO_INIT {}
Expand All @@ -81,7 +80,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_vfat_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_vfat_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/fs/xfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_XFS_ADMIN_MASK /* set-uuid */
};

#define UNUSED __attribute__((unused))

#ifdef __clang__
#define ZERO_INIT {}
Expand All @@ -79,7 +78,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
* plugin implementation and having all the runtime dependencies available
*/
gboolean __attribute__ ((visibility ("hidden")))
bd_fs_xfs_is_tech_avail (BDFSTech tech UNUSED, guint64 mode, GError **error) {
bd_fs_xfs_is_tech_avail (BDFSTech tech G_GNUC_UNUSED, guint64 mode, GError **error) {
guint32 required = 0;
guint i = 0;
for (i = 0; i <= BD_FS_MODE_LAST; i++)
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void bd_loop_close (void) {
/* nothing to do here */
}

#define UNUSED __attribute__((unused))

/**
* bd_loop_is_tech_avail:
Expand All @@ -86,7 +85,7 @@ void bd_loop_close (void) {
* Returns: whether the @tech-@mode combination is available -- supported by the
* plugin implementation and having all the runtime dependencies available
*/
gboolean bd_loop_is_tech_avail (BDLoopTech tech UNUSED, guint64 mode UNUSED, GError **error UNUSED) {
gboolean bd_loop_is_tech_avail (BDLoopTech tech G_GNUC_UNUSED, guint64 mode G_GNUC_UNUSED, GError **error G_GNUC_UNUSED) {
/* all combinations are supported by this implementation of the plugin */
return TRUE;
}
Expand Down Expand Up @@ -206,7 +205,7 @@ BDLoopInfo* bd_loop_info (const gchar *loop, GError **error) {
*
* Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_QUERY
*/
gchar* bd_loop_get_loop_name (const gchar *file, GError **error UNUSED) {
gchar* bd_loop_get_loop_name (const gchar *file, GError **error G_GNUC_UNUSED) {
glob_t globbuf;
gchar **path_p;
gboolean success = FALSE;
Expand Down
Loading

0 comments on commit 78cf9e6

Please sign in to comment.