[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202309120150.uX27LKII-lkp@intel.com>
Date: Tue, 12 Sep 2023 01:57:42 +0800
From: kernel test robot <lkp@...el.com>
To: Andrii Nakryiko <andrii@...nel.org>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>
Subject: kernel/bpf/bpf_iter.c:789:17: warning: no previous declaration for
'bpf_iter_num_new'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
commit: 6018e1f407cccf39b804d1f75ad4de7be4e6cc45 bpf: implement numbers iterator
date: 6 months ago
config: x86_64-randconfig-002-20230910 (https://download.01.org/0day-ci/archive/20230912/202309120150.uX27LKII-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230912/202309120150.uX27LKII-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309120150.uX27LKII-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/bpf/bpf_iter.c:789:17: warning: no previous declaration for 'bpf_iter_num_new' [-Wmissing-declarations]
__bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end)
^~~~~~~~~~~~~~~~
>> kernel/bpf/bpf_iter.c:822:18: warning: no previous declaration for 'bpf_iter_num_next' [-Wmissing-declarations]
__bpf_kfunc int *bpf_iter_num_next(struct bpf_iter_num* it)
^~~~~~~~~~~~~~~~~
>> kernel/bpf/bpf_iter.c:841:18: warning: no previous declaration for 'bpf_iter_num_destroy' [-Wmissing-declarations]
__bpf_kfunc void bpf_iter_num_destroy(struct bpf_iter_num *it)
^~~~~~~~~~~~~~~~~~~~
vim +/bpf_iter_num_new +789 kernel/bpf/bpf_iter.c
784
785 __diag_push();
786 __diag_ignore_all("-Wmissing-prototypes",
787 "Global functions as their definitions will be in vmlinux BTF");
788
> 789 __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end)
790 {
791 struct bpf_iter_num_kern *s = (void *)it;
792
793 BUILD_BUG_ON(sizeof(struct bpf_iter_num_kern) != sizeof(struct bpf_iter_num));
794 BUILD_BUG_ON(__alignof__(struct bpf_iter_num_kern) != __alignof__(struct bpf_iter_num));
795
796 BTF_TYPE_EMIT(struct btf_iter_num);
797
798 /* start == end is legit, it's an empty range and we'll just get NULL
799 * on first (and any subsequent) bpf_iter_num_next() call
800 */
801 if (start > end) {
802 s->cur = s->end = 0;
803 return -EINVAL;
804 }
805
806 /* avoid overflows, e.g., if start == INT_MIN and end == INT_MAX */
807 if ((s64)end - (s64)start > BPF_MAX_LOOPS) {
808 s->cur = s->end = 0;
809 return -E2BIG;
810 }
811
812 /* user will call bpf_iter_num_next() first,
813 * which will set s->cur to exactly start value;
814 * underflow shouldn't matter
815 */
816 s->cur = start - 1;
817 s->end = end;
818
819 return 0;
820 }
821
> 822 __bpf_kfunc int *bpf_iter_num_next(struct bpf_iter_num* it)
823 {
824 struct bpf_iter_num_kern *s = (void *)it;
825
826 /* check failed initialization or if we are done (same behavior);
827 * need to be careful about overflow, so convert to s64 for checks,
828 * e.g., if s->cur == s->end == INT_MAX, we can't just do
829 * s->cur + 1 >= s->end
830 */
831 if ((s64)(s->cur + 1) >= s->end) {
832 s->cur = s->end = 0;
833 return NULL;
834 }
835
836 s->cur++;
837
838 return &s->cur;
839 }
840
> 841 __bpf_kfunc void bpf_iter_num_destroy(struct bpf_iter_num *it)
842 {
843 struct bpf_iter_num_kern *s = (void *)it;
844
845 s->cur = s->end = 0;
846 }
847
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists