Skip to content

Clang warning fixes #4482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/glfs-fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -5962,7 +5962,7 @@ glfs_recall_lease_upcall(struct glfs *fs, struct glfs_upcall *up_arg,
glfs_h_close(object);

/* Set reason to prevent applications from using ->event */
up_arg->reason = GF_UPCALL_EVENT_NULL;
up_arg->reason = GLFS_UPCALL_EVENT_NULL;
}
return ret;
}
Expand Down Expand Up @@ -6618,7 +6618,7 @@ void
gf_lease_to_glfs_lease(struct gf_lease *gf_lease, struct glfs_lease *lease)
{
u_int lease_type = gf_lease->lease_type;
lease->cmd = gf_lease->cmd;
lease->cmd = (glfs_lease_cmds_t)gf_lease->cmd;
lease->lease_type = lease_type;
memcpy(lease->lease_id, gf_lease->lease_id, LEASE_ID_SIZE);
}
Expand All @@ -6627,7 +6627,7 @@ void
glfs_lease_to_gf_lease(struct glfs_lease *lease, struct gf_lease *gf_lease)
{
u_int lease_type = lease->lease_type;
gf_lease->cmd = lease->cmd;
gf_lease->cmd = (gf_lease_cmds_t)lease->cmd;
gf_lease->lease_type = lease_type;
memcpy(gf_lease->lease_id, lease->lease_id, LEASE_ID_SIZE);
}
Expand Down
2 changes: 0 additions & 2 deletions cli/src/cli-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ cli_cmd_process_line(struct cli_state *state, const char *text)
char *token = NULL;
char *copy = NULL;
char *saveptr = NULL;
int i = 0;
int ret = -1;

count = cli_cmd_input_token_count(text);
Expand All @@ -185,7 +184,6 @@ cli_cmd_process_line(struct cli_state *state, const char *text)
if (!*tokenp)
goto out;
tokenp++;
i++;
}

ret = cli_cmd_process(state, count, tokens);
Expand Down
2 changes: 1 addition & 1 deletion glusterfsd/src/glusterfsd-mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ glusterfs_handle_node_status(rpcsvc_request_t *req)
default:
ret = -1;
msg = gf_strdup("Unknown status op");
gf_log(THIS->name, GF_LOG_ERROR, "%s", msg);
gf_log(THIS->name, GF_LOG_ERROR, "Unknown status op");
break;
}
rsp.op_ret = ret;
Expand Down
6 changes: 2 additions & 4 deletions libglusterfs/src/client_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,8 @@ gf_client_dump_fdtables(xlator_t *this)
clienttable->cliententries[count].next_free)
continue;
client = clienttable->cliententries[count].client;
if (client->client_uid) {
gf_proc_dump_build_key(key, "conn", "%d.id", count);
gf_proc_dump_write(key, "%s", client->client_uid);
}
gf_proc_dump_build_key(key, "conn", "%d.id", count);
gf_proc_dump_write(key, "%s", client->client_uid);

if (client->subdir_mount) {
gf_proc_dump_build_key(key, "conn", "%d.subdir", count);
Expand Down
2 changes: 1 addition & 1 deletion libglusterfs/src/common-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ gf_string2percent_or_bytesize(const char *str, double *n,
}

/* Error out if we cannot store the value in uint64 */
if ((UINT64_MAX - value) < 0) {
if ((UINT64_MAX - (unsigned long)value) < 0) {
errno = ERANGE;
return -1;
}
Expand Down
18 changes: 18 additions & 0 deletions libglusterfs/src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ dict_setn(dict_t *this, char *key, const int keylen, data_t *value)
return -1;
}

if (caa_unlikely(!key)) {
gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
"key is NULL");
return -1;
}

LOCK(&this->lock);

ret = dict_set_lk(this, key, keylen, value, 1);
Expand All @@ -426,6 +432,12 @@ dict_addn(dict_t *this, char *key, const int keylen, data_t *value)
return -1;
}

if (caa_unlikely(!key)) {
gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
"key is NULL");
return -1;
}

LOCK(&this->lock);

ret = dict_set_lk(this, key, keylen, value, 0);
Expand Down Expand Up @@ -2695,6 +2707,12 @@ dict_rename_key(dict_t *this, char *key, char *replace_key)
int ret = -EINVAL;
int replacekey_len = 0;

if (caa_unlikely(!replace_key)) {
gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
"key is NULL");
return -1;
}

/* replacing a key by itself is a NO-OP */
if (strcmp(key, replace_key) == 0)
return 0;
Expand Down
8 changes: 3 additions & 5 deletions libglusterfs/src/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,9 @@ __is_root_gfid(uuid_t gfid)
static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
const uint64_t *p = (uint64_t *)gfid;

