summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-28 06:36:47 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-28 06:36:47 -0800
commit3872921ffebe4a35ff62a7814b8293b0da8f5eae (patch)
tree798dbd46593cd0b400930b613cb0ecdf3bdf3694
parentf6fb8823378a692acec09926b5ab42b0561b17f2 (diff)
downloadsubsurface-3872921ffebe4a35ff62a7814b8293b0da8f5eae.tar.gz
Divecomputer entries with deviceid 0 should be ignored for nicknames
Those only come from a number of development versions of Subsurface that didn't include the deviceid in the divecomputer entry. There is no way of telling different dive computers (of the same model) apart, so assigning a nickname to such an entry then creates incorrect output when loading an XML file from someone else (e.g. Linus and I both have a Uemis SDA and both may have entries for our own SDA with deviceid 0; then the nickname Subsurface shows for any Uemis SDA entry with a deviceid of 0 depends on whether I last loaded his XML file or mine; that makes no sense). This should only affect the develoers who stored XML files with one of the development version of Subsurface that didn't store deviceids. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--gtk-gui.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 35bfd5116..974cfe29d 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -2051,6 +2051,11 @@ void set_filename(const char *filename, gboolean force)
static struct dcnicknamelist *get_dc_nicknameentry(const char *model, int deviceid)
{
struct dcnicknamelist *known = nicknamelist;
+
+ /* a 0 deviceid doesn't get a nickname - those come from development
+ * versions of Subsurface that didn't store the deviceid in the divecomputer entries */
+ if (!deviceid)
+ return NULL;
if (!model)
model = "";
while (known) {
@@ -2077,6 +2082,11 @@ const char *get_dc_nickname(const char *model, uint32_t deviceid)
static struct dcnicknamelist *get_different_dc_nicknameentry(const char *model, int deviceid)
{
struct dcnicknamelist *known = nicknamelist;
+
+ /* a 0 deviceid matches any DC of the same model - those come from development
+ * versions of Subsurface that didn't store the deviceid in the divecomputer entries */
+ if (!deviceid)
+ return NULL;
if (!model)
model = "";
while (known) {
@@ -2163,6 +2173,11 @@ bail:
void remember_dc(const char *model, uint32_t deviceid, const char *nickname, gboolean change_conf)
{
+ /* we don't want to record entries with a deviceid of 0; those are from earlier
+ * development versions of Subsurface before we stored the hash in the divecomputer
+ * entries... we don't know which actual divecomputer those entries are from */
+ if (!deviceid)
+ return;
if (!nickname)
nickname = "";
if (!get_dc_nickname(model, deviceid)) {
@@ -2273,8 +2288,8 @@ void add_dc_to_string(char **dc_xml, struct divecomputer *dc)
const char *nickname;
int len;
- if (!dc || !dc->model || !*dc->model)
- /* we have no dc or no model information... nothing to do here */
+ if (!dc || !dc->model || !*dc->model || !dc->deviceid)
+ /* we have no dc or no model or no deviceid information... nothing to do here */
return;
len = sizeof(" model='' deviceid=''") + strlen(dc->model) + 8;
pattern = malloc(len);