mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-21 00:42:16 +00:00
Orangefs: address problems found by static checker
Don't check for negative rc from boolean. Don't pointlessly initialize variables, it short-circuits gcc's uninitialized variable warnings. And max_new_nr_segs can never be zero, so don't check for it. Preserve original kstrdup pointer for freeing later. Don't check for negative value in unsigned variable. Signed-off-by: Mike Marshall <hubcap@omnibond.com>
This commit is contained in:
parent
84d02150de
commit
eeaa3d448c
@ -104,7 +104,6 @@ static void readdir_handle_dtor(struct pvfs2_bufmap *bufmap,
|
|||||||
*
|
*
|
||||||
* \param dir_emit callback function called for each entry read.
|
* \param dir_emit callback function called for each entry read.
|
||||||
*
|
*
|
||||||
* \retval <0 on error
|
|
||||||
* \retval 0 when directory has been completely traversed
|
* \retval 0 when directory has been completely traversed
|
||||||
* \retval >0 if we don't call dir_emit for all entries
|
* \retval >0 if we don't call dir_emit for all entries
|
||||||
*
|
*
|
||||||
@ -253,8 +252,6 @@ get_new_buffer_index:
|
|||||||
__func__,
|
__func__,
|
||||||
llu(pos));
|
llu(pos));
|
||||||
ret = dir_emit(ctx, ".", 1, ino, DT_DIR);
|
ret = dir_emit(ctx, ".", 1, ino, DT_DIR);
|
||||||
if (ret < 0)
|
|
||||||
goto out_destroy_handle;
|
|
||||||
ctx->pos++;
|
ctx->pos++;
|
||||||
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
||||||
"%s: ctx->pos:%lld\n",
|
"%s: ctx->pos:%lld\n",
|
||||||
@ -270,8 +267,6 @@ get_new_buffer_index:
|
|||||||
__func__,
|
__func__,
|
||||||
llu(pos));
|
llu(pos));
|
||||||
ret = dir_emit(ctx, "..", 2, ino, DT_DIR);
|
ret = dir_emit(ctx, "..", 2, ino, DT_DIR);
|
||||||
if (ret < 0)
|
|
||||||
goto out_destroy_handle;
|
|
||||||
ctx->pos++;
|
ctx->pos++;
|
||||||
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
||||||
"%s: ctx->pos:%lld\n",
|
"%s: ctx->pos:%lld\n",
|
||||||
@ -293,17 +288,6 @@ get_new_buffer_index:
|
|||||||
(unsigned long)pos);
|
(unsigned long)pos);
|
||||||
ret =
|
ret =
|
||||||
dir_emit(ctx, current_entry, len, current_ino, DT_UNKNOWN);
|
dir_emit(ctx, current_entry, len, current_ino, DT_UNKNOWN);
|
||||||
if (ret < 0) {
|
|
||||||
gossip_debug(GOSSIP_DIR_DEBUG,
|
|
||||||
"dir_emit() failed. ret:%d\n",
|
|
||||||
ret);
|
|
||||||
if (i < 2) {
|
|
||||||
gossip_err("dir_emit failed on one of the first two true PVFS directory entries.\n");
|
|
||||||
gossip_err("Duplicate entries may appear.\n");
|
|
||||||
}
|
|
||||||
buffer_full = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ctx->pos++;
|
ctx->pos++;
|
||||||
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
gossip_ldebug(GOSSIP_DIR_DEBUG,
|
||||||
"%s: ctx->pos:%lld\n",
|
"%s: ctx->pos:%lld\n",
|
||||||
|
@ -463,12 +463,12 @@ static ssize_t do_readv_writev(enum PVFS_io_type type, struct file *file,
|
|||||||
unsigned int to_free;
|
unsigned int to_free;
|
||||||
size_t count;
|
size_t count;
|
||||||
unsigned long seg;
|
unsigned long seg;
|
||||||
unsigned long new_nr_segs = 0;
|
unsigned long new_nr_segs;
|
||||||
unsigned long max_new_nr_segs = 0;
|
unsigned long max_new_nr_segs;
|
||||||
unsigned long seg_count = 0;
|
unsigned long seg_count;
|
||||||
unsigned long *seg_array = NULL;
|
unsigned long *seg_array;
|
||||||
struct iovec *iovecptr = NULL;
|
struct iovec *iovecptr;
|
||||||
struct iovec *ptr = NULL;
|
struct iovec *ptr;
|
||||||
|
|
||||||
total_count = 0;
|
total_count = 0;
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@ -477,12 +477,6 @@ static ssize_t do_readv_writev(enum PVFS_io_type type, struct file *file,
|
|||||||
|
|
||||||
/* Compute total and max number of segments after split */
|
/* Compute total and max number of segments after split */
|
||||||
max_new_nr_segs = bound_max_iovecs(iov, nr_segs, &count);
|
max_new_nr_segs = bound_max_iovecs(iov, nr_segs, &count);
|
||||||
if (max_new_nr_segs < 0) {
|
|
||||||
gossip_lerr("%s: could not bound iovec %lu\n",
|
|
||||||
__func__,
|
|
||||||
max_new_nr_segs);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
gossip_debug(GOSSIP_FILE_DEBUG,
|
gossip_debug(GOSSIP_FILE_DEBUG,
|
||||||
"%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",
|
"%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",
|
||||||
|
@ -1077,6 +1077,7 @@ void debug_string_to_mask(char *debug_string, void *mask, int type)
|
|||||||
char *unchecked_keyword;
|
char *unchecked_keyword;
|
||||||
int i;
|
int i;
|
||||||
char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
|
char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
|
||||||
|
char *original_pointer;
|
||||||
int element_count = 0;
|
int element_count = 0;
|
||||||
struct client_debug_mask *c_mask;
|
struct client_debug_mask *c_mask;
|
||||||
__u64 *k_mask;
|
__u64 *k_mask;
|
||||||
@ -1092,6 +1093,7 @@ void debug_string_to_mask(char *debug_string, void *mask, int type)
|
|||||||
element_count = num_kmod_keyword_mask_map;
|
element_count = num_kmod_keyword_mask_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
original_pointer = strsep_fodder;
|
||||||
while ((unchecked_keyword = strsep(&strsep_fodder, ",")))
|
while ((unchecked_keyword = strsep(&strsep_fodder, ",")))
|
||||||
if (strlen(unchecked_keyword)) {
|
if (strlen(unchecked_keyword)) {
|
||||||
for (i = 0; i < element_count; i++)
|
for (i = 0; i < element_count; i++)
|
||||||
@ -1105,7 +1107,7 @@ void debug_string_to_mask(char *debug_string, void *mask, int type)
|
|||||||
&k_mask);
|
&k_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(strsep_fodder);
|
kfree(original_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_c_mask(int i,
|
void do_c_mask(int i,
|
||||||
|
@ -77,10 +77,8 @@ ssize_t pvfs2_inode_getxattr(struct inode *inode, const char *prefix,
|
|||||||
gossip_err("pvfs2_inode_getxattr: bogus NULL pointers\n");
|
gossip_err("pvfs2_inode_getxattr: bogus NULL pointers\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (size < 0 ||
|
if ((strlen(name) + strlen(prefix)) >= PVFS_MAX_XATTR_NAMELEN) {
|
||||||
(strlen(name) + strlen(prefix)) >= PVFS_MAX_XATTR_NAMELEN) {
|
gossip_err("Invalid key length (%d)\n",
|
||||||
gossip_err("Invalid size (%d) or key length (%d)\n",
|
|
||||||
(int)size,
|
|
||||||
(int)(strlen(name) + strlen(prefix)));
|
(int)(strlen(name) + strlen(prefix)));
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user