no dives are shown in the Dive List
dirk at hohndel.org
Mon Jan 27 10:10:09 UTC 2014
On Mon, 2014-01-27 at 10:53 +0100, Jef Driesen wrote:
> I think the real problem is something else. Jun Song's dives fail to
> parse. Not sure why yet. But that's just one part of the problem. When I
> try download the memory dump into subsurface, I can confirm no dives are
> imported. No error message is shown. So it seems subsurface is silently
> dropping dives that are failing to parse. That's the second part of the
> I quickly checked the subsurface code. The dive_cb function exits
> immediately in case of a parsing error, and as a result the dive never
> gets added anywhere.
Which seems reasonable. If we can't parse it, we clearly can't add it.
> But the error is also never reported back to the
> user. There is a call to the dev_info function to show an error message
> in the progress bar, but I assume that because the download dialog is
> closed almost immediately, the user doesn't have a chance to notice this
> error message.
I'll fix that.
> The libdivecomputer error code is used as the exit code for the dive_cb
> function. But this is not used to communicate errors back to the caller.
> The return value of the callback function is used to tell
> libdivecomputer whether it should proceed with the next dive or not. It
> should be either 0 (abort) or 1 (continue). Note that the (negative)
> dc_status_t error codes happens to work too, because all non-zero values
> evaluate to "true" in the boolean expression that is used internally.
Fun. So a long time ago Linus misunderstood the libdivecomputer API
(clearly documented in http://libdivecomputer.org/manual.html) and ever
since we didn't deal with errors correctly. We faithfully returned the
error codes, clearly assuming that they would be passed on to the
device_foreach function. But reading the source that clearly isn't the
case. And that's why we never respond to the error - it never gets
passed up the stack!
If I read the sources correctly, then Subsurface needs to pass the error
code to the calling function some other way as an error in the parser
that we find in the dive_cb cannot be passed back up to the actual
caller (do_device_import() in libdivecomputer.c) as dc_device_foreach()
will report DC_STATUS_SUCCESS even if the parsing of a dive failed and
caused us to abort the operation.
Am I reading this correctly?
More information about the subsurface