@alteriom/painlessmesh 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -204,9 +204,14 @@ void routePackage(const layout::Layout<T>& layout,
204
204
  #if ARDUINOJSON_VERSION_MAJOR == 7
205
205
  protocol::Variant variant(pkg);
206
206
  if (variant.error) {
207
+ // The error is a DeserializationError object, not an integer: passing it
208
+ // through varargs is undefined behaviour. size_t is unsigned long on the
209
+ // 64-bit desktop build and unsigned int on ESP32/ESP8266, so it is cast
210
+ // to one type and printed with the matching specifier.
207
211
  Log(ERROR,
208
- "routePackage(): parsing failed. err=%u, total_length=%d, data=%s<--\n",
209
- variant.error, pkg.length(), pkg.c_str());
212
+ "routePackage(): parsing failed. err=%s, total_length=%lu, data=%s<--\n",
213
+ variant.error.c_str(), static_cast<unsigned long>(pkg.length()),
214
+ pkg.c_str());
210
215
  return;
211
216
  }
212
217
 
@@ -248,15 +253,20 @@ void routePackage(const layout::Layout<T>& layout,
248
253
  auto variant = std::make_shared<protocol::Variant>(pkg, capacity);
249
254
 
250
255
  if (variant->error) {
256
+ // Same two defects as the ArduinoJson 7 branch above (CodeQL
257
+ // cpp/wrong-type-format-argument, alerts #6-#9).
251
258
  if (variant->error == DeserializationError::NoMemory) {
252
259
  Log(ERROR,
253
- "routePackage(): Message too large. length=%d, calculated_capacity=%u, "
254
- "nesting_depth=%u. Consider increasing MAX_MESSAGE_CAPACITY if needed.\n",
255
- pkg.length(), calculatedCapacity, nestingDepth);
260
+ "routePackage(): Message too large. length=%lu, calculated_capacity=%lu, "
261
+ "nesting_depth=%lu. Consider increasing MAX_MESSAGE_CAPACITY if needed.\n",
262
+ static_cast<unsigned long>(pkg.length()),
263
+ static_cast<unsigned long>(calculatedCapacity),
264
+ static_cast<unsigned long>(nestingDepth));
256
265
  } else {
257
266
  Log(ERROR,
258
- "routePackage(): parsing failed. err=%u, length=%d, data=%s<--\n",
259
- variant->error, pkg.length(), pkg.c_str());
267
+ "routePackage(): parsing failed. err=%s, length=%lu, data=%s<--\n",
268
+ variant->error.c_str(), static_cast<unsigned long>(pkg.length()),
269
+ pkg.c_str());
260
270
  }
261
271
  return;
262
272
  }