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)
Nov 8 2024, 1:35 AM
Unknown Object (File)
Nov 1 2024, 4:38 AM
Unknown Object (File)
Oct 12 2024, 3:02 PM
Unknown Object (File)
Sep 30 2024, 11:30 PM
Unknown Object (File)
Sep 26 2024, 8:01 AM
Unknown Object (File)
Sep 22 2024, 5:24 PM
Unknown Object (File)
Sep 4 2024, 5:34 AM
Unknown Object (File)
Aug 31 2024, 7: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 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.