Fix memory leak caused by using std::string to hold result
of strdup call returned from getObjName().
Fix for Coverity issues:
CID 1221525 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Failing to save or free storage allocated by
this->getObjName(soid, 0UL) leaks it.
CID 1221526 (1-3 of 3): Resource leak (RESOURCE_LEAK)
leaked_storage: Failing to save or free storage allocated by
this->getObjName(soid, *) leaks it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix handling of realloc. If realloc() fails it returns NULL, assigning
the return value of realloc() directly to the pointer without checking
for the result will lead to a memory leak in error case.
Use a temporary pointer to hold the result of realloc(). In error case
print error and exit, otherwise assign it to the pointer we want to realloc.
Fix also error checks for malloc to fail as soon as malloc fails and
don't try to run realloc again after failed malloc.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for:
CID 1128384 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN)
check_return: fread(void * restrict, size_t, size_t, FILE * restrict)
returns the number of bytes read, but it is ignored.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for:
CID 1054853 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking is_truncated suggests that it may
be null, but it has already been dereferenced on all paths leading
to the check.
Add vim line to file.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Check return value as done in all other places. Fix error messages
to print correct function name getdir and not read_dir/readdir since
the error isn't necessarily raised by read_dir().
Fix for:
CID 1219463 (#1 of 1): Unchecked return value (CHECKED_RETURN)
check_return: Calling getdir without checking return value (as
is done elsewhere 4 out of 5 times).
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for:
[src/test/test_rbd_replay.cc:193]: (portability) Passing NULL after the
last typed argument to a variadic function leads to undefined behaviour.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
The convert() call is changing data. To prevent Heisenbugs
depending in NDEBUG definition (e.g. if debug is off).
Move convert() call out of the assert call and use assert
only on the result value of the call.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
A junk value for ID was falling through from
the outer scope. Rename the outer one to
`osdid` and look up `id` explicitly in crush link.
For a bonus also add an error string for when
link_bucket returns an error (previously
would get plain "Error EINVAL")
Signed-off-by: John Spray <john.spray@redhat.com>
currently if you dump transaction for a single rbd write, a transaction
of OMAP_RMKEYS will be listed even if to_remove is empty.
Signed-off-by: xinxin shu <xinxin.shu@intel.com>