Skip to content

Commit ed12d9c

Browse files
committed
systemlib: Fix param used counting
1 parent 8e4c78c commit ed12d9c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/modules/systemlib/param/param.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ param_for_used_index(unsigned index)
287287
/* we found the right used count,
288288
* return the param value
289289
*/
290-
if (i == count) {
290+
if (index == count) {
291291
return (param_t)i;
292292
}
293293

@@ -303,16 +303,19 @@ param_for_used_index(unsigned index)
303303
int
304304
param_get_index(param_t param)
305305
{
306-
if (handle_in_range(param))
306+
if (handle_in_range(param)) {
307307
return (unsigned)param;
308+
}
308309

309310
return -1;
310311
}
311312

312313
int
313314
param_get_used_index(param_t param)
314315
{
315-
if (!handle_in_range(param)) {
316+
int param_storage_index = param_get_index(param);
317+
318+
if (param_storage_index < 0) {
316319
return -1;
317320
}
318321

@@ -322,12 +325,17 @@ param_get_used_index(param_t param)
322325
for (unsigned i = 0; i < (unsigned)param + 1; i++) {
323326
for (unsigned j = 0; j < 8; j++) {
324327
if (param_changed_storage[i] & (1 << j)) {
328+
329+
if (param_storage_index == i) {
330+
return count;
331+
}
332+
325333
count++;
326334
}
327335
}
328336
}
329337

330-
return count;
338+
return -1;
331339
}
332340

333341
const char *

0 commit comments

Comments
 (0)