Skip to content

Commit

Permalink
glusterfs: Build with Modern C, change set 6
Browse files Browse the repository at this point in the history
GCC and Clang communities are hinting that in versions 14 and 16
respectively they will deprecate or disable legacy C89 features,
e.g. K&R1 style function definitions, among others.

In parallel, Fedora is going to start enforcing C99 as the minimum,
expected to land in F40. (I.e. around Spring 2024 IIRC.)

Currently Fedora is recommending that use of -Werror=implicit-int,
-Werror=implicit-function-declaration, -Werror=int-conversion,
-Werror=strict-prototypes, and -Werror=old-style-definition a set
of options to build with in the mean time to clean up code.

This change fixes a subset of the errors found when compiling with
this set of options.

Change-Id: Ia436ef321ad7963331d5cc813c98880525d0525e
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
  • Loading branch information
kalebskeithley authored and xhernandez committed Nov 4, 2022
1 parent 22a507a commit 8713385
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libglusterfs/src/dict.c
Expand Up @@ -65,7 +65,7 @@ get_new_data(void)
}

static dict_t *
get_new_dict_full()
get_new_dict_full(void)
{
dict_t *dict = mem_get0(THIS->ctx->dict_pool);

Expand Down
37 changes: 34 additions & 3 deletions libglusterfs/src/glusterfs/glfs-message-id.h
Expand Up @@ -153,6 +153,38 @@
#define GLFS_APPLY(_macro, _in, _num, _fields...) \
GLFS_APPLY_##_num(_macro, _in, ##_fields)

#define GLFS_APPLY_ARGS_0(_macro, _in) void

#define GLFS_APPLY_ARGS_1(_macro, _in, _f) _macro _f

#define GLFS_APPLY_ARGS_2(_macro, _in, _f, _more) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_1(_macro, _in, _more)

#define GLFS_APPLY_ARGS_3(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_2(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_4(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_3(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_5(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_4(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_6(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_5(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_7(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_6(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_8(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_7(_macro, _in, ##_more)

#define GLFS_APPLY_ARGS_9(_macro, _in, _f, _more...) \
_macro _f GLFS_EXPAND _in GLFS_APPLY_ARGS_8(_macro, _in, ##_more)

/* Apply a macro to a variable number of fields. */
#define GLFS_APPLY_ARGS(_macro, _in, _num, _fields...) \
GLFS_APPLY_ARGS_##_num(_macro, _in, ##_fields)

/* Translate a name into an internal name to avoid variable name collisions. */
#define GLFS_GET(_name) _glfs_var_##_name

Expand Down Expand Up @@ -190,11 +222,10 @@
#define GLFS_NAMES(_num, _fields...) GLFS_APPLY(GLFS_NAME, (), _num, ##_fields)

/* Generate a format string for all fields. */
#define GLFS_FMTS(_num, _fields...) \
GLFS_APPLY(GLFS_FMT, (", "), _num, ##_fields)
#define GLFS_FMTS(_num, _fields...) GLFS_APPLY(GLFS_FMT, (", "), _num, ##_fields)

/* Generate the function call argument declaration for all fields. */
#define GLFS_ARGS(_num, _fields...) GLFS_APPLY(GLFS_ARG, (, ), _num, ##_fields)
#define GLFS_ARGS(_num, _fields...) GLFS_APPLY_ARGS(GLFS_ARG, (, ), _num, ##_fields)

/* Generate the list of variables for all fields from a structure. */
#define GLFS_VARS(_num, _fields...) GLFS_APPLY(GLFS_VAR, (), _num, ##_fields)
Expand Down
2 changes: 1 addition & 1 deletion xlators/debug/io-stats/src/io-stats.c
Expand Up @@ -1030,7 +1030,7 @@ _resolve_group_name(xlator_t *this, gid_t gid)
* FAILURE: NULL
*/
static struct dnscache_entry *
gf_dnscache_entry_init()
gf_dnscache_entry_init(void)
{
struct dnscache_entry *entry = GF_CALLOC(1, sizeof(*entry),
gf_common_mt_dnscache_entry);
Expand Down
4 changes: 2 additions & 2 deletions xlators/mgmt/glusterd/src/glusterd-handshake.c
Expand Up @@ -1234,7 +1234,7 @@ gd_validate_cluster_op_version(xlator_t *this, int cluster_op_version,
}

static gf_boolean_t
glusterd_have_volumes()
glusterd_have_volumes(void)
{
xlator_t *this = THIS;
glusterd_conf_t *priv = NULL;
Expand All @@ -1249,7 +1249,7 @@ glusterd_have_volumes()
}

static gf_boolean_t
glusterd_have_peers()
glusterd_have_peers(void)
{
glusterd_conf_t *conf = NULL;

Expand Down
6 changes: 3 additions & 3 deletions xlators/mgmt/glusterd/src/glusterd-nfs-svc.c
Expand Up @@ -21,7 +21,7 @@
#include "glusterd-svc-helper.h"

static gf_boolean_t
glusterd_nfssvc_need_start()
glusterd_nfssvc_need_start(void)
{
glusterd_conf_t *priv = NULL;
gf_boolean_t start = _gf_false;
Expand All @@ -44,7 +44,7 @@ glusterd_nfssvc_need_start()
}

static int
glusterd_nfssvc_create_volfile()
glusterd_nfssvc_create_volfile(void)
{
char filepath[PATH_MAX] = {
0,
Expand Down Expand Up @@ -142,7 +142,7 @@ glusterd_nfssvc_build(glusterd_svc_t *svc)
}

int
glusterd_nfssvc_reconfigure()
glusterd_nfssvc_reconfigure(void)
{
int ret = -1;
xlator_t *this = THIS;
Expand Down
2 changes: 1 addition & 1 deletion xlators/mgmt/glusterd/src/glusterd-nfs-svc.h
Expand Up @@ -18,7 +18,7 @@ void
glusterd_nfssvc_build(glusterd_svc_t *svc);

int
glusterd_nfssvc_reconfigure();
glusterd_nfssvc_reconfigure(void);

#endif /* BUILD_GNFS */
#endif

0 comments on commit 8713385

Please sign in to comment.