[LU-4674] __{LITTLE,BIG}_ENDIAN macros used incorrectly Created: 26/Feb/14  Updated: 26/Mar/14  Resolved: 26/Mar/14

Status: Closed
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.6.0
Fix Version/s: Lustre 2.6.0

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Fixed Votes: 0
Labels: cleanup, endianness, patch

Severity: 3
Rank (Obsolete): 12829

 Description   

There are a few places in the source where __

{LITTLE,BIG}

_ENDIAN is tested with #ifdef:

static __inline__ int ext2_set_bit(int nr, void *addr)
{
#ifdef __BIG_ENDIAN
        return set_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
#else
        return set_bit(nr, addr);
#endif
}
const struct dt_rec *osd_quota_pack(struct osd_object *obj,
                                    const struct dt_rec *rec,
                                    union lquota_rec *quota_rec)
{
#ifdef __BIG_ENDIAN
        struct iam_descr        *descr;

        LASSERT(obj->oo_dir != NULL);
        descr = obj->oo_dir->od_container.ic_descr;

        memcpy(quota_rec, rec, descr->id_rec_size);

        osd_quota_swab((char *)quota_rec, descr->id_rec_size);
        return (const struct dt_rec *)quota_rec;
#else
        return rec;
#endif
}

In userspace, including endian.h always defines __BIG_ENDIAN to 4321. The correct test is '#if __BYTE_ORDER == __BIG_ENDIAN'. All uses of these macros should be audited.



 Comments   
Comment by Swapnil Pimpale (Inactive) [ 13/Mar/14 ]

patch: http://review.whamcloud.com/#/c/9641/

Comment by John Hammond [ 26/Mar/14 ]

Patch landed to master. Thanks Swapnil.

Generated at Sat Feb 10 01:44:51 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.