From: Mukund Sivaraman Date: Thu, 31 May 2012 05:11:39 +0000 (+0530) Subject: [2009] Add comment about why a static_cast is necessary X-Git-Tag: trac2351_base~226^2~64^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afc0fe7345aa86ba3eaebf1bba8f62db64760c1f;p=thirdparty%2Fkea.git [2009] Add comment about why a static_cast is necessary --- diff --git a/src/lib/xfr/xfrout_client.cc b/src/lib/xfr/xfrout_client.cc index 1d7ce3bc63..af0c1b51c3 100644 --- a/src/lib/xfr/xfrout_client.cc +++ b/src/lib/xfr/xfrout_client.cc @@ -82,7 +82,12 @@ XfroutClient::sendXfroutRequestInfo(const int tcp_sock, // TODO: this shouldn't be blocking send, even though it's unlikely to // block. - // converting the 16-bit word to network byte order. + // Converting the 16-bit word to network byte order. + + // Splitting msg_len below performs something called a 'narrowing + // conversion' (conversion of uint16_t to uint8_t). C++0x (and GCC + // 4.7) requires explicit casting when a narrowing conversion is + // performed. For reference, see 8.5.4/6 of n3225. const uint8_t lenbuf[2] = { static_cast(msg_len >> 8), static_cast(msg_len & 0xff) }; if (send(impl_->socket_.native(), lenbuf, sizeof(lenbuf), 0) !=