Open Bug 2010563 Opened 10 months ago Updated 10 months ago

Include endian.h for BYTE_ORDER

Categories

(NSS :: Build, defect, P3)

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: prlw1, Unassigned)

Details

Steps to reproduce:

When compiling nss from nss-3.120.tar.gz (3.120 doesn't appear in the bugzilla Version drop down menu), I see

Actual results:

h_page.c: In function 'dbm_get_page':
h_page.c:729:30: error: 'BYTE_ORDER' undeclared (first use in this function)
  729 |         if (hashp->LORDER != BYTE_ORDER) {
      |                              ^~~~~~~~~~
h_page.c:729:30: note: each undeclared identifier is reported only once for each function it appears in
h_page.c: In function 'dbm_put_page':
h_page.c:820:26: error: 'BYTE_ORDER' undeclared (first use in this function)
  820 |     if (hashp->LORDER != BYTE_ORDER) {
      |                          ^~~~~~~~~~

etc

Expected results:

According to POSIX, endian.h is the header file which needs to be included to define BYTE_ORDER.

Looking at nss/lib/dbm/include/mcom_db.h, we see that it is only included for builds on linux., (#if defined(__linux)). I suppose one could add a long list of operating systems to the conditional, but preferably, do your build system equivalent of AC_CHECK_HEADERS([endian.h]), and

#ifdef HAVE_ENDIAN_H
#include <endian.h>
#endif

in nss/lib/dbm/include/mcom_db.h

What platform are you building on?

Severity: -- → S3
Priority: -- → P3

I precisely worded the above report to suggest that that is irrelevant: simply by code inspection, you see that for a POSIX compliant system, endian.h is the header file to include in order to use BYTE_ORDER etc. The way forward is to simply include the correct header. If you want to handle the case in which said header doesn't exist (nowadays unlikely, and you already assume its existence in the linux case), then you can test for its existence first, as per the autoconf philosophy, test for features. (My guess is that with inclusion, you would be able to simplify your #if operating_system_name forest, but that would probably require testing - anyone have an AIX system handy?)

You need to log in before you can comment on or make changes to this bug.