0 is returned only if retval == 0, which is a problem because retval is a double type...