Skip to content

Commit

Permalink
Rename old_dzg_meter -> dzg_fix_negative_values
Browse files Browse the repository at this point in the history
Let's use a more speaking name for what this workaround actually does,
considering that the option is now part of the public API.
  • Loading branch information
tanuva committed Oct 4, 2023
1 parent 2f30897 commit 60accef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/sml_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
exit(0); // exit here
break;
case 'd':
workarounds.old_dzg_meter = 1;
workarounds.dzg_fix_negative_values = 1;
break;
case 's':
sflag = true;
Expand Down
2 changes: 1 addition & 1 deletion sml/include/sml/sml_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ typedef struct {
* Note that this will NOT work if a meter outputs negative
* values compressed as well - but mine doesn't.
*/
unsigned int old_dzg_meter : 1;
unsigned int dzg_fix_negative_values : 1;
} sml_workarounds;

#ifdef __cplusplus
Expand Down
3 changes: 2 additions & 1 deletion sml/src/sml_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ sml_list *sml_list_entry_parse(sml_buffer *buf, const sml_workarounds *workaroun
if (sml_buf_has_errors(buf))
goto error;

if (workarounds->old_dzg_meter && l->obj_name && l->obj_name->len == sizeof(dzg_power_name) &&
if (workarounds->dzg_fix_negative_values && l->obj_name &&
l->obj_name->len == sizeof(dzg_power_name) &&
memcmp(l->obj_name->str, dzg_power_name, sizeof(dzg_power_name)) == 0 && l->value &&
(value_len_more == 1 || value_len_more == 2 || value_len_more == 3)) {
l->value->type &= ~SML_TYPE_FIELD;
Expand Down

0 comments on commit 60accef

Please sign in to comment.