Skip to content

Commit 1dea76f

Browse files
committed
Serialize value: Fix check for simple value
Only THINGSET_ERR_UNSUPPORTED_FORMAT indicates that a value was not a simple value. There may also be other error codes, which should be propagated correctly.
1 parent 8de7f18 commit 1dea76f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/thingset_bin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ static int bin_serialize_value(struct thingset_context *ts,
208208
int err;
209209

210210
err = bin_serialize_simple_value(ts->encoder, object->data, object->type, object->detail);
211-
if (err == 0) {
212-
return 0;
211+
if (err != -THINGSET_ERR_UNSUPPORTED_FORMAT) {
212+
return err;
213213
}
214214

215215
/* not a simple value */

src/thingset_txt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static int txt_serialize_value(struct thingset_context *ts,
247247

248248
int pos = json_serialize_simple_value(buf, size, object->data, object->type, object->detail);
249249

250-
if (pos < 0) {
250+
if (pos == -THINGSET_ERR_UNSUPPORTED_FORMAT) {
251251
/* not a simple value */
252252
if (object->type == THINGSET_TYPE_GROUP) {
253253
pos = snprintf(buf, size, "null,");

0 commit comments

Comments
 (0)