Commit 2ed81b4
fs: make plain ->i_state access fail to compile
... to make sure all accesses are properly validated.
Merely renaming the var to __i_state still lets the compiler make the
following suggestion:
error: 'struct inode' has no member named 'i_state'; did you mean '__i_state'?
Unfortunately some people will add the __'s and call it a day.
In order to make it harder to mess up in this way, hide it behind a
struct. The resulting error message should be convincing in terms of
checking what to do:
error: invalid operands to binary & (have 'struct inode_state_flags' and 'int')
Of course people determined to do a plain access can still do it, but
nothing can be done for that case.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>1 parent 18c6139 commit 2ed81b4
1 file changed
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
788 | 795 | | |
789 | 796 | | |
790 | 797 | | |
| |||
843 | 850 | | |
844 | 851 | | |
845 | 852 | | |
846 | | - | |
| 853 | + | |
847 | 854 | | |
848 | 855 | | |
849 | 856 | | |
| |||
909 | 916 | | |
910 | 917 | | |
911 | 918 | | |
912 | | - | |
| 919 | + | |
913 | 920 | | |
914 | 921 | | |
915 | 922 | | |
916 | 923 | | |
917 | 924 | | |
918 | | - | |
| 925 | + | |
919 | 926 | | |
920 | 927 | | |
921 | 928 | | |
922 | 929 | | |
923 | 930 | | |
924 | | - | |
| 931 | + | |
925 | 932 | | |
926 | 933 | | |
927 | 934 | | |
| |||
934 | 941 | | |
935 | 942 | | |
936 | 943 | | |
937 | | - | |
| 944 | + | |
938 | 945 | | |
939 | 946 | | |
940 | 947 | | |
| |||
947 | 954 | | |
948 | 955 | | |
949 | 956 | | |
950 | | - | |
| 957 | + | |
951 | 958 | | |
952 | 959 | | |
953 | 960 | | |
| |||
962 | 969 | | |
963 | 970 | | |
964 | 971 | | |
965 | | - | |
| 972 | + | |
966 | 973 | | |
967 | 974 | | |
968 | 975 | | |
| |||
0 commit comments