fixes for part of errors found using clang checker and coverity

"make check" was ok.

full scan reports here:
https://www.dropbox.com/s/7w9zx8mg3d5c8tb/static_analyze_report.zip?dl=0
you can try to solve remaining errors.
Here get_data_pointer will always succeed though if you want to check if dt1 is valid, the proper way is to check the return value of get_data_pointer().