XML format change

Linus Torvalds torvalds at linux-foundation.org
Mon Dec 24 10:02:08 PST 2012


On Mon, Dec 24, 2012 at 2:12 AM, Jef Driesen <jefdriesen at telenet.be> wrote:
>
> Actually you should also take into account the libdivecomputer backend type,
> because just the model number and serial number tuple might overlap with
> those from other backends. But if you encode the model as the full device
> name (e.g. Suunto Vyper Air) and not just the model number, then you are
> already doing that of course.

Yes. I originally saved the vendor/device information separately, so we had

    dc->vendor = "Suunto";
    dc->product = "Vyper Air";

rather than the current

    dc->model = "Suunto Vyper Air";

setup.

It ended up being just extra work (you had to always check both), and
unlike libdivecomputer, there's no "backend type" for subsurface, so
there was no upside.

One thing I probably *should* have done is to make the "dc->deviceid"
be the SHA1SUM of not just the libdivecomputer device ID string, but
make it the SHA1 of the combination of model string and device ID
string. That would have been easy to do, and then the deviceid really
would be unique (well, modulo collisions in just the 32-bit truncated
space - but when people tend to have a single dive computer, and
having five would be considered unusual, there just isn't much point
in worrying about collisions ;)

[ Background for Jef, who probably didn't look at what subsurface
does: not only do we combine the libdivecomputer vendor/product into a
single model thing, the dive and device ID strings are not kept as
strings at all by subsurface. We create the dive ID by calculating the
SHA1 of your "fingerprint" string, and we do the device ID by
calculating the SHA1 over your model/firmware/serial numbers. In both
cases we then just take the 20-byte SHA1 and use the first four bytes
to create a 32-bit integer. So we've turned the arbitrary
libdivecomputer information into two 32-bit opaque numbers. That makes
things *much* easier to work with, and has the same amount of actual
information. ]

But if we were to now change subsurface to mix in the model string too
(not just the model number that libdivecomputer uses for
DC_EVENT_DEVINFO) into the device ID in subsurface, the existing
device ID's would change, so it would be slightly inconvenient. Also,
I do think that it is likely a good idea to always have the model
information in things like nickname tables, even if it would be
redundant - just for the human readability. So while having "globally
unique" device ID numbers (again, modulo collisions that we don't
really care about) could have been a programming convenience, I
suspect we're just as well off just always using the <model,deviceid>
tuple.

             Linus


More information about the subsurface mailing list