Check return value when it make sense.

Fixes CID #965890, #965892, #965893, #965894, #965898, #1084351
Remove dead conditionals

Fixes CID #965943 #965949
Fix integer overflow

Fixes CID #966079, #966078
Remove unused pointer

Fixes CID #966530
Fix uninitialized scalar field

 CID #966282, #966283, #966284, #966285, #966286, #966287, #966316,
 #966343, #966349, #966363, #966364, #966366, #966370, #966373, #966374,
 #966376, #966377
Remove unused variables.

Partialy fixes CID #966363
Fix Uninitialized pointer field

CID #966313