View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001944 | 1003.1(2024)/Issue8 | System Interfaces | public | 2025-09-10 23:48 | 2025-09-10 23:48 |
Reporter | joelsherrill | Assigned To | |||
Priority | normal | Severity | Comment | Type | Clarification Requested |
Status | New | Resolution | Open | ||
Name | Joel Sherrill | ||||
Organization | RTEMS Project | ||||
User Reference | |||||
Section | C243.pdf | ||||
Page Number | p. 1553 | ||||
Line Number | 52176 | ||||
Interp Status | |||||
Final Accepted Text | |||||
Summary | 0001944: posix_devctl() uses int for command where some ioctl() implementations use larger type | ||||
Description | The posix_devctl() function is intended to provide a type safe alternative to ioctl(). Unfortunately, it uses int for dcmd which is not necessarily large enough to contain the "op/dcmd" value. Per the Linux man page https://man7.org/linux/man-pages/man2/ioctl.2.html, ioctl() commonly has one of two signatures: int ioctl(int fd, unsigned long op, ...); /* glibc, BSD */ int ioctl(int fd, int op, ...); /* musl, other UNIX */ FreeBSD assumes the "op" is at least 32 bits in size and that the most significant bit can be set. The macros generating "op" values end up generating 32-bit signed numbers which causes compiler warnings when using those computed values with posix_devctl(). Per the Linux ioct.h man page cited above, the "op" is constructed similarly and can explicitly set the most significant bit in the 32-bit int. This is the same problem. The rationale provided with the posix_devctl() discusses why direction was not explicitly mentioned in the "dcmd" encoding. However, it misses that the existing practices needed an unsigned value. Note: The BSD and Linux op encoding schemes do not work at all on targets where int is 16 bits. | ||||
Desired Action | There are two possible alternative resolutions. One is to switch to unsigned long per glib and BSD. The other is to go to a special type which the implementer can define such as ioctl_command_t. Historically 32-bits have been enough but using a new type for "dcmd" allows an implementation to use a width that does not correspond to int or long type if that provides value. | ||||
Tags | No tags attached. |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-09-10 23:48 | joelsherrill | New Issue |