You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ts...@apache.org on 2016/07/02 10:36:18 UTC

svn commit: r1751049 - in /incubator/log4cxx/trunk/src: changes/changes.xml main/cpp/locationinfo.cpp main/cpp/loggingevent.cpp main/cpp/objectoutputstream.cpp

Author: tschoening
Date: Sat Jul  2 10:36:18 2016
New Revision: 1751049

URL: http://svn.apache.org/viewvc?rev=1751049&view=rev
Log:
LOGCXX-482: I never liked the static_cast<char>-approach and so changed to what the bug author provided and is inline with the following comment, which has already been mentione din LOGCXX-400.

http://stackoverflow.com/questions/28094263/create-array-of-chars-avoiding-narrowing?rq=1#comment44564938_28094263

Modified:
    incubator/log4cxx/trunk/src/changes/changes.xml
    incubator/log4cxx/trunk/src/main/cpp/locationinfo.cpp
    incubator/log4cxx/trunk/src/main/cpp/loggingevent.cpp
    incubator/log4cxx/trunk/src/main/cpp/objectoutputstream.cpp

Modified: incubator/log4cxx/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/changes/changes.xml?rev=1751049&r1=1751048&r2=1751049&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/changes/changes.xml (original)
+++ incubator/log4cxx/trunk/src/changes/changes.xml Sat Jul  2 10:36:18 2016
@@ -93,6 +93,7 @@
 			<action issue="LOGCXX-443" type="fix">Return by const reference in Logger::getName()</action>
 			<action issue="LOGCXX-446" type="fix">make install fails, trying to overwrite header files</action>
 			<action issue="LOGCXX-464" type="fix">TimeBasedRollingPolicy should append as configured on rollover</action>
+			<action issue="LOGCXX-482" type="fix">Build failure with GCC-6</action>
 
 			<action type="update">Behavior of StringHelper::startsWith and endsWith synced</action>
 			<action type="update">Documented C (class) and M (method) log format keywords.</action>

