changeset 1654:3727a09e7b53

fix some icc warnings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Sep 2015 15:03:35 +0200
parents 0c86b30bb8b2
children e40fd0d925c5
files Core/Images/Font.cpp Core/Images/JpegWriter.cpp Core/Images/JpegWriter.h Core/Toolbox.cpp OrthancServer/DicomProtocol/RemoteModalityParameters.cpp OrthancServer/DicomProtocol/RemoteModalityParameters.h UnitTestsSources/FromDcmtkTests.cpp UnitTestsSources/ImageTests.cpp UnitTestsSources/MemoryCacheTests.cpp
diffstat 9 files changed, 41 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/Font.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/Core/Images/Font.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -118,7 +118,7 @@
           throw OrthancException(ErrorCode_BadFont);
         }
 
-        c->bitmap_[j] = value;
+        c->bitmap_[j] = static_cast<uint8_t>(value);
       }
 
       int index = boost::lexical_cast<int>(characters[i]);
@@ -166,7 +166,7 @@
     unsigned int width = MyMin(character.width_, target.GetWidth() - x);
     unsigned int height = MyMin(character.height_, target.GetHeight() - y);
 
-    uint8_t bpp = target.GetBytesPerPixel();
+    unsigned int bpp = target.GetBytesPerPixel();
 
     // Blit the font bitmap OVER the target image
     // https://en.wikipedia.org/wiki/Alpha_compositing
@@ -184,7 +184,8 @@
           for (unsigned int cx = left; cx < width; cx++, pos++, p++)
           {
             uint16_t alpha = character.bitmap_[pos];
-            *p = (alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(*p)) >> 8;
+            uint16_t value = alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(*p);
+            *p = static_cast<uint8_t>(value >> 8);
           }
 
           break;
@@ -196,9 +197,11 @@
           for (unsigned int cx = left; cx < width; cx++, pos++, p += 3)
           {
             uint16_t alpha = character.bitmap_[pos];
-            p[0] = (alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(p[0])) >> 8;
-            p[1] = (alpha * static_cast<uint16_t>(color[1]) + (255 - alpha) * static_cast<uint16_t>(p[1])) >> 8;
-            p[2] = (alpha * static_cast<uint16_t>(color[2]) + (255 - alpha) * static_cast<uint16_t>(p[2])) >> 8;
+            for (uint8_t i = 0; i < 3; i++)
+            {
+              uint16_t value = alpha * static_cast<uint16_t>(color[i]) + (255 - alpha) * static_cast<uint16_t>(p[i]);
+              p[i] = static_cast<uint8_t>(value >> 8);
+            }
           }
 
           break;
--- a/Core/Images/JpegWriter.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/Core/Images/JpegWriter.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -69,7 +69,7 @@
                        unsigned int width,
                        unsigned int height,
                        PixelFormat format,
-                       int quality)
+                       uint8_t quality)
   {
     cinfo.image_width = width;
     cinfo.image_height = height;
--- a/Core/Images/JpegWriter.h	Mon Sep 28 13:49:48 2015 +0200
+++ b/Core/Images/JpegWriter.h	Mon Sep 28 15:03:35 2015 +0200
@@ -42,7 +42,7 @@
   class JpegWriter
   {
   private:
-    int  quality_;
+    uint8_t  quality_;
 
   public:
     JpegWriter() : quality_(90)
--- a/Core/Toolbox.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/Core/Toolbox.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -468,9 +468,13 @@
     assert(value < 16);
 
     if (value < 10)
+    {
       return value + '0';
+    }
     else
+    {
       return (value - 10) + 'a';
+    }
   }
 
 
@@ -508,8 +512,8 @@
     result.resize(32);
     for (unsigned int i = 0; i < 16; i++)
     {
-      result[2 * i] = GetHexadecimalCharacter(actualHash[i] / 16);
-      result[2 * i + 1] = GetHexadecimalCharacter(actualHash[i] % 16);
+      result[2 * i] = GetHexadecimalCharacter(static_cast<uint8_t>(actualHash[i] / 16));
+      result[2 * i + 1] = GetHexadecimalCharacter(static_cast<uint8_t>(actualHash[i] % 16));
     }
   }
 #endif
--- a/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -50,7 +50,7 @@
 
   RemoteModalityParameters::RemoteModalityParameters(const std::string& aet,
                                                      const std::string& host,
-                                                     int port,
+                                                     uint16_t port,
                                                      ModalityManufacturer manufacturer)
   {
     SetApplicationEntityTitle(aet);
@@ -60,16 +60,6 @@
   }
 
 
