HomeFreeBSD

Fix compiling with gcc [4.2.1] after r287797 when MK_HESOID == no and

Description

Fix compiling with gcc [4.2.1] after r287797 when MK_HESOID == no and
MK_NIS == no by converting i back to an int, and instead cast the loop
comparison to int

The loop comparison is iterating the len(ns_dtab)-1, because
the last element is the sentinel tuple { NULL, NULL, NULL, }, so when
both HESOID and NIS are off, len(ns_dtab)-1 == 1 - 1 == 0, and the loop
is skipped because the expression is tautologically false

While here, convert (sizeof(x) / sizeof(x[0])) to nitems(x)

Tested with: clang 3.7.0, gcc 4.2.1, and gcc 4.9.4 [*] with MK_NIS={no,yes}

and by running bash -lc 'id -u && id -g && id'
  • gcc 4.9.4 needs another patch in order for the compile to succeed with -Werror with lib/libc/gen/getgrent.c

Reported by: jhibbits

Details

Provenance
ngieAuthored on
Parents
rS289924: MFC r289146:
Branches
Unknown
Tags
Unknown