Skip to content

Commit

Permalink
Undo some Watcom warnings fixed in:
Browse files Browse the repository at this point in the history
  7704a1e

This caused a lot of warnings from gcc + clang-cl.
Hence revert and use a '(long)' cast for Watcom 16-bit
target. But is it '__I86__' and/or '_M_I86' for Watcom 16-bit?
  • Loading branch information
gvanem committed Mar 27, 2024
1 parent 4b01f1a commit e1accb2
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 74 deletions.
27 changes: 19 additions & 8 deletions inc/sys/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,32 @@
* word. The high 2 bits of the upper word are used
* to encode the in/out status of the parameter; for now
* we restrict parameters to at most 128 bytes.
*
* Watcom 16-bit targets (small/large) need special handling
* to avoid warnings like:
* ioctl.c(99): Warning! W135: Shift amount too large
*
* Hence use a '(long)' cast in several places below.
*/
#if defined(__WATCOMC__) && defined(__I86__)
#define W32_IOCTL_CAST(val) ((long)(val))
#else
#define W32_IOCTL_CAST(val) val
#endif

#define IOCPARM_MASK (long) 0x7f /* parameters must be < 128 bytes */
#define IOCPARM_MASK W32_IOCTL_CAST (0x7f) /* parameters must be < 128 bytes */

#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
#define IOCBASECMD(x) ((x) & ~IOCPARM_MASK)
#define IOCGROUP(x) (((x) >> 8) & 0xff)

#define IOCPARM_MAX (long) 4096 /* max size of ioctl */
#define IOC_VOID (long) 0x20000000 /* no parameters */
#define IOC_OUT (long) 0x40000000 /* copy out parameters */
#define IOC_IN (long) 0x80000000 /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT) /* 0x20000000 distinguishes new &
old ioctl's */
#define IOC_DIRMASK (long) 0xe0000000 /* mask for IN/OUT/VOID */
#define IOCPARM_MAX W32_IOCTL_CAST (4096) /* max size of ioctl */
#define IOC_VOID W32_IOCTL_CAST (0x20000000) /* no parameters */
#define IOC_OUT W32_IOCTL_CAST (0x40000000) /* copy out parameters */
#define IOC_IN W32_IOCTL_CAST (0x80000000) /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT) /* 0x20000000 distinguishes new &
old ioctl's */
#define IOC_DIRMASK W32_IOCTL_CAST (0xe0000000) /* mask for IN/OUT/VOID */

