Page MenuHomeFreeBSD

Use NDLT to get number of LDTs
ClosedPublic

Authored by dim on Feb 4 2019, 12:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 29, 7:18 AM
Unknown Object (File)
Wed, Jan 29, 6:51 AM
Unknown Object (File)
Wed, Jan 29, 6:20 AM
Unknown Object (File)
Dec 24 2024, 11:16 PM
Unknown Object (File)
Dec 20 2024, 2:38 PM
Unknown Object (File)
Dec 20 2024, 9:05 AM
Unknown Object (File)
Nov 8 2024, 1:35 AM
Unknown Object (File)
Nov 1 2024, 4:38 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 Not Applicable
Unit
Tests Not Applicable

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.