Fixed const char * comparison.
authorFlorian Pose <fp@igh-essen.com>
Thu, 30 Apr 2009 19:35:58 +0000
changeset 1431 70e891465da1
parent 1430 97ab86a9b1d7
child 1432 1cda765207cd
Fixed const char * comparison.
tool/CommandRegRead.cpp
tool/CommandRegWrite.cpp
--- a/tool/CommandRegRead.cpp	Thu Apr 30 16:04:44 2009 +0000
+++ b/tool/CommandRegRead.cpp	Thu Apr 30 19:35:58 2009 +0000
@@ -159,35 +159,35 @@
 	}
 
     cout << setfill('0');
-    if (!dataType || dataType->name == "string") {
+    if (!dataType || string(dataType->name) == "string") {
         uint16_t i;
         for (i = 0; i < data.length; i++) {
             cout << data.data[i];
         }
         if (dataType)
             cout << endl;
-    } else if (dataType->name == "int8") {
+    } else if (string(dataType->name) == "int8") {
         int val = (int) *data.data;
         cout << "0x" << hex << setw(2) << val << " " << dec << val << endl;
-    } else if (dataType->name == "int16") {
+    } else if (string(dataType->name) == "int16") {
         int16_t val = le16_to_cpup(data.data);
         cout << "0x" << hex << setw(4) << val << " " << dec << val << endl;
-    } else if (dataType->name == "int32") {
+    } else if (string(dataType->name) == "int32") {
         int32_t val = le32_to_cpup(data.data);
         cout << "0x" << hex << setw(8) << val << " " << dec << val << endl;
-    } else if (dataType->name == "int64") {
+    } else if (string(dataType->name) == "int64") {
         int64_t val = le64_to_cpup(data.data);
         cout << "0x" << hex << setw(16) << val << " " << dec << val << endl;
-    } else if (dataType->name == "uint8") {
+    } else if (string(dataType->name) == "uint8") {
         unsigned int val = (unsigned int) *data.data;
         cout << "0x" << hex << setw(2) << val << " " << dec << val << endl;
-    } else if (dataType->name == "uint16") {
+    } else if (string(dataType->name) == "uint16") {
         uint16_t val = le16_to_cpup(data.data);
         cout << "0x" << hex << setw(4) << val << " " << dec << val << endl;
-    } else if (dataType->name == "uint32") {
+    } else if (string(dataType->name) == "uint32") {
         uint32_t val = le32_to_cpup(data.data);
         cout << "0x" << hex << setw(8) << val << " " << dec << val << endl;
-    } else if (dataType->name == "uint64") {
+    } else if (string(dataType->name) == "uint64") {
         uint64_t val = le64_to_cpup(data.data);
         cout << "0x" << hex << setw(16) << val << " " << dec << val << endl;
     } else { // raw
--- a/tool/CommandRegWrite.cpp	Thu Apr 30 16:04:44 2009 +0000
+++ b/tool/CommandRegWrite.cpp	Thu Apr 30 19:35:58 2009 +0000
@@ -132,44 +132,44 @@
 		strValue.exceptions(ios::failbit);
 
 		try {
-			if (dataType->name == "int8") {
+			if (string(dataType->name) == "int8") {
 				int16_t val; // uint8_t is interpreted as char
 				strValue >> val;
 				if (val > 127 || val < -128)
 					throw ios::failure("Value out of range");
 				*data.data = (int8_t) val;
-			} else if (dataType->name == "int16") {
+			} else if (string(dataType->name) == "int16") {
 				int16_t val;
 				strValue >> val;
 				*(int16_t *) data.data = cpu_to_le16(val);
-			} else if (dataType->name == "int32") {
+			} else if (string(dataType->name) == "int32") {
 				int32_t val;
 				strValue >> val;
 				*(int32_t *) data.data = cpu_to_le32(val);
-			} else if (dataType->name == "int64") {
+			} else if (string(dataType->name) == "int64") {
 				int64_t val;
 				strValue >> val;
 				*(int64_t *) data.data = cpu_to_le64(val);
-			} else if (dataType->name == "uint8") {
+			} else if (string(dataType->name) == "uint8") {
 				uint16_t val; // uint8_t is interpreted as char
 				strValue >> val;
 				if (val > 0xff)
 					throw ios::failure("Value out of range");
 				*data.data = (uint8_t) val;
-			} else if (dataType->name == "uint16") {
+			} else if (string(dataType->name) == "uint16") {
 				uint16_t val;
 				strValue >> val;
 				*(uint16_t *) data.data = cpu_to_le16(val);
-			} else if (dataType->name == "uint32") {
+			} else if (string(dataType->name) == "uint32") {
 				uint32_t val;
 				strValue >> val;
 				*(uint32_t *) data.data = cpu_to_le32(val);
-			} else if (dataType->name == "uint64") {
+			} else if (string(dataType->name) == "uint64") {
 				uint64_t val;
 				strValue >> val;
 				*(uint64_t *) data.data = cpu_to_le64(val);
-			} else if (dataType->name == "string" ||
-					dataType->name == "octet_string") {
+			} else if (string(dataType->name) == "string" ||
+					string(dataType->name) == "octet_string") {
 				data.length = strValue.str().size();
 				if (!data.length) {
 					err << "Zero-size string now allowed!";