Skip to content
Snippets Groups Projects
Commit 5f313637 authored by Florian Pose's avatar Florian Pose
Browse files

Fixed const char * comparison.

parent 738dd2a2
No related branches found
No related tags found
No related merge requests found
......@@ -159,35 +159,35 @@ void CommandRegRead::execute(MasterDevice &m, const StringVector &args)
}
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
......
......@@ -132,44 +132,44 @@ void CommandRegWrite::execute(MasterDevice &m, const StringVector &args)
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!";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment