Skip to content

Commit

Permalink
Merge pull request #2131 from jimklimov/issue-1941
Browse files Browse the repository at this point in the history
drivers/apcsmart-old.c: do_capabilities(): revert to behavior like in…
  • Loading branch information
jimklimov authored Oct 25, 2023
2 parents dc368ad + d04dc76 commit 41dd671
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
23 changes: 14 additions & 9 deletions drivers/apcsmart-old.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "apcsmart-old.h"
#include "nut_stdint.h"

#define DRIVER_NAME "APC Smart protocol driver"
#define DRIVER_VERSION "2.31"
#define DRIVER_NAME "APC Smart protocol driver (old)"
#define DRIVER_VERSION "2.32"

static upsdrv_info_t table_info = {
"APC command table",
Expand Down Expand Up @@ -395,15 +395,20 @@ static void do_capabilities(void)
__func__, (ptr[2] - 48), (ptr[3] - 48),
cmd, loc);

/* just ignore it as we did for ages (the
* rest of loop cycle would be no-op anyway)
/* just ignore it as we did for ages see e.g. v2.7.4
* (note the next loop cycle was and still would be
* no-op anyway, if "nument <= 0").
*/
ptr = entptr;
continue;
}
nument = 0;
entlen = 0;

nument = (size_t)ptr[2] - 48;
entlen = (size_t)ptr[3] - 48;
/* NOT a full skip: Gotta handle "vt" to act like before */
/*ptr = entptr;*/
/*continue;*/
} else {
nument = (size_t)ptr[2] - 48;
entlen = (size_t)ptr[3] - 48;
}

vt = vartab_lookup_char(cmd);
valid = vt && ((loc == upsloc) || (loc == '4'));
Expand Down
21 changes: 13 additions & 8 deletions drivers/apcsmart.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "apcsmart_tabs.h"

#define DRIVER_NAME "APC Smart protocol driver"
#define DRIVER_VERSION "3.31"
#define DRIVER_VERSION "3.32"

#ifdef WIN32
# ifndef ECANCELED
Expand Down Expand Up @@ -1040,15 +1040,20 @@ static void apc_getcaps(int qco)
__func__, (ptr[2] - 48), (ptr[3] - 48),
cmd, loc);

/* just ignore it as we did for ages (the
* rest of loop cycle would be no-op anyway)
/* just ignore it as we did for ages see e.g. v2.7.4
* (note the next loop cycle was and still would be
* no-op anyway, if "nument <= 0").
*/
ptr = entptr;
continue;
}
nument = 0;
entlen = 0;

nument = (size_t)ptr[2] - 48;
entlen = (size_t)ptr[3] - 48;
/* NOT a full skip: Gotta handle "vt" to act like before */
/*ptr = entptr;*/
/*continue;*/
} else {
nument = (size_t)ptr[2] - 48;
entlen = (size_t)ptr[3] - 48;
}

vt = vt_lookup_char(cmd);
valid = vt && ((loc == upsloc) || (loc == '4')) && !(vt->flags & APC_PACK);
Expand Down

0 comments on commit 41dd671

Please sign in to comment.