Skip to content

Commit

Permalink
server/netget.c: get_type(): simplify logging and vars used [networku…
Browse files Browse the repository at this point in the history
…pstools#266]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 23, 2024
1 parent 5776fb2 commit 7fb4afe
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions server/netget.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,17 @@ static void get_type(nut_ctype_t *client, const char *upsname, const char *var)

/* Sanity-check current contents */
if (node->val && *(node->val)) {
char *s = NULL;
double d;
long l;
int ok = 1;
size_t len = strlen(node->val);

errno = 0;
if (!str_to_double_strict(node->val, &d, 10)) {
upsdebugx(3, "%s: UPS[%s] variable %s is a NUMBER but not a double: %s",
upsdebugx(3, "%s: UPS[%s] variable %s is a NUMBER but not (exclusively) a double: %s",
__func__, upsname, var, node->val);
upsdebugx(4, "%s: val=%f len=%" PRIuSIZE " errno=%d *s=%c (0x%02x)",
__func__, d, len, errno, s ? *s : 'z', s ? *s : 255);
upsdebug_with_errno(4, "%s: val=%f len=%" PRIuSIZE,
__func__, d, len);
ok = 0;
}

Expand All @@ -198,10 +197,10 @@ static void get_type(nut_ctype_t *client, const char *upsname, const char *var)
errno = 0;
ok = 1;
if (!str_to_long_strict(node->val, &l, 10)) {
upsdebugx(3, "%s: UPS[%s] variable %s is a NUMBER but not a long int: %s",
upsdebugx(3, "%s: UPS[%s] variable %s is a NUMBER but not (exclusively) a long int: %s",
__func__, upsname, var, node->val);
upsdebugx(4, "%s: val=%ld len=%" PRIuSIZE " errno=%d *s=%c (0x%02x)",
__func__, l, len, errno, s ? *s : '*', s ? *s : 255);
upsdebug_with_errno(4, "%s: val=%ld len=%" PRIuSIZE,
__func__, l, len);
ok = 0;
}
}
Expand Down

0 comments on commit 7fb4afe

Please sign in to comment.