From be34f53a513034677a56757605516667a047bfdd Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Thu, 3 Mar 2016 14:42:57 -0700 Subject: [PATCH] grovescam: fix narrowing conversions (c++11) Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/grovescam/grovescam.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/grovescam/grovescam.cxx b/src/grovescam/grovescam.cxx index 4b1d8e2c..11f216b3 100644 --- a/src/grovescam/grovescam.cxx +++ b/src/grovescam/grovescam.cxx @@ -194,7 +194,8 @@ void GROVESCAM::drainInput() bool GROVESCAM::init() { const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = {0xaa, 0x0d|m_camAddr, 0x00, 0x00, 0x00, 0x00}; + uint8_t cmd[pktLen] = {0xaa, static_cast(0x0d|m_camAddr), 0x00, + 0x00, 0x00, 0x00}; uint8_t resp[pktLen]; int retries = 0; @@ -246,7 +247,8 @@ bool GROVESCAM::init() bool GROVESCAM::preCapture(PIC_FORMATS_T fmt) { const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = { 0xaa, 0x01 | m_camAddr, 0x00, 0x07, 0x00, fmt }; + uint8_t cmd[pktLen] = { 0xaa, static_cast(0x01 | m_camAddr), 0x00, + 0x07, 0x00, fmt }; uint8_t resp[pktLen]; int retries = 0; @@ -282,7 +284,8 @@ bool GROVESCAM::preCapture(PIC_FORMATS_T fmt) bool GROVESCAM::doCapture() { const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = { 0xaa, 0x06 | m_camAddr, 0x08, MAX_PKT_LEN & 0xff, + uint8_t cmd[pktLen] = { 0xaa, static_cast(0x06 | m_camAddr), 0x08, + MAX_PKT_LEN & 0xff, (MAX_PKT_LEN >> 8) & 0xff, 0}; uint8_t resp[pktLen]; int retries = 0; @@ -422,7 +425,8 @@ bool GROVESCAM::storeImage(const char *fname) if ((m_picTotalLen % (MAX_PKT_LEN-6)) != 0) pktCnt += 1; - uint8_t cmd[pktLen] = { 0xaa, 0x0e | m_camAddr, 0x00, 0x00, 0x00, 0x00 }; + uint8_t cmd[pktLen] = { 0xaa, static_cast(0x0e | m_camAddr), 0x00, + 0x00, 0x00, 0x00 }; uint8_t pkt[MAX_PKT_LEN]; int retries = 0;