From 8dab812f3a3e3fa58a1150234ee2a8a523d23819 Mon Sep 17 00:00:00 2001 From: Ayoub Zaki Date: Thu, 19 Dec 2024 09:13:03 +0100 Subject: [PATCH] cppcheck: remove all warnings --- bmap-writer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bmap-writer.cpp b/bmap-writer.cpp index 39f7c92..cbf8ec9 100644 --- a/bmap-writer.cpp +++ b/bmap-writer.cpp @@ -125,6 +125,7 @@ bool isDeviceMounted(const std::string &device) { } void printBufferHex(const char *buffer, size_t size) { +#ifdef DEBUG for (size_t i = 0; i < size; ++i) { std::cout << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)(unsigned char)buffer[i]; if ((i + 1) % 16 == 0) { @@ -134,6 +135,11 @@ void printBufferHex(const char *buffer, size_t size) { } } std::cout << std::endl; +#else + (void)buffer; + (void)size; + return; +#endif } int BmapWriteImage(const std::string &imageFile, const bmap_t &bmap, const std::string &device) { @@ -229,7 +235,7 @@ int BmapWriteImage(const std::string &imageFile, const bmap_t &bmap, const std:: err << "Computed Checksum: " << computedChecksum << std::endl; err << "Expected Checksum: " << range.checksum; //std::cerr << "Buffer content (hex):" << std::endl; - //printBufferHex(buffer.data(), outBytes); + printBufferHex(buffer.data(), outBytes); throw std::string(err.str()); } @@ -260,7 +266,7 @@ int BmapWriteImage(const std::string &imageFile, const bmap_t &bmap, const std:: return ret; } -int main(int argc, char *argv[]) { +int main(int argc, const char *argv[]) { if (argc < 4) { std::cerr << "Usage: " << argv[0] << " " << std::endl; return 1;