if (caa_unlikely(!p))
return _gf_false;

if (*p) /*if it doesn't start with zero's, it's not root gfid */
return _gf_false;

Expand Down Expand Up @@ -1674,7 +1677,6 @@ inode_table_with_invalidator(uint32_t lru_limit, xlator_t *xl,
uint32_t inode_hashsize)
{
inode_table_t *new = NULL;
uint32_t mem_pool_size = lru_limit;
size_t diff;
int ret = -1;
int i = 0;
Expand Down Expand Up @@ -1729,10 +1731,6 @@ inode_table_with_invalidator(uint32_t lru_limit, xlator_t *xl,
new->inode_hashsize, inode_hashsize);
}

/* In case FUSE is initing the inode table. */
if (!mem_pool_size || (mem_pool_size > DEFAULT_INODE_MEMPOOL_ENTRIES))
mem_pool_size = DEFAULT_INODE_MEMPOOL_ENTRIES;

new->inode_hash = (void *)GF_MALLOC(
new->inode_hashsize * sizeof(struct list_head), gf_common_mt_list_head);
if (!new->inode_hash)
Expand Down
5 changes: 4 additions & 1 deletion xlators/cluster/afr/src/afr-self-heal-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,7 @@ afr_frame_create(xlator_t *this, int32_t *op_errno)
call_frame_t *frame = NULL;
afr_local_t *local = NULL;
pid_t pid = GF_CLIENT_PID_SELF_HEALD;
int ret = 0;

frame = create_frame(this, this->ctx->pool);
if (!frame) {
Expand All @@ -2462,9 +2463,11 @@ afr_frame_create(xlator_t *this, int32_t *op_errno)
return NULL;
}

