Various fixes from SCA and Coverity

Fixes for Coverity issues: 
- CID 1219473
- CID 1221525
- CID 1221526
- CID 745921 - CID 745926
- CID 1128384
- CID 1054853
- CID 1219463

Other fixes:
- rgw/rgw_formats.cc: fix realloc memory leak
- some whitespace and indentation fixes

Fixes from SCA tools:
- use static_cast/reinterpret_cast instead of c-style cast
- fix va_list parameter handling
- prefer ++operator for non-primitive iterators
- reduce scope of some variables
- move convert() call out of assert() to avoid Heisenbugs
- remove unused variables
- use empty() instead of size()
- remove self assignment of new_info.effective_uri
- add some cppcheck-suppress comments
-