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-25 15:28 | 
| Reporter | joelsherrill | Assigned To | |||
| Priority | normal | Severity | Comment | Type | Clarification Requested | 
| Status | Resolved | Resolution | Accepted As Marked | ||
| Name | Joel Sherrill | ||||
| Organization | RTEMS Project | ||||
| User Reference | |||||
| Section | C243.pdf | ||||
| Page Number | p. 1553 | ||||
| Line Number | 52176 | ||||
| Interp Status | --- | ||||
| Final Accepted Text | 0001944:0007278 | ||||
| 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 | issue9 | ||||
|  | After page 234 line 8250 section <devctl.h>, add: The <devctl.h> header shall define the devctl_cmd_t type as an integer type with a width greater than or equal to the width of type int. On page 1557 line 52177 section posix_devctl(), change: int dcmd to: devctl_cmd_t dcmd | 
| Date Modified | Username | Field | Change | 
|---|---|---|---|
| 2025-09-10 23:48 | joelsherrill | New Issue | |
| 2025-09-25 15:26 | geoffclare | Note Added: 0007278 | |
| 2025-09-25 15:27 | geoffclare | Status | New => Resolved | 
| 2025-09-25 15:27 | geoffclare | Resolution | Open => Accepted As Marked | 
| 2025-09-25 15:27 | geoffclare | Interp Status | => --- | 
| 2025-09-25 15:27 | geoffclare | Final Accepted Text | => 0001944:0007278 | 
| 2025-09-25 15:28 | geoffclare | Tag Attached: issue9 | 
