Page MenuHomeFreeBSD

Use NDLT to get number of LDTs
ClosedPublic

Authored by dim on Feb 4 2019, 12:25 PM.
Tags
None
Referenced Files
F81593647: D19074.diff
Thu, Apr 18, 4:11 PM
Unknown Object (File)
Tue, Apr 16, 1:12 PM
Unknown Object (File)
Fri, Apr 12, 7:39 AM
Unknown Object (File)
Jan 11 2024, 10:59 PM
Unknown Object (File)
Dec 22 2023, 10:57 PM
Unknown Object (File)
Jul 19 2023, 6:34 PM
Unknown Object (File)
Jul 2 2023, 1:24 AM
Unknown Object (File)
Jul 2 2023, 1:24 AM
Subscribers

Details

Summary

Compiling a GENERIC kernel for i386 with clang 8.0 results in the
following warning:

/usr/src/sys/i386/i386/sys_machdep.c:542:40: error: 'sizeof ((ldt))' will return the size of the pointer, not the array itself [-Werror,-Wsizeof-pointer-div]
        nldt = pldt != NULL ? pldt->ldt_len : nitems(ldt);
                                              ^~~~~~~~~~~
/usr/src/sys/sys/param.h:299:32: note: expanded from macro 'nitems'
#define nitems(x)       (sizeof((x)) / sizeof((x)[0]))
                         ~~~~~~~~~~~ ^

Indeed, 'ldt' is declared as 'union descriptor *', so nitems() is not
the right way to determine the number of LDTs. Instead, the NLDT define
from sys/x86/include/segments.h should be used.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22339
Build 21518: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Feb 4 2019, 12:58 PM
This revision was automatically updated to reflect the committed changes.