local = AFR_FRAME_INIT(frame, (*op_errno));
local = AFR_FRAME_INIT(frame, ret);
if (!local) {
STACK_DESTROY(frame->root);
if (op_errno)
*op_errno = ret;
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion xlators/cluster/dht/src/dht-rebalance.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *cached_subvol,
if (entrylk_locked) {
lk_ret = syncop_entrylk(hashed_subvol, DHT_ENTRY_SYNC_DOMAIN,
&parent_loc, loc->name, ENTRYLK_UNLOCK,
ENTRYLK_UNLOCK, NULL, NULL);
ENTRYLK_WRLCK, NULL, NULL);
if (lk_ret < 0) {
gf_msg(this->name, GF_LOG_WARNING, -lk_ret,
DHT_MSG_MIGRATE_FILE_FAILED,
Expand Down
9 changes: 6 additions & 3 deletions xlators/features/shard/src/shard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,8 @@ shard_refresh_internal_dir_cbk(call_frame_t *frame, void *cookie,
{
shard_local_t *local = NULL;
inode_t *linked_inode = NULL;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
cookie;

local = frame->local;

Expand Down Expand Up @@ -1370,7 +1371,8 @@ shard_lookup_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
{
inode_t *link_inode = NULL;
shard_local_t *local = NULL;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
cookie;

local = frame->local;

Expand Down Expand Up @@ -5889,7 +5891,8 @@ shard_mkdir_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
{
inode_t *link_inode = NULL;
shard_local_t *local = NULL;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie;
shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long)
cookie;

local = frame->local;

Expand Down
12 changes: 7 additions & 5 deletions xlators/features/simple-quota/src/simple-quota.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sq_set_ns_hardlimit(xlator_t *this, inode_t *inode, int64_t limit, int64_t size,
ret = inode_ctx_put(inode, this, (uint64_t)(uintptr_t)sq_ctx);
if (IS_ERROR(ret)) {
GF_FREE(sq_ctx);
sq_ctx = NULL;
sq_ctx = NULL;
goto out;
}

Expand Down Expand Up @@ -217,7 +217,9 @@ sq_update_brick_usage(xlator_t *this, inode_t *inode)
if (!tmp_mq) {
goto out;
}
loc_t loc = { 0, };
loc_t loc = {
0,
};
loc.inode = inode_ref(inode);
int ret = syncop_getxattr(FIRST_CHILD(this), &loc, &dict, SQUOTA_SIZE_KEY,
NULL, NULL);
Expand Down Expand Up @@ -262,7 +264,7 @@ sq_update_hard_limit(xlator_t *this, inode_t *ns, int64_t limit, int64_t size)
limit, size);
sq_ctx->hard_lim = limit;

//GF_ASSERT(size > 0);
// GF_ASSERT(size > 0);

out:
return;
Expand Down Expand Up @@ -529,7 +531,7 @@ sq_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
uint32_t nlink = 0;
uint64_t blocks = 0;
int ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, &nlink);
if ((nlink == 1)) {
if (nlink == 1) {
ret = dict_get_uint64(xdata, GF_GET_FILE_BLOCK_COUNT, &blocks);
gf_msg(this->name, GF_LOG_DEBUG, 0, 0,
"reduce size by %" PRIu64 " blocks (ret: %d)", blocks, ret);
Expand Down Expand Up @@ -1014,7 +1016,7 @@ sq_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
uint32_t nlink = 0;
uint64_t blocks = 0;
int ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, &nlink);
if ((nlink == 1)) {
if (nlink == 1) {
ret = dict_get_uint64(xdata, GF_GET_FILE_BLOCK_COUNT, &blocks);
gf_msg(this->name, GF_LOG_DEBUG, 0, 0,
"reduce size by %" PRIu64 " blocks (ret: %d)", blocks, ret);
Expand Down
6 changes: 3 additions & 3 deletions xlators/mgmt/glusterd/src/glusterd-locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ glusterd_mgmt_v3_lock(const char *name, uuid_t uuid, uint32_t *op_errno,
"Failed to save "
"the back trace for lock %s granted to %s",
key_dup, uuid_utoa(uuid));
ret = 0;
}

#endif
Expand All @@ -627,7 +626,9 @@ gd_mgmt_v3_unlock_timer_cbk(void *data)
char *key = NULL;
int keylen;
int32_t ret = -1;

#ifdef DEBUG
int bt_key_len = 0;
#endif
conf = this->private;
GF_VALIDATE_OR_GOTO(this->name, conf, out);

Expand All @@ -639,7 +640,6 @@ gd_mgmt_v3_unlock_timer_cbk(void *data)

#ifdef DEBUG
char bt_key[PATH_MAX] = "";
int bt_key_len = 0;

bt_key_len = snprintf(bt_key, PATH_MAX, "debug.last-success-bt-%s", key);
if (bt_key_len != SLEN("debug.last-success-bt-") + keylen) {
Expand Down
4 changes: 3 additions & 1 deletion xlators/mgmt/glusterd/src/glusterd-messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ GLFS_MSGID(
GD_MSG_ADD_BRICK_MNT_INFO_FAIL, GD_MSG_GET_MNT_ENTRY_INFO_FAIL,
GD_MSG_QUORUM_CLUSTER_COUNT_GET_FAIL, GD_MSG_POST_COMMIT_OP_FAIL,
GD_MSG_POST_COMMIT_FROM_UUID_REJCT, GD_MSG_POST_COMMIT_REQ_SEND_FAIL,
GD_MSG_GRACEFUL_CLEANUP_SET_FAIL, GD_PMAP_PORT_BIND_FAILED);
GD_MSG_GRACEFUL_CLEANUP_SET_FAIL, GD_PMAP_PORT_BIND_FAILED,
GD_MSG_PLUGIN_NOT_FOUND);

#define GD_MSG_INVALID_ENTRY_STR "Invalid data entry"
#define GD_MSG_INVALID_ARGUMENT_STR \
Expand Down Expand Up @@ -411,6 +412,7 @@ GLFS_MSGID(
#define GD_MSG_VOLINFO_IMPORT_FAIL_STR "Volume is not yet imported"
#define GD_MSG_BRICK_SET_INFO_FAIL_STR \
"Failed to add brick mount details to dict"
#define GD_MSG_PLUGIN_NOT_FOUND_STR "Plugin not found"
#define GD_MSG_SET_XATTR_BRICK_FAIL_STR \
"Glusterfs is not supported on brick. Setting extended attribute failed"
#define GD_MSG_SET_XATTR_FAIL_STR "Failed to set extended attribute"
Expand Down
11 changes: 11 additions & 0 deletions xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ glusterd_snap_volinfo_restore(dict_t *dict, dict_t *rsp_dict,
/* To use generic functions from the plugin */
glusterd_snapshot_plugin_by_name(snap_volinfo->snap_plugin,
&snap_ops);
if (caa_unlikely(!snap_ops)) {
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PLUGIN_NOT_FOUND,
"Failed to find plugin for %s",
snap_volinfo->snap_plugin);
goto out;
}

snap_ops->brick_path(snap_mount_dir, brickinfo->origin_path, 0,
snap_volinfo->snapshot->snapname,
Expand Down Expand Up @@ -3314,6 +3320,11 @@ glusterd_snap_unmount(xlator_t *this, glusterd_volinfo_t *volinfo)
GF_ASSERT(volinfo);

glusterd_snapshot_plugin_by_name(volinfo->snap_plugin, &snap_ops);
if (caa_unlikely(!snap_ops)) {
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PLUGIN_NOT_FOUND,
"Failed to find plugin for %s", volinfo->snap_plugin);
goto out;
}

cds_list_for_each_entry(brickinfo, &volinfo->bricks, brick_list)
{
Expand Down
Loading