Code is mixing error reporting to LOGD and fprintf to stderr. It'd be better to make them print the errors in the same place.