Modified: incubator/log4cxx/trunk/src/main/cpp/locationinfo.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/locationinfo.cpp?rev=1751049&r1=1751048&r2=1751049&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/locationinfo.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/locationinfo.cpp Sat Jul  2 10:36:18 2016
@@ -152,14 +152,13 @@ void LocationInfo::write(ObjectOutputStr
     if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
          os.writeNull(p);
     } else {
-        char prolog[] = {
+        unsigned char prolog[] = {
          0x72,
          0x00,
          0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
          0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
-         0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, static_cast<char>(0xED),
-         static_cast<char>(0x99), static_cast<char>(0xBB), static_cast<char>(0xE1),
-         0x4A, static_cast<char>(0x91), static_cast<char>(0xA5), 0x7C, 0x02,
+         0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
+         0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
          0x00,
          0x01, 0x4C,
          0x00,
@@ -168,7 +167,7 @@ void LocationInfo::write(ObjectOutputStr
          0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
          0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
         };
-      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, prolog, sizeof(prolog), p);
+      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
         char* line = p.itoa(lineNumber);
         //
         //   construct Java-like fullInfo (replace "::" with ".")

Modified: incubator/log4cxx/trunk/src/main/cpp/loggingevent.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/loggingevent.cpp?rev=1751049&r1=1751048&r2=1751049&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/loggingevent.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/loggingevent.cpp Sat Jul  2 10:36:18 2016
@@ -236,63 +236,63 @@ void LoggingEvent::setProperty(const Log
 
 
 void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p)  {
-     char classDesc[] = {
-        0x72, 0x00, 0x21, 
-        0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 
-        0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A, 
-        0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F, 0x67, 
-        0x67, 0x69, 0x6E, 0x67, 0x45, 0x76, 0x65, 0x6E, 
-        0x74, static_cast<char>(0xF3), static_cast<char>(0xF2), static_cast<char>(0xB9), 0x23, 0x74, 0x0B, static_cast<char>(0xB5), 
-        0x3F, 0x03, 0x00, 0x0A, 0x5A, 0x00, 0x15, 0x6D, 
-        0x64, 0x63, 0x43, 0x6F, 0x70, 0x79, 0x4C, 0x6F, 
-        0x6F, 0x6B, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 
-        0x69, 0x72, 0x65, 0x64, 0x5A, 0x00, 0x11, 0x6E, 
-        0x64, 0x63, 0x4C, 0x6F, 0x6F, 0x6B, 0x75, 0x70, 
-        0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 
-        0x4A, 0x00, 0x09, 0x74, 0x69, 0x6D, 0x65, 0x53, 
-        0x74, 0x61, 0x6D, 0x70, 0x4C, 0x00, 0x0C, 0x63, 
-        0x61, 0x74, 0x65, 0x67, 0x6F, 0x72, 0x79, 0x4E, 
-        0x61, 0x6D, 0x65, 0x74, 0x00, 0x12, 0x4C, 0x6A, 
-        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 
-        0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 
-        0x4C, 0x00, 0x0C, 0x6C, 0x6F, 0x63, 0x61, 0x74, 
-        0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0x74, 
-        0x00, 0x23, 0x4C, 0x6F, 0x72, 0x67, 0x2F, 0x61, 
-        0x70, 0x61, 0x63, 0x68, 0x65, 0x2F, 0x6C, 0x6F, 
-        0x67, 0x34, 0x6A, 0x2F, 0x73, 0x70, 0x69, 0x2F, 
-        0x4C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 
-        0x49, 0x6E, 0x66, 0x6F, 0x3B, 0x4C, 0x00, 0x07, 
-        0x6D, 0x64, 0x63, 0x43, 0x6F, 0x70, 0x79, 0x74, 
-        0x00, 0x15, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 
-        0x75, 0x74, 0x69, 0x6C, 0x2F, 0x48, 0x61, 0x73, 
-        0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x3B, 0x4C, 
-        0x00, 0x03, 0x6E, 0x64, 0x63, 
-        0x74, 0x00, 0x12, 0x4C, 0x6A, 
-        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 
+     unsigned char classDesc[] = {
+        0x72, 0x00, 0x21,
+        0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63,
+        0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A,
+        0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F, 0x67,
+        0x67, 0x69, 0x6E, 0x67, 0x45, 0x76, 0x65, 0x6E,
+        0x74, 0xF3, 0xF2, 0xB9, 0x23, 0x74, 0x0B, 0xB5,
+        0x3F, 0x03, 0x00, 0x0A, 0x5A, 0x00, 0x15, 0x6D,
+        0x64, 0x63, 0x43, 0x6F, 0x70, 0x79, 0x4C, 0x6F,
+        0x6F, 0x6B, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75,
+        0x69, 0x72, 0x65, 0x64, 0x5A, 0x00, 0x11, 0x6E,
+        0x64, 0x63, 0x4C, 0x6F, 0x6F, 0x6B, 0x75, 0x70,
+        0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64,
+        0x4A, 0x00, 0x09, 0x74, 0x69, 0x6D, 0x65, 0x53,
+        0x74, 0x61, 0x6D, 0x70, 0x4C, 0x00, 0x0C, 0x63,
+        0x61, 0x74, 0x65, 0x67, 0x6F, 0x72, 0x79, 0x4E,
+        0x61, 0x6D, 0x65, 0x74, 0x00, 0x12, 0x4C, 0x6A,
+        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67,
         0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B,
-        0x4C, 0x00, 0x0F, 0x72, 0x65, 0x6E, 
-        0x64, 0x65, 0x72, 0x65, 0x64, 0x4D, 0x65, 0x73, 
-        0x73, 0x61, 0x67, 0x65, 
-        0x74, 0x00, 0x12, 0x4C, 0x6A, 
-        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 
+        0x4C, 0x00, 0x0C, 0x6C, 0x6F, 0x63, 0x61, 0x74,
+        0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0x74,
+        0x00, 0x23, 0x4C, 0x6F, 0x72, 0x67, 0x2F, 0x61,
+        0x70, 0x61, 0x63, 0x68, 0x65, 0x2F, 0x6C, 0x6F,
+        0x67, 0x34, 0x6A, 0x2F, 0x73, 0x70, 0x69, 0x2F,
+        0x4C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
+        0x49, 0x6E, 0x66, 0x6F, 0x3B, 0x4C, 0x00, 0x07,
+        0x6D, 0x64, 0x63, 0x43, 0x6F, 0x70, 0x79, 0x74,
+        0x00, 0x15, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F,
+        0x75, 0x74, 0x69, 0x6C, 0x2F, 0x48, 0x61, 0x73,
+        0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x3B, 0x4C,
+        0x00, 0x03, 0x6E, 0x64, 0x63,
+        0x74, 0x00, 0x12, 0x4C, 0x6A,
+        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67,
         0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B,
-        0x4C, 0x00, 0x0A, 0x74, 0x68, 0x72, 0x65, 
-        0x61, 0x64, 0x4E, 0x61, 0x6D, 0x65, 
-        0x74, 0x00, 0x12, 0x4C, 0x6A, 
-        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 
+        0x4C, 0x00, 0x0F, 0x72, 0x65, 0x6E,
+        0x64, 0x65, 0x72, 0x65, 0x64, 0x4D, 0x65, 0x73,
+        0x73, 0x61, 0x67, 0x65,
+        0x74, 0x00, 0x12, 0x4C, 0x6A,
+        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67,
         0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B,
-        0x4C, 0x00, 0x0D, 0x74, 0x68, 
-        0x72, 0x6F, 0x77, 0x61, 0x62, 0x6C, 0x65, 0x49, 
-        0x6E, 0x66, 0x6F, 0x74, 0x00, 0x2B, 0x4C, 0x6F, 
-        0x72, 0x67, 0x2F, 0x61, 0x70, 0x61, 0x63, 0x68, 
-        0x65, 0x2F, 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2F, 
-        0x73, 0x70, 0x69, 0x2F, 0x54, 0x68, 0x72, 0x6F, 
-        0x77, 0x61, 0x62, 0x6C, 0x65, 0x49, 0x6E, 0x66, 
-        0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 
-        0x3B, 0x78, 0x70 }; 
+        0x4C, 0x00, 0x0A, 0x74, 0x68, 0x72, 0x65,
+        0x61, 0x64, 0x4E, 0x61, 0x6D, 0x65,
+        0x74, 0x00, 0x12, 0x4C, 0x6A,
+        0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67,
+        0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B,
+        0x4C, 0x00, 0x0D, 0x74, 0x68,
+        0x72, 0x6F, 0x77, 0x61, 0x62, 0x6C, 0x65, 0x49,
+        0x6E, 0x66, 0x6F, 0x74, 0x00, 0x2B, 0x4C, 0x6F,
+        0x72, 0x67, 0x2F, 0x61, 0x70, 0x61, 0x63, 0x68,
+        0x65, 0x2F, 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2F,
+        0x73, 0x70, 0x69, 0x2F, 0x54, 0x68, 0x72, 0x6F,
+        0x77, 0x61, 0x62, 0x6C, 0x65, 0x49, 0x6E, 0x66,
+        0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E,
+        0x3B, 0x78, 0x70 };
 
-     os.writeProlog("org.apache.log4j.spi.LoggingEvent", 
-        8, classDesc, sizeof(classDesc), p);
+     os.writeProlog("org.apache.log4j.spi.LoggingEvent",
+        8, (char*) classDesc, sizeof(classDesc), p);
 }
 
 void LoggingEvent::write(helpers::ObjectOutputStream& os, Pool& p) const {

Modified: incubator/log4cxx/trunk/src/main/cpp/objectoutputstream.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/objectoutputstream.cpp?rev=1751049&r1=1751048&r2=1751049&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/objectoutputstream.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/objectoutputstream.cpp Sat Jul  2 10:36:18 2016
@@ -37,8 +37,8 @@ ObjectOutputStream::ObjectOutputStream(O
 		objectHandle(objectHandleDefault),
 		classDescriptions(new ClassDescriptionMap())
 {
-	char start[] = { static_cast<char>(0xAC), static_cast<char>(0xED), 0x00, 0x05 };
-	ByteBuffer buf(start, sizeof(start));
+	unsigned char start[] = { 0xAC, 0xED, 0x00, 0x05 };
+	ByteBuffer buf((char*) start, sizeof(start));
 	os->write(buf, p);
 }
 
@@ -97,19 +97,19 @@ void ObjectOutputStream::writeObject(con
 	//
 	// TC_OBJECT and the classDesc for java.util.Hashtable
 	//
-	char prolog[] = {
+	unsigned char prolog[] = {
 		0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61,
 		0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61,
 		0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13,
-		static_cast<char>(0xBB), 0x0F, 0x25, 0x21, 0x4A, static_cast<char>(0xE4), static_cast<char>(0xB8), 0x03,
+		0xBB, 0x0F, 0x25, 0x21, 0x4A, 0xE4, 0xB8, 0x03,
 		0x00, 0x02, 0x46, 0x00, 0x0A, 0x6C, 0x6F, 0x61,
 		0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49,
 		0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68,
 		0x6F, 0x6C, 0x64, 0x78, 0x70  };
-	writeProlog("java.util.Hashtable", 1, prolog, sizeof(prolog), p);
+	writeProlog("java.util.Hashtable", 1, (char*) prolog, sizeof(prolog), p);
 
 	// loadFactor = 0.75, threshold = 5, blockdata start, buckets.size = 7
-	char data[] = {	0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
+	char data[] = {	0x3F, 0x40,   0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
 					TC_BLOCKDATA, 0x08, 0x00, 0x00, 0x00, 0x07 };
 	ByteBuffer dataBuf(data, sizeof(data));
 	os->write(dataBuf, p);