Commit f68d60e
committed
Refactor: libcib: cib_perform_op() takes only one CIB argument
The new approach is to set the caller's result_cib pointer to the
current CIB instead of to NULL. Then pass &result_cib to
cib_perform_op() as its "cib" argument.
* If it doesn't make a copy, then it operates on the original CIB
directly and then assign the original CIB to working_cib -- just as
we were already doing.
* If it does make a copy, then it's copying the original CIB, just as we
were already doing.
* If it makes *cib point somewhere else at the end (in the "done"
section), then that changes the value of the caller's result_cib, but
it DOES NOT change the value of caller's current CIB pointer (the_cib
in pacemaker-based or private->cib_xml in cib_file.c). So the caller
still has a reference to the original CIB.
The logic is arguably a bit more complicated, but previously we had five
CIB pointers (current_cib, result_cib, working_cib, old_versions, top)
in cib_perform_op(). Now we only have to deal with four. That feels more
manageable and thus worth it IMO.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>1 parent 8e3d81b commit f68d60e
4 files changed
Lines changed: 25 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
566 | 567 | | |
567 | | - | |
| 568 | + | |
568 | 569 | | |
569 | 570 | | |
570 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
| 199 | + | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
172 | 173 | | |
173 | | - | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
| 468 | + | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
493 | | - | |
| 492 | + | |
494 | 493 | | |
495 | 494 | | |
496 | 495 | | |
| |||
500 | 499 | | |
501 | 500 | | |
502 | 501 | | |
503 | | - | |
| 502 | + | |
504 | 503 | | |
505 | 504 | | |
506 | 505 | | |
507 | 506 | | |
508 | 507 | | |
509 | 508 | | |
510 | 509 | | |
511 | | - | |
512 | | - | |
| 510 | + | |
| 511 | + | |
513 | 512 | | |
514 | 513 | | |
515 | | - | |
516 | | - | |
| 514 | + | |
| 515 | + | |
517 | 516 | | |
518 | | - | |
| 517 | + | |
519 | 518 | | |
520 | 519 | | |
521 | | - | |
| 520 | + | |
522 | 521 | | |
523 | | - | |
524 | | - | |
525 | | - | |
| 522 | + | |
| 523 | + | |
526 | 524 | | |
527 | | - | |
| 525 | + | |
528 | 526 | | |
529 | 527 | | |
530 | | - | |
531 | | - | |
| 528 | + | |
| 529 | + | |
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
535 | | - | |
| 533 | + | |
536 | 534 | | |
537 | 535 | | |
538 | 536 | | |
| |||
615 | 613 | | |
616 | 614 | | |
617 | 615 | | |
618 | | - | |
| 616 | + | |
619 | 617 | | |
620 | 618 | | |
621 | 619 | | |
622 | 620 | | |
623 | 621 | | |
624 | | - | |
| 622 | + | |
625 | 623 | | |
626 | | - | |
| 624 | + | |
627 | 625 | | |
628 | 626 | | |
629 | 627 | | |
| |||
0 commit comments