Fix optional params always using index 0 in ptools_backend_call

Loop variable j was declared inside the loop and reset to 0 on every
iteration. All branches had early continue, so j++ never executed.

Change j to i - reqParCnt to correctly index into optionalParams array.
Also fix paramtype check to use j instead of i.

Fixes GH #215
This commit is contained in:
Levi Neely 2026-03-03 12:28:22 +01:00
parent 8d203a4f97
commit 22eeb28e43
1 changed files with 4 additions and 6 deletions

View File

@ -258,30 +258,28 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
// Add optional parameters to the structure
for (i = reqParCnt; i < totalParCnt; i++) {
int j = 0;
int j = i - reqParCnt;
if (optionalParams->Params[i].paramtype == 0) {
if (optionalParams->Params[j].paramtype == 0) {
localParams[i] = (binparam)PAPI_STR(optionalParams->Params[j].paramname,
optionalParams->Params[j].str);
continue;
}
if (optionalParams->Params[i].paramtype == 1) {
if (optionalParams->Params[j].paramtype == 1) {
localParams[i] = (binparam)PAPI_NUM(optionalParams->Params[j].paramname,
optionalParams->Params[j].num);
continue;
}
if (optionalParams->Params[i].paramtype == 2) {
if (optionalParams->Params[j].paramtype == 2) {
localParams[i] = (binparam)PAPI_BOOL(optionalParams->Params[j].paramname,
optionalParams->Params[j].num);
continue;
}
j++;
}
for (i = 0; i < totalParCnt; i++) {