From 50ae3e67e4f294925fc840d3f83b77f7072af54d Mon Sep 17 00:00:00 2001 From: Kaleb S KEITHLEY Date: Wed, 18 Nov 2015 12:28:42 -0500 Subject: all: reduce "inline" usage There are three kinds of inline functions: plain inline, extern inline, and static inline. All three have been removed from .c files, except those in "contrib" which aren't our problem. Inlines in .h files, which are overwhelmingly "static inline" already, have generally been left alone. Over time we should be able to "lower" these into .c files, but that has to be done in a case-by-case fashion requiring more manual effort. This part was easy to do automatically without (as far as I can tell) any ill effect. In the process, several pieces of dead code were flagged by the compiler, and were removed. backport of Change-Id: I56a5e614735c9e0a6ee420dab949eac22e25c155, http://review.gluster.org/11769, BUG: 1245331 Change-Id: Iba1efb0bc578ea4a5e9bf76b7bd93dc1be9eba44 BUG: 1283302 Signed-off-by: Kaleb S KEITHLEY Reviewed-on: http://review.gluster.org/12646 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- .../changelog/lib/src/gf-changelog-reborp.c | 53 +--------------------- xlators/features/changelog/lib/src/gf-changelog.c | 2 +- .../features/changelog/src/changelog-encoders.c | 2 +- .../features/changelog/src/changelog-ev-handle.c | 6 +-- xlators/features/changelog/src/changelog-helpers.c | 26 +++++------ xlators/features/changelog/src/changelog-rpc.c | 2 +- xlators/features/changelog/src/changelog.c | 2 +- 7 files changed, 21 insertions(+), 72 deletions(-) (limited to 'xlators/features/changelog') diff --git a/xlators/features/changelog/lib/src/gf-changelog-reborp.c b/xlators/features/changelog/lib/src/gf-changelog-reborp.c index 2a1e56ae79e..19c43cc8211 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-reborp.c +++ b/xlators/features/changelog/lib/src/gf-changelog-reborp.c @@ -87,55 +87,6 @@ gf_changelog_connection_janitor (void *arg) return NULL; } -static inline void -__gf_changelog_set_conn_state (gf_changelog_t *entry, - gf_changelog_conn_state_t state) -{ - entry->connstate = state; -} - -/** - * state check login to gaurd access object after free - */ -static inline void -gf_changelog_check_event (gf_private_t *priv, - gf_changelog_t *entry, rpcsvc_event_t event) -{ - gf_boolean_t needfree = _gf_false; - gf_changelog_conn_state_t laststate; - /** - * need to handle couple of connection states to gaurd correct - * freeing of object. - */ - LOCK (&entry->statelock); - { - laststate = entry->connstate; - if (event == RPCSVC_EVENT_ACCEPT) { - __gf_changelog_set_conn_state - (entry, GF_CHANGELOG_CONN_STATE_ACCEPTED); - - if (laststate == GF_CHANGELOG_CONN_STATE_DISCONNECTED) - needfree = _gf_true; - } - - if (event == RPCSVC_EVENT_DISCONNECT) { - __gf_changelog_set_conn_state - (entry, GF_CHANGELOG_CONN_STATE_DISCONNECTED); - - if (laststate == GF_CHANGELOG_CONN_STATE_ACCEPTED) - needfree = _gf_true; - } - } - UNLOCK (&entry->statelock); - - /** - * TODO: - * Handle the race between ACCEPT and DISCONNECT in the - * reconnect code. So purging of entry is deliberately - * avoided here. It will be handled in the reconnect code. - */ -} - int gf_changelog_reborp_rpcsvc_notify (rpcsvc_t *rpc, void *mydata, rpcsvc_event_t event, void *data) @@ -173,8 +124,6 @@ gf_changelog_reborp_rpcsvc_notify (rpcsvc_t *rpc, void *mydata, break; } - /* gf_changelog_check_event (priv, entry, event); */ - return 0; } @@ -230,7 +179,7 @@ gf_changelog_invoke_callback (gf_changelog_t *entry, * dynamically allocated and ordered. */ -inline int +int __is_expected_sequence (struct gf_event_list *ev, struct gf_event *event) { return (ev->next_seq == event->seq); diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c index bc953369343..c528a24f017 100644 --- a/xlators/features/changelog/lib/src/gf-changelog.c +++ b/xlators/features/changelog/lib/src/gf-changelog.c @@ -44,7 +44,7 @@ */ xlator_t *master = NULL; -static inline +static gf_private_t *gf_changelog_alloc_priv () { int ret = 0; diff --git a/xlators/features/changelog/src/changelog-encoders.c b/xlators/features/changelog/src/changelog-encoders.c index ea395e11f90..4e06abfb5ce 100644 --- a/xlators/features/changelog/src/changelog-encoders.c +++ b/xlators/features/changelog/src/changelog-encoders.c @@ -133,7 +133,7 @@ del_entry_free_fn (void *data) * try to write all data in one shot */ -static inline void +static void changelog_encode_write_xtra (changelog_log_data_t *cld, char *buffer, size_t *off, gf_boolean_t encode) { diff --git a/xlators/features/changelog/src/changelog-ev-handle.c b/xlators/features/changelog/src/changelog-ev-handle.c index ca7443cfd22..bcce28ebd7e 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.c +++ b/xlators/features/changelog/src/changelog-ev-handle.c @@ -42,7 +42,7 @@ changelog_event_dispatch_cbk (struct rpc_req *req, } /* dispatcher RPC */ -inline int +int changelog_dispatch_vec (call_frame_t *frame, xlator_t *this, struct rpc_clnt *rpc, struct ev_rpc_vec *vec) { @@ -241,7 +241,7 @@ changelog_ev_cleanup_connections (xlator_t *this, changelog_clnt_t *c_clnt) * a performance bottleneck. */ -static inline changelog_rpc_clnt_t * +static changelog_rpc_clnt_t * get_client (changelog_clnt_t *c_clnt, struct list_head **next) { changelog_rpc_clnt_t *crpc = NULL; @@ -260,7 +260,7 @@ get_client (changelog_clnt_t *c_clnt, struct list_head **next) return crpc; } -static inline void +static void put_client (changelog_clnt_t *c_clnt, changelog_rpc_clnt_t *crpc) { LOCK (&c_clnt->active_lock); diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 73963779418..d692753f084 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -62,7 +62,7 @@ changelog_thread_cleanup (xlator_t *this, pthread_t thr_id) return ret; } -inline void * +void * changelog_get_usable_buffer (changelog_local_t *local) { changelog_log_data_t *cld = NULL; @@ -77,7 +77,7 @@ changelog_get_usable_buffer (changelog_local_t *local) return cld->cld_iobuf->ptr; } -static inline int +static int changelog_selector_index (unsigned int selector) { return (ffs (selector) - 1); @@ -186,7 +186,7 @@ changelog_cleanup_event_selection (xlator_t *this, return LOCK_DESTROY (&selection->reflock); } -static inline void +static void changelog_perform_dispatch (xlator_t *this, changelog_priv_t *priv, void *mem, size_t size) { @@ -216,7 +216,7 @@ changelog_dispatch_event (xlator_t *this, } } -inline void +void changelog_set_usable_record_and_length (changelog_local_t *local, size_t len, int xr) { @@ -256,7 +256,7 @@ changelog_local_cleanup (xlator_t *xl, changelog_local_t *local) mem_put (local); } -inline int +int changelog_write (int fd, char *buffer, size_t len) { ssize_t size = 0; @@ -925,7 +925,7 @@ changelog_start_next_change (xlator_t *this, /** * return the length of entry */ -inline size_t +size_t changelog_entry_length () { return sizeof (changelog_log_data_t); @@ -1013,7 +1013,7 @@ out: return ret; } -inline int +int changelog_handle_change (xlator_t *this, changelog_priv_t *priv, changelog_log_data_t *cld) { @@ -1555,7 +1555,7 @@ changelog_inode_ctx_get (xlator_t *this, * then there is no need to record an update (as the equality of the two version * signifies an update was recorded in the current time slice). */ -inline void +void changelog_update (xlator_t *this, changelog_priv_t *priv, changelog_local_t *local, changelog_log_type type) { @@ -1623,7 +1623,7 @@ changelog_update (xlator_t *this, changelog_priv_t *priv, * not incremented fop count but color is assigned black. */ -inline void +void changelog_color_fop_and_inc_cnt (xlator_t *this, changelog_priv_t *priv, changelog_local_t *local) { @@ -1639,7 +1639,7 @@ changelog_color_fop_and_inc_cnt (xlator_t *this, changelog_priv_t *priv, } /* Increments the respective fop counter based on the fop color */ -inline void +void changelog_inc_fop_cnt (xlator_t *this, changelog_priv_t *priv, changelog_local_t *local) { @@ -1669,7 +1669,7 @@ changelog_inc_fop_cnt (xlator_t *this, changelog_priv_t *priv, } /* Decrements the respective fop counter based on the fop color */ -inline void +void changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, changelog_local_t *local) { @@ -1719,7 +1719,7 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, /* Write to a pipe setup between changelog main thread and changelog * rollover thread to initiate explicit rollover of changelog journal. */ -inline int +int changelog_barrier_notify (changelog_priv_t *priv, char *buf) { int ret = 0; @@ -1731,7 +1731,7 @@ changelog_barrier_notify (changelog_priv_t *priv, char *buf) } /* Clean up flags set on barrier notification */ -inline void +void changelog_barrier_cleanup (xlator_t *this, changelog_priv_t *priv, struct list_head *queue) { diff --git a/xlators/features/changelog/src/changelog-rpc.c b/xlators/features/changelog/src/changelog-rpc.c index c7c0fffa9f5..005ac15c3c7 100644 --- a/xlators/features/changelog/src/changelog-rpc.c +++ b/xlators/features/changelog/src/changelog-rpc.c @@ -187,7 +187,7 @@ changelog_rpc_clnt_cleanup (changelog_rpc_clnt_t *crpc) GF_FREE (crpc); } -static inline changelog_rpc_clnt_t * +static changelog_rpc_clnt_t * changelog_rpc_clnt_init (xlator_t *this, changelog_probe_req *rpc_req, changelog_clnt_t *c_clnt) { diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index 09dd55626d4..8898d51344f 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -2454,7 +2454,7 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) } /* Destroy barrier related condition variables and locks */ -static inline void +static void changelog_barrier_pthread_destroy (changelog_priv_t *priv) { pthread_mutex_destroy (&priv->bn.bnotify_mutex); -- cgit