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:
Mike Marshall
2015-07-29 13:36:37 -04:00
parent 84d02150de
commit eeaa3d448c
4 changed files with 11 additions and 33 deletions

View File

@@ -463,12 +463,12 @@ static ssize_t do_readv_writev(enum PVFS_io_type type, struct file *file,
unsigned int to_free;
size_t count;
unsigned long seg;
unsigned long new_nr_segs = 0;
unsigned long max_new_nr_segs = 0;
unsigned long seg_count = 0;
unsigned long *seg_array = NULL;
struct iovec *iovecptr = NULL;
struct iovec *ptr = NULL;
unsigned long new_nr_segs;
unsigned long max_new_nr_segs;
unsigned long seg_count;
unsigned long *seg_array;
struct iovec *iovecptr;
struct iovec *ptr;
total_count = 0;
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 */
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,
"%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",