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)
Fri, Oct 10, 12:22 PM
Unknown Object (File)
Mon, Sep 29, 12:37 PM
Unknown Object (File)
Sun, Sep 28, 4:39 AM
Unknown Object (File)
Sat, Sep 27, 4:53 PM
Unknown Object (File)
Sat, Sep 27, 3:17 PM
Unknown Object (File)
Sat, Sep 27, 11:50 AM
Unknown Object (File)
Sep 13 2025, 8:57 AM
Unknown Object (File)
Jul 19 2025, 11:44 PM
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.