summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0a17f3d)
raw | patch | inline | side by side (parent: 0a17f3d)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 4 Jul 2014 18:42:58 +0000 (20:42 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 4 Jul 2014 18:42:58 +0000 (20:42 +0200) |
Also, extended the unit tests to catch this error.
src/core/store.c | patch | blob | history | |
t/unit/core/store_test.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index 323ed778b7c52fa76c8d492447781b2920695995..7de75b1ee546e6a49509746fa0a13410834ba779 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
int status;
status = store_obj(attributes, SDB_ATTRIBUTE, key, last_update, &attr);
- if (status < 0)
+ if (status)
return status;
assert(attr);
index 6715a5b0868a49714b3a9e3664ff586e6455166c..1eb387e34b855f0625b110715f2d7e919e6d3892 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
datum.data.string = "v1";
sdb_store_attribute("h1", "k1", &datum, 1);
datum.data.string = "v2";
- sdb_store_attribute("h1", "k2", &datum, 1);
+ sdb_store_attribute("h1", "k2", &datum, 2);
datum.data.string = "v3";
- sdb_store_attribute("h1", "k3", &datum, 1);
+ sdb_store_attribute("h1", "k3", &datum, 2);
+
+ /* make sure that older updates don't overwrite existing values */
+ datum.data.string = "fail";
+ sdb_store_attribute("h1", "k2", &datum, 1);
+ sdb_store_attribute("h1", "k3", &datum, 2);
sdb_store_service("h2", "s1", 1);
sdb_store_service("h2", "s2", 1);