-  void RemoteModalityParameters::SetPort(int port)
-  {
-    if (port <= 0 || port >= 65535)
-    {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
-    }
-
-    port_ = port;
-  }
-
   void RemoteModalityParameters::FromJson(const Json::Value& modality)
   {
     if (!modality.isArray() ||
@@ -84,13 +74,20 @@
     const Json::Value& portValue = modality.get(2u, "");
     try
     {
-      SetPort(portValue.asInt());
+      int tmp = portValue.asInt();
+
+      if (tmp <= 0 || tmp >= 65535)
+      {
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+
+      SetPort(static_cast<uint16_t>(tmp));
     }
     catch (std::runtime_error /* error inside JsonCpp */)
     {
       try
       {
-        SetPort(boost::lexical_cast<int>(portValue.asString()));
+        SetPort(boost::lexical_cast<uint16_t>(portValue.asString()));
       }
       catch (boost::bad_lexical_cast)
       {
--- a/OrthancServer/DicomProtocol/RemoteModalityParameters.h	Mon Sep 28 13:49:48 2015 +0200
+++ b/OrthancServer/DicomProtocol/RemoteModalityParameters.h	Mon Sep 28 15:03:35 2015 +0200
@@ -34,6 +34,7 @@
 
 #include "../ServerEnumerations.h"
 
+#include <stdint.h>
 #include <string>
 #include <json/json.h>
 
@@ -44,7 +45,7 @@
   private:
     std::string aet_;
     std::string host_;
-    int port_;
+    uint16_t port_;
     ModalityManufacturer manufacturer_;
 
   public:
@@ -52,7 +53,7 @@
 
     RemoteModalityParameters(const std::string& aet,
                              const std::string& host,
-                             int port,
+                             uint16_t port,
                              ModalityManufacturer manufacturer);
 
     const std::string& GetApplicationEntityTitle() const
@@ -75,12 +76,15 @@
       host_ = host;
     }
     
-    int GetPort() const
+    uint16_t GetPort() const
     {
       return port_;
     }
 
-    void SetPort(int port);
+    void SetPort(uint16_t port)
+    {
+      port_ = port;
+    }
 
     ModalityManufacturer GetManufacturer() const
     {
--- a/UnitTestsSources/FromDcmtkTests.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -181,7 +181,7 @@
     img.SetHeight(256);
     img.SetFormat(PixelFormat_Grayscale16);
 
-    int v = 0;
+    uint16_t v = 0;
     for (unsigned int y = 0; y < img.GetHeight(); y++)
     {
       uint16_t *p = reinterpret_cast<uint16_t*>(img.GetAccessor().GetRow(y));
--- a/UnitTestsSources/ImageTests.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/UnitTestsSources/ImageTests.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -50,15 +50,15 @@
 TEST(PngWriter, ColorPattern)
 {
   Orthanc::PngWriter w;
-  int width = 17;
-  int height = 61;
-  int pitch = width * 3;
+  unsigned int width = 17;
+  unsigned int height = 61;
+  unsigned int pitch = width * 3;
 
   std::vector<uint8_t> image(height * pitch);
-  for (int y = 0; y < height; y++)
+  for (unsigned int y = 0; y < height; y++)
   {
     uint8_t *p = &image[0] + y * pitch;
-    for (int x = 0; x < width; x++, p += 3)
+    for (unsigned int x = 0; x < width; x++, p += 3)
     {
       p[0] = (y % 3 == 0) ? 255 : 0;
       p[1] = (y % 3 == 1) ? 255 : 0;
--- a/UnitTestsSources/MemoryCacheTests.cpp	Mon Sep 28 13:49:48 2015 +0200
+++ b/UnitTestsSources/MemoryCacheTests.cpp	Mon Sep 28 15:03:35 2015 +0200
@@ -190,11 +190,6 @@
       LOG(INFO) << "Removing cache entry for " << value_;
       log_ += boost::lexical_cast<std::string>(value_) + " ";
     }
-
-    int GetValue() const 
-    {
-      return value_;
-    }
   };
 
   class IntegerProvider : public Orthanc::ICachePageProvider
@@ -235,8 +230,6 @@
 
 
 
-
-
 namespace
 {
   class S : public Orthanc::IDynamicObject
@@ -253,11 +246,6 @@
     {
       return value_;
     }
-
-    static const std::string& Access(const Orthanc::IDynamicObject& obj)
-    {
-      return dynamic_cast<const S&>(obj).GetValue();
-    }
   };
 }