#define _IO(x,y) (IOC_VOID|(x<<8)|y)
#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
Expand Down
132 changes: 66 additions & 66 deletions src/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int file_ioctrl (Socket *socket, long cmd, void *argp)
{
int len;

switch (cmd)
switch ((DWORD)cmd)
{
case FIONREAD:
VERIFY_RW (argp, sizeof(u_long));
Expand Down Expand Up @@ -280,7 +280,7 @@ static int iface_ioctrl (Socket *socket, long cmd, void *argp)

VERIFY_RW (argp, sizeof(*ifr));

switch (cmd)
switch ((DWORD)cmd)
{
case SIOCSARP:
case SIOCGARP:
Expand Down Expand Up @@ -514,7 +514,7 @@ static int iface_ioctrl (Socket *socket, long cmd, void *argp)
*/
static int waterm_ioctrl (Socket *socket, long cmd, void *argp)
{
switch (cmd)
switch ((DWORD)cmd)
{
case SIOCSHIWAT:
/** \todo set high watermark */
Expand Down Expand Up @@ -556,7 +556,7 @@ static int arp_ioctrl (Socket *socket, long cmd, void *argp)
eth_address *eth;
DWORD ip;

switch (cmd)
switch ((DWORD)cmd)
{
case SIOCSARP: /* add given IP/MAC-addr pair to ARP cache */
ip = intel (*(DWORD*)arp->arp_pa.sa_data);
Expand Down Expand Up @@ -611,53 +611,53 @@ static int arp_ioctrl (Socket *socket, long cmd, void *argp)
*/
#if defined(USE_DEBUG)
static const struct search_list commands[] = {
{ (DWORD) FIOCLEX, "FIOCLEX" },
{ (DWORD) FIONCLEX, "FIONCLEX" },
{ (DWORD) FIONREAD, "FIONREAD" },
{ (DWORD) FIONBIO, "FIONBIO" },
{ (DWORD) FIOASYNC, "FIOASYNC" },
{ (DWORD) FIOSETOWN, "FIOSETOWN" },
{ (DWORD) FIOGETOWN, "FIOGETOWN" },
{ (DWORD) SIOCSPGRP, "SIOCSPGRP" },
{ (DWORD) SIOCGPGRP, "SIOCGPGRP" },
{ (DWORD) SIOCADDRT, "SIOCADDRT" },
{ (DWORD) SIOCDELRT, "SIOCDELRT" },
{ (DWORD) SIOCSIFADDR, "SIOCSIFADDR" },
{ (DWORD) OSIOCGIFADDR, "OSIOCGIFADDR" },
{ (DWORD) SIOCGIFADDR, "SIOCGIFADDR" },
{ (DWORD) SIOCSIFDSTADDR, "SIOCSIFDSTADDR" },
{ (DWORD) OSIOCGIFDSTADDR, "OSIOCGIFDSTADDR" },
{ (DWORD) SIOCGIFDSTADDR, "SIOCGIFDSTADDR" },
{ (DWORD) SIOCSIFFLAGS, "SIOCSIFFLAGS" },
{ (DWORD) SIOCGIFFLAGS, "SIOCGIFFLAGS" },
{ (DWORD) OSIOCGIFBRDADDR, "OSIOCGIFBRDADDR" },
{ (DWORD) SIOCGIFBRDADDR, "SIOCGIFBRDADDR" },
{ (DWORD) SIOCSIFBRDADDR, "SIOCSIFBRDADDR" },
{ (DWORD) OSIOCGIFCONF, "OSIOCGIFCONF" },
{ (DWORD) SIOCGIFCONF, "SIOCGIFCONF" },
{ (DWORD) OSIOCGIFNETMASK, "OSIOCGIFNETMASK" },
{ (DWORD) SIOCGIFNETMASK, "SIOCGIFNETMASK" },
{ (DWORD) SIOCSIFNETMASK, "SIOCSIFNETMASK" },
{ (DWORD) SIOCGIFMETRIC, "SIOCGIFMETRIC" },
{ (DWORD) SIOCSIFMETRIC, "SIOCSIFMETRIC" },
{ (DWORD) SIOCDIFADDR, "SIOCDIFADDR" },
{ (DWORD) SIOCAIFADDR, "SIOCAIFADDR" },
{ (DWORD) SIOCGIFMTU, "SIOCGIFMTU" },
{ (DWORD) SIOCSARP, "SIOCSARP" },
{ (DWORD) OSIOCGARP, "OSIOCGARP" },
{ (DWORD) SIOCGARP, "SIOCGARP" },
{ (DWORD) SIOCDARP, "SIOCDARP" },
{ (DWORD) SIOCSHIWAT, "SIOCSHIWAT" },
{ (DWORD) SIOCGHIWAT, "SIOCGHIWAT" },
{ (DWORD) SIOCSLOWAT, "SIOCSLOWAT" },
{ (DWORD) SIOCGLOWAT, "SIOCGLOWAT" },
{ (DWORD) SIOCATMARK, "SIOCATMARK" },
{ (DWORD) SIOCGIFHWADDR, "SIOCGIFHWADDR" }
{ FIOCLEX, "FIOCLEX" },
{ FIONCLEX, "FIONCLEX" },
{ FIONREAD, "FIONREAD" },
{ FIONBIO, "FIONBIO" },
{ FIOASYNC, "FIOASYNC" },
{ FIOSETOWN, "FIOSETOWN" },
{ FIOGETOWN, "FIOGETOWN" },
{ SIOCSPGRP, "SIOCSPGRP" },
{ SIOCGPGRP, "SIOCGPGRP" },
{ SIOCADDRT, "SIOCADDRT" },
{ SIOCDELRT, "SIOCDELRT" },
{ SIOCSIFADDR, "SIOCSIFADDR" },
{ OSIOCGIFADDR, "OSIOCGIFADDR" },
{ SIOCGIFADDR, "SIOCGIFADDR" },
{ SIOCSIFDSTADDR, "SIOCSIFDSTADDR" },
{ OSIOCGIFDSTADDR, "OSIOCGIFDSTADDR" },
{ SIOCGIFDSTADDR, "SIOCGIFDSTADDR" },
{ SIOCSIFFLAGS, "SIOCSIFFLAGS" },
{ SIOCGIFFLAGS, "SIOCGIFFLAGS" },
{ OSIOCGIFBRDADDR, "OSIOCGIFBRDADDR" },
{ SIOCGIFBRDADDR, "SIOCGIFBRDADDR" },
{ SIOCSIFBRDADDR, "SIOCSIFBRDADDR" },
{ OSIOCGIFCONF, "OSIOCGIFCONF" },
{ SIOCGIFCONF, "SIOCGIFCONF" },
{ OSIOCGIFNETMASK, "OSIOCGIFNETMASK" },
{ SIOCGIFNETMASK, "SIOCGIFNETMASK" },
{ SIOCSIFNETMASK, "SIOCSIFNETMASK" },
{ SIOCGIFMETRIC, "SIOCGIFMETRIC" },
{ SIOCSIFMETRIC, "SIOCSIFMETRIC" },
{ SIOCDIFADDR, "SIOCDIFADDR" },
{ SIOCAIFADDR, "SIOCAIFADDR" },
{ SIOCGIFMTU, "SIOCGIFMTU" },
{ SIOCSARP, "SIOCSARP" },
{ OSIOCGARP, "OSIOCGARP" },
{ SIOCGARP, "SIOCGARP" },
{ SIOCDARP, "SIOCDARP" },
{ SIOCSHIWAT, "SIOCSHIWAT" },
{ SIOCGHIWAT, "SIOCGHIWAT" },
{ SIOCSLOWAT, "SIOCSLOWAT" },
{ SIOCGLOWAT, "SIOCGLOWAT" },
{ SIOCATMARK, "SIOCATMARK" },
{ SIOCGIFHWADDR, "SIOCGIFHWADDR" }
};

static const char *get_ioctl_cmd (long cmd)
{
static char buf[50];
static char buf [50];

switch (IOCGROUP(cmd))
{
Expand Down Expand Up @@ -706,7 +706,7 @@ void __assert_fail (unsigned line)

const char *eth_addr_string (struct ether_addr *eth)
{
static char buf[20];
static char buf [20];

sprintf (buf, "%02X:%02X:%02X:%02X:%02X:%02X",
eth->ether_addr_octet[0],
Expand All @@ -720,45 +720,45 @@ const char *eth_addr_string (struct ether_addr *eth)

const char *if_flags_string (unsigned short flags)
{
static char buf[200];
static char buf [200];

buf[0] = '\0';

if (flags & IFF_UP)
strcat (buf,"up,");
strcat (buf, "up,");
if (flags & IFF_BROADCAST)
strcat (buf,"broadcast,");
strcat (buf, "broadcast,");
if (flags & IFF_DEBUG)
strcat (buf,"debug,");
strcat (buf, "debug,");
if (flags & IFF_LOOPBACK)
strcat (buf,"loopback,");
strcat (buf, "loopback,");
if (flags & IFF_POINTOPOINT)
strcat (buf,"p-to-p,");
strcat (buf, "p-to-p,");
if (flags & IFF_NOTRAILERS)
strcat (buf,"no-trail,");
strcat (buf, "no-trail,");
if (flags & IFF_RUNNING)
strcat (buf,"running,");
strcat (buf, "running,");
if (flags & IFF_NOARP)
strcat (buf,"no-arp,");
strcat (buf, "no-arp,");
if (flags & IFF_PROMISC)
strcat (buf,"promisc,");
strcat (buf, "promisc,");
if (flags & IFF_ALLMULTI)
strcat (buf,"all-multi,");
strcat (buf, "all-multi,");
if (flags & IFF_OACTIVE)
strcat (buf,"out-act,");
strcat (buf, "out-act,");
if (flags & IFF_SIMPLEX)
strcat (buf,"simplex,");
strcat (buf, "simplex,");
if (flags & IFF_LINK0)
strcat (buf,"link0,");
strcat (buf, "link0,");
if (flags & IFF_LINK1)
strcat (buf,"link1,");
strcat (buf, "link1,");
if (flags & IFF_LINK2)
strcat (buf,"link2,");
strcat (buf, "link2,");
if (flags & IFF_MULTICAST)
strcat (buf,"mcast,");
strcat (buf, "mcast,");

if (buf[0])
buf[strlen(buf)-1] = '\0';
buf [strlen(buf)-1] = '\0';
return (buf);
}

Expand Down

0 comments on commit e1accb2

Please sign in to comment.