sensorcommands: avoid stringop-truncation warning
When compiling ipmi-fru-parser with GCC 13.2.0, I observed the
following:
```
../subprojects/phosphor-host-ipmid/dbus-sdr/sensorcommands.cpp:1748:17: error: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ specified bound 16 equals destination size [-Werror=stringop-truncation]
1748 | std::strncpy(record.body.id_string, name.c_str(),
```
Switch to a memcpy instead of a strncpy to avoid the warning.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I43d5cddd74cf1ad2d686e9529e87ec416e2bb6a0
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index b4dfa5a..5a62d7b 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -1756,8 +1756,8 @@
auto name = sensor::parseSdrIdFromPath(path);
get_sdr::body::set_id_strlen(name.size(), &record.body);
get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1"
- std::strncpy(record.body.id_string, name.c_str(),
- sizeof(record.body.id_string));
+ std::memcpy(record.body.id_string, name.c_str(),
+ std::min(name.length() + 1, sizeof(record.body.id_string)));
// Remember the sensor name, as determined for this sensor number
details::sdrStatsTable.updateName(sensorNum, name);