[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #57565] _IO, _IOR, _IOW macros expect sizeof() result
From: |
Victor Brzeski |
Subject: |
[lwip-devel] [bug #57565] _IO, _IOR, _IOW macros expect sizeof() result to be long type - not always true |
Date: |
Thu, 9 Jan 2020 11:01:52 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36 |
URL:
<https://savannah.nongnu.org/bugs/?57565>
Summary: _IO, _IOR, _IOW macros expect sizeof() result to be
long type - not always true
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: vbrzeski
Submitted on: Thu 09 Jan 2020 04:01:51 PM UTC
Category: sockets/netconn
Severity: 3 - Normal
Item Group: Change Request
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: git head
_______________________________________________________
Details:
Hello,
The way the ioctls are designed are to assume the result of sizeof() is a
long, where in my case it is not. The code below shows this:
#define _IO(x,y) ((long)(IOC_VOID|((x)<<8)|(y)))
#define _IOR(x,y,t)
((long)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
#define _IOW(x,y,t)
((long)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
I had this issue very early in the project and fixed it by simply casting the
sizeof() intrinsic to a long.
#define _IO(x, y) ((long)(IOC_VOID | ((x) << 8) | (y)))
#define _IOR(x, y, t) ((long)(IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK) <<
16) | ((x) << 8) | (y)))
#define _IOW(x, y, t) ((long)(IOC_IN | (((long)sizeof(t) & IOCPARM_MASK) <<
16) | ((x) << 8) | (y)))
This should be adequate to fix my 16-bit problem, and shouldn't invoke any
performance penalties as sizeof() resolves compile-time.
Kind regards,
Victor B.
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?57565>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
- [lwip-devel] [bug #57565] _IO, _IOR, _IOW macros expect sizeof() result to be long type - not always true,
Victor Brzeski <=