| Summary: | Clang prints bogus warning: incompatible pointer types passing 'struct kinfo_proc *' to parameter of type 'struct kinfo_proc *' [-Wincompatible-pointer-types] | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Yuri Victorovich <yuri> | ||||
| Component: | misc | Assignee: | Brooks Davis <brooks> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | CC: | brooks | ||||
| Priority: | --- | ||||||
| Version: | 13.1-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
The warning is weird, but in the current state of things sys/user.h needs to be included before libprocstat.h for struct kinfo_proc to be declared before things that use it are declared. I think the issue is that the implicit declaration shadows the real one and conflicts. I've fixed this in https://cgit.freebsd.org/src/commit/?id=a28f83353243e2298b5f89c0dd6705dfcbda77ea and have checked locally that it eliminates that warning. A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=569bfb42951aaa65b9884a0a7c2f04cd91b1862d commit 569bfb42951aaa65b9884a0a7c2f04cd91b1862d Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2022-08-26 22:20:32 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2022-08-31 22:38:15 +0000 libprocstat: forward declare struct kinfo_proc This allows libprocstat.h to be included without sys/user.h as documented in the manpage. PR: 266146 (cherry picked from commit a28f83353243e2298b5f89c0dd6705dfcbda77ea) lib/libprocstat/libprocstat.h | 1 + 1 file changed, 1 insertion(+) A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f4036d3241cf4e1f78cff77aaaf05e962ebaf46e commit f4036d3241cf4e1f78cff77aaaf05e962ebaf46e Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2022-08-26 22:20:32 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2022-08-31 22:55:52 +0000 libprocstat: forward declare struct kinfo_proc This allows libprocstat.h to be included without sys/user.h as documented in the manpage. PR: 266146 (cherry picked from commit a28f83353243e2298b5f89c0dd6705dfcbda77ea) lib/libprocstat/libprocstat.h | 1 + 1 file changed, 1 insertion(+) Fixed as much as practical. To get a useful error in these cases use -Wvisibility which gives warning like:
/usr/include/libprocstat.h:181:59: error: declaration of 'struct kinfo_proc' will not be visible outside of this function [-Werror,-Wvisibility]
void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
^
/usr/include/libprocstat.h:189:12: error: declaration of 'struct kinfo_proc' will not be visible outside of this function [-Werror,-Wvisibility]
struct kinfo_proc *kp, int mmapped);
^
2 errors generated.
|
Created attachment 236273 [details] clang-issue.c Both types are identical - how come they are incompatible? clang-14.0.5