Skip to content

Wrong values generated of constants defined by #define for a linux header file. #2926

@AnirbanHalder654322

Description

@AnirbanHalder654322

Taken from this https://github.com/torvalds/linux/blob/master/include/uapi/linux/posix_acl.h .

Input C/C++ Header

#define ACL_UNDEFINED_ID	(-1)

/* a_type field in acl_user_posix_entry_t */
#define ACL_TYPE_ACCESS		(0x8000)
#define ACL_TYPE_DEFAULT	(0x4000)

/* e_tag entry in struct posix_acl_entry */
#define ACL_USER_OBJ		(0x01)
#define ACL_USER		(0x02)
#define ACL_GROUP_OBJ		(0x04)
#define ACL_GROUP		(0x08)
#define ACL_MASK		(0x10)
#define ACL_OTHER		(0x20)

/* permissions in the e_perm field */
#define ACL_READ		(0x04)
#define ACL_WRITE		(0x02)
#define ACL_EXECUTE	(0x01)

Bindgen Invocation

$ bindgen input.h -o output.rs

Actual Results

pub const ACL_UNDEFINED_ID: i32 = -1;
pub const ACL_TYPE_ACCESS: u32 = 32768;
pub const ACL_TYPE_DEFAULT: u32 = 16384;
pub const ACL_USER_OBJ: u32 = 1;
pub const ACL_USER: u32 = 2;
pub const ACL_GROUP_OBJ: u32 = 4;
pub const ACL_GROUP: u32 = 8;
pub const ACL_MASK: u32 = 16;
pub const ACL_OTHER: u32 = 32;
pub const ACL_READ: u32 = 4;
pub const ACL_WRITE: u32 = 2;
pub const ACL_EXECUTE: u32 = 1;

Expected Results

The correct parsing and generation of the u32 value, this is plaguing few rust libc functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions