@@ -175,33 +175,28 @@ static void test_lru_sanity0(int map_type, int map_flags)
175
175
BPF_NOEXIST ));
176
176
177
177
/* BPF_NOEXIST means: add new element if it doesn't exist */
178
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == -1
179
- /* key=1 already exists */
180
- && errno == EEXIST );
178
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == - EEXIST );
179
+ /* key=1 already exists */
181
180
182
- assert (bpf_map_update_elem (lru_map_fd , & key , value , -1 ) == -1 &&
183
- errno == EINVAL );
181
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , -1 ) == - EINVAL );
184
182
185
183
/* insert key=2 element */
186
184
187
185
/* check that key=2 is not found */
188
186
key = 2 ;
189
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
190
- errno == ENOENT );
187
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
191
188
192
189
/* BPF_EXIST means: update existing element */
193
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == -1 &&
194
- /* key=2 is not there */
195
- errno == ENOENT );
190
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == - ENOENT );
191
+ /* key=2 is not there */
196
192
197
193
assert (!bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ));
198
194
199
195
/* insert key=3 element */
200
196
201
197
/* check that key=3 is not found */
202
198
key = 3 ;
203
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
204
- errno == ENOENT );
199
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
205
200
206
201
/* check that key=1 can be found and mark the ref bit to
207
202
* stop LRU from removing key=1
@@ -217,8 +212,7 @@ static void test_lru_sanity0(int map_type, int map_flags)
217
212
218
213
/* key=2 has been removed from the LRU */
219
214
key = 2 ;
220
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
221
- errno == ENOENT );
215
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
222
216
223
217
/* lookup elem key=1 and delete it, then check it doesn't exist */
224
218
key = 1 ;
@@ -381,8 +375,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
381
375
end_key = 1 + batch_size ;
382
376
value [0 ] = 4321 ;
383
377
for (key = 1 ; key < end_key ; key ++ ) {
384
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
385
- errno == ENOENT );
378
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
386
379
assert (!bpf_map_update_elem (lru_map_fd , & key , value ,
387
380
BPF_NOEXIST ));
388
381
assert (!bpf_map_lookup_elem_with_ref_bit (lru_map_fd , key , value ));
@@ -562,8 +555,7 @@ static void do_test_lru_sanity5(unsigned long long last_key, int map_fd)
562
555
assert (!bpf_map_lookup_elem_with_ref_bit (map_fd , key , value ));
563
556
564
557
/* Cannot find the last key because it was removed by LRU */
565
- assert (bpf_map_lookup_elem (map_fd , & last_key , value ) == -1 &&
566
- errno == ENOENT );
558
+ assert (bpf_map_lookup_elem (map_fd , & last_key , value ) == - ENOENT );
567
559
}
568
560
569
561
/* Test map with only one element */
@@ -711,30 +703,26 @@ static void test_lru_sanity7(int map_type, int map_flags)
711
703
BPF_NOEXIST ));
712
704
713
705
/* BPF_NOEXIST means: add new element if it doesn't exist */
714
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == -1
715
- /* key=1 already exists */
716
- && errno == EEXIST );
706
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == - EEXIST );
707
+ /* key=1 already exists */
717
708
718
709
/* insert key=2 element */
719
710
720
711
/* check that key=2 is not found */
721
712
key = 2 ;
722
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
723
- errno == ENOENT );
713
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
724
714
725
715
/* BPF_EXIST means: update existing element */
726
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == -1 &&
727
- /* key=2 is not there */
728
- errno == ENOENT );
716
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == - ENOENT );
717
+ /* key=2 is not there */
729
718
730
719
assert (!bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ));
731
720
732
721
/* insert key=3 element */
733
722
734
723
/* check that key=3 is not found */
735
724
key = 3 ;
736
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
737
- errno == ENOENT );
725
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
738
726
739
727
/* check that key=1 can be found and mark the ref bit to
740
728
* stop LRU from removing key=1
@@ -757,8 +745,7 @@ static void test_lru_sanity7(int map_type, int map_flags)
757
745
758
746
/* key=2 has been removed from the LRU */
759
747
key = 2 ;
760
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
761
- errno == ENOENT );
748
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
762
749
763
750
assert (map_equal (lru_map_fd , expected_map_fd ));
764
751
@@ -805,21 +792,18 @@ static void test_lru_sanity8(int map_type, int map_flags)
805
792
assert (!bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ));
806
793
807
794
/* BPF_NOEXIST means: add new element if it doesn't exist */
808
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == -1
809
- /* key=1 already exists */
810
- && errno == EEXIST );
795
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ) == - EEXIST );
796
+ /* key=1 already exists */
811
797
812
798
/* insert key=2 element */
813
799
814
800
/* check that key=2 is not found */
815
801
key = 2 ;
816
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
817
- errno == ENOENT );
802
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
818
803
819
804
/* BPF_EXIST means: update existing element */
820
- assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == -1 &&
821
- /* key=2 is not there */
822
- errno == ENOENT );
805
+ assert (bpf_map_update_elem (lru_map_fd , & key , value , BPF_EXIST ) == - ENOENT );
806
+ /* key=2 is not there */
823
807
824
808
assert (!bpf_map_update_elem (lru_map_fd , & key , value , BPF_NOEXIST ));
825
809
assert (!bpf_map_update_elem (expected_map_fd , & key , value ,
@@ -829,8 +813,7 @@ static void test_lru_sanity8(int map_type, int map_flags)
829
813
830
814
/* check that key=3 is not found */
831
815
key = 3 ;
832
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
833
- errno == ENOENT );
816
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
834
817
835
818
/* check that key=1 can be found and do _not_ mark ref bit.
836
819
* this will be evicted on next update.
@@ -853,8 +836,7 @@ static void test_lru_sanity8(int map_type, int map_flags)
853
836
854
837
/* key=1 has been removed from the LRU */
855
838
key = 1 ;
856
- assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == -1 &&
857
- errno == ENOENT );
839
+ assert (bpf_map_lookup_elem (lru_map_fd , & key , value ) == - ENOENT );
858
840
859
841
assert (map_equal (lru_map_fd , expected_map_fd ));
860
842
0 commit comments