Commit b454be1
Martin Belanger
python: add nvme.i consistency check and fix violations
Add tools/check-nvme-i-consistency.py, a static analysis script that
verifies nvme.i stays consistent with the accessor annotations in
private.h and private-fabrics.h. It enforces several rules:
Rule 1 (error): !accessors:readonly fields exposed in nvme.i must
be declared %immutable.
Rule 2 (error): fields with auto-generated or bridged accessors
must be in %extend{} so SWIG invokes the getter
instead of accessing the struct member directly.
Rule 3 (error): fields in %extend{} must have a getter bridge
whose target is declared in a public header.
Check 4 (error): bridge target not found in any public header.
Check 5 (error): %immutable declaration for a field that does not
exist in the corresponding C struct.
Check 6 (warning): field has an accessor but is not exposed in nvme.i.
Check 7 (warning): field type in nvme.i differs from private header.
The check is registered as a meson test in libnvme/libnvme/meson.build
inside the 'if want_python' block. It performs pure static analysis and
does not depend on the built SWIG module.
Fix all Rule 2 violations found by the new check by moving the
offending fields into %extend{} blocks (using existing blocks where
possible, creating one for libnvme_ns). Remove stale comments on
cntrltype, dctype, and discovered that incorrectly claimed no getter
method was available.
Signed-off-by: Martin Belanger <[email protected]>
Assisted-by: Claude Sonnet 4.6 <[email protected]>1 parent d391152 commit b454be1
4 files changed
Lines changed: 594 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
80 | 106 | | |
81 | 107 | | |
82 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | 601 | | |
607 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | 636 | | |
641 | 637 | | |
642 | 638 | | |
| |||
665 | 661 | | |
666 | 662 | | |
667 | 663 | | |
| 664 | + | |
| 665 | + | |
668 | 666 | | |
669 | 667 | | |
670 | 668 | | |
671 | 669 | | |
| 670 | + | |
672 | 671 | | |
673 | 672 | | |
674 | 673 | | |
| |||
695 | 694 | | |
696 | 695 | | |
697 | 696 | | |
698 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
| |||
0 commit comments