summaryrefslogtreecommitdiffstats
path: root/sys/dev/firewire
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2014-02-04 03:36:42 +0000
committereadler <eadler@FreeBSD.org>2014-02-04 03:36:42 +0000
commitec294fd7f5fc5de11ed889d6c2d701f918d1ecfb (patch)
tree7e76e370b9406b0383b17bd343084addb4ad6a25 /sys/dev/firewire
parentd374d7f398b846dc59d8a5ec3c7bfb318cf880af (diff)
downloadFreeBSD-src-ec294fd7f5fc5de11ed889d6c2d701f918d1ecfb.zip
FreeBSD-src-ec294fd7f5fc5de11ed889d6c2d701f918d1ecfb.tar.gz
MFC r258779,r258780,r258787,r258822:
Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this shifts into the sign bit. Instead use (1U << 31) which gets the expected result. Similar to the (1 << 31) case it is not defined to do (2 << 30). This fix is not ideal as it assumes a 32 bit int, but does fix the issue for most cases. A similar change was made in OpenBSD.
Diffstat (limited to 'sys/dev/firewire')
-rw-r--r--sys/dev/firewire/firewire.c2
-rw-r--r--sys/dev/firewire/fwohci.c4
-rw-r--r--sys/dev/firewire/fwohcireg.h4
-rw-r--r--sys/dev/firewire/sbp.c2
-rw-r--r--sys/dev/firewire/sbp.h2
-rw-r--r--sys/dev/firewire/sbp_targ.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c
index f1ebb6d..0a6180a 100644
--- a/sys/dev/firewire/firewire.c
+++ b/sys/dev/firewire/firewire.c
@@ -649,7 +649,7 @@ fw_reset_csr(struct firewire_comm *fc)
CSRARC(fc, BANDWIDTH_AV) = 4915;
CSRARC(fc, CHANNELS_AV_HI) = 0xffffffff;
CSRARC(fc, CHANNELS_AV_LO) = 0xffffffff;
- CSRARC(fc, IP_CHANNELS) = (1 << 31);
+ CSRARC(fc, IP_CHANNELS) = (1U << 31);
CSRARC(fc, CONF_ROM) = 0x04 << 24;
CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */
diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c
index 77886d3..ae753d5 100644
--- a/sys/dev/firewire/fwohci.c
+++ b/sys/dev/firewire/fwohci.c
@@ -179,7 +179,7 @@ static void fwohci_task_dma(void *, int);
#define OHCI_ATRETRY 0x08
#define OHCI_CROMHDR 0x18
#define OHCI_BUS_OPT 0x20
-#define OHCI_BUSIRMC (1 << 31)
+#define OHCI_BUSIRMC (1U << 31)
#define OHCI_BUSCMC (1 << 30)
#define OHCI_BUSISC (1 << 29)
#define OHCI_BUSBMC (1 << 28)
@@ -205,7 +205,7 @@ static void fwohci_task_dma(void *, int);
#define OHCI_SID_BUF 0x64
#define OHCI_SID_CNT 0x68
-#define OHCI_SID_ERR (1 << 31)
+#define OHCI_SID_ERR (1U << 31)
#define OHCI_SID_CNT_MASK 0xffc
#define OHCI_IT_STAT 0x90
diff --git a/sys/dev/firewire/fwohcireg.h b/sys/dev/firewire/fwohcireg.h
index 64bbf4f..d8deca8 100644
--- a/sys/dev/firewire/fwohcireg.h
+++ b/sys/dev/firewire/fwohcireg.h
@@ -241,7 +241,7 @@ struct ohci_registers {
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */
-#define OHCI_HCC_BIBIV (1 << 31) /* BIBimage Valid */
+#define OHCI_HCC_BIBIV (1U << 31) /* BIBimage Valid */
#define OHCI_HCC_BIGEND (1 << 30) /* noByteSwapData */
#define OHCI_HCC_PRPHY (1 << 23) /* programPhyEnable */
#define OHCI_HCC_PHYEN (1 << 22) /* aPhyEnhanceEnable */
@@ -280,7 +280,7 @@ struct ohci_registers {
fwohcireg_t link_cntl_clr; /* Chip control clear 0xe4*/
#define FWOHCI_NODEID 0xe8
fwohcireg_t node; /* Node ID 0xe8 */
-#define OHCI_NODE_VALID (1 << 31)
+#define OHCI_NODE_VALID (1U << 31)
#define OHCI_NODE_ROOT (1 << 30)
#define OHCI_ASYSRCBUS 1
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index 00e780e..8c978dd 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -2469,7 +2469,7 @@ END_DEBUG
ocb->sdev = sdev;
ocb->ccb = ccb;
ccb->ccb_h.ccb_sdev_ptr = sdev;
- ocb->orb[0] = htonl(1 << 31);
+ ocb->orb[0] = htonl(1U << 31);
ocb->orb[1] = 0;
ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS )<< 16) );
ocb->orb[3] = htonl(ocb->bus_addr + IND_PTR_OFFSET);
diff --git a/sys/dev/firewire/sbp.h b/sys/dev/firewire/sbp.h
index fcfa514..84d522a 100644
--- a/sys/dev/firewire/sbp.h
+++ b/sys/dev/firewire/sbp.h
@@ -35,7 +35,7 @@
*
*/
-#define ORB_NOTIFY (1 << 31)
+#define ORB_NOTIFY (1U << 31)
#define ORB_FMT_STD (0 << 29)
#define ORB_FMT_VED (2 << 29)
#define ORB_FMT_NOP (3 << 29)
diff --git a/sys/dev/firewire/sbp_targ.c b/sys/dev/firewire/sbp_targ.c
index f3434dd..8026b79 100644
--- a/sys/dev/firewire/sbp_targ.c
+++ b/sys/dev/firewire/sbp_targ.c
@@ -1716,7 +1716,7 @@ sbp_targ_pointer_handler(struct fw_xfer *xfer)
orb0 = ntohl(orbi->orb[0]);
orb1 = ntohl(orbi->orb[1]);
- if ((orb0 & (1 << 31)) != 0) {
+ if ((orb0 & (1U << 31)) != 0) {
printf("%s: invalid pointer\n", __func__);
goto done;
}
OpenPOWER on IntegriCloud