Improve error handling in diagnostic_data.c
Improve error handling in diagnostic_data.c

* Use proper error code
* Detect errors and close file properly

barak/obp-utils,vincentbernat/mxt-app,boundarydevices/mxt-app,kdunning/mxt-app,boundarydevices/mxt-app,vincentbernat/mxt-app,barak/obp-utils,kdunning/mxt-app