Imported from libpng-0.99j.tar
diff --git a/pngrutil.c b/pngrutil.c
index 2a2bbd8..b275e7e 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1704,7 +1704,7 @@
          case 1:
          {
             png_bytep sp, dp;
-            png_uint_32 sshift, dshift;
+            int sshift, dshift;
             int s_start, s_end, s_inc;
             png_byte v;
             png_uint_32 i;
@@ -1715,8 +1715,8 @@
 #if defined(PNG_READ_PACKSWAP_SUPPORTED)
             if (transformations & PNG_PACKSWAP)
             {
-                sshift = (png_uint_32)((row_info->width + 7) & 7);
-                dshift = (png_uint_32)((final_width + 7) & 7);
+                sshift = (int)((row_info->width + 7) & 7);
+                dshift = (int)((final_width + 7) & 7);
                 s_start = 7;
                 s_end = 0;
                 s_inc = -1;
@@ -1724,8 +1724,8 @@
             else
 #endif
             {
-                sshift = 7 - (png_uint_32)((row_info->width + 7) & 7);
-                dshift = 7 - (png_uint_32)((final_width + 7) & 7);
+                sshift = 7 - (int)((row_info->width + 7) & 7);
+                dshift = 7 - (int)((final_width + 7) & 7);
                 s_start = 0;
                 s_end = 7;
                 s_inc = 1;
@@ -1759,7 +1759,7 @@
          case 2:
          {
             png_bytep sp, dp;
-            png_uint_32 sshift, dshift;
+            int sshift, dshift;
             int s_start, s_end, s_inc;
             png_uint_32 i;
 
@@ -1768,8 +1768,8 @@
 #if defined(PNG_READ_PACKSWAP_SUPPORTED)
             if (transformations & PNG_PACKSWAP)
             {
-               sshift = (png_uint_32)(((row_info->width + 3) & 3) << 1);
-               dshift = (png_uint_32)(((final_width + 3) & 3) << 1);
+               sshift = (int)(((row_info->width + 3) & 3) << 1);
+               dshift = (int)(((final_width + 3) & 3) << 1);
                s_start = 6;
                s_end = 0;
                s_inc = -2;
@@ -1777,8 +1777,8 @@
             else
 #endif
             {
-               sshift = (png_uint_32)((3 - ((row_info->width + 3) & 3)) << 1);
-               dshift = (png_uint_32)((3 - ((final_width + 3) & 3)) << 1);
+               sshift = (int)((3 - ((row_info->width + 3) & 3)) << 1);
+               dshift = (int)((3 - ((final_width + 3) & 3)) << 1);
                s_start = 0;
                s_end = 6;
                s_inc = 2;
@@ -1815,7 +1815,7 @@
          case 4:
          {
             png_bytep sp, dp;
-            png_uint_32 sshift, dshift;
+            int sshift, dshift;
             int s_start, s_end, s_inc;
             png_uint_32 i;
 
@@ -1824,8 +1824,8 @@
 #if defined(PNG_READ_PACKSWAP_SUPPORTED)
             if (transformations & PNG_PACKSWAP)
             {
-               sshift = (png_uint_32)(((row_info->width + 1) & 1) << 2);
-               dshift = (png_uint_32)(((final_width + 1) & 1) << 2);
+               sshift = (int)(((row_info->width + 1) & 1) << 2);
+               dshift = (int)(((final_width + 1) & 1) << 2);
                s_start = 4;
                s_end = 0;
                s_inc = -4;
@@ -1833,8 +1833,8 @@
             else
 #endif
             {
-               sshift = (png_uint_32)((1 - ((row_info->width + 1) & 1)) << 2);
-               dshift = (png_uint_32)((1 - ((final_width + 1) & 1)) << 2);
+               sshift = (int)((1 - ((row_info->width + 1) & 1)) << 2);
+               dshift = (int)((1 - ((final_width + 1) & 1)) << 2);
                s_start = 0;
                s_end = 4;
                s_inc = 4;
diff --git a/pngtest.c b/pngtest.c
index 5983ca3..9481427 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -54,7 +54,7 @@
 void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
 void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
-    if(png_ptr == NULL || row_number > 0x3fffffff) return;
+    if(png_ptr == NULL || row_number > 0x3fffffffL) return;
     if(status_pass != pass)
     {
        fprintf(stdout,"\n Pass %d: ",pass);
@@ -72,7 +72,7 @@
 void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
 void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
-    if(png_ptr == NULL || row_number > 0x3fffffff || pass > 7) return;
+    if(png_ptr == NULL || row_number > 0x3fffffffL || pass > 7) return;
     fprintf(stdout, "w");
 }
 
@@ -106,7 +106,7 @@
     {
        int pos=0;
        png_uint_32 n;
-       for (n=0; n<(int)row_info->width; n++)
+       for (n=0; n<row_info->width; n++)
        {
           if(row_info->bit_depth == 1)
              if(((*dp << pos++ )& 0x80) == 0) black_pixels++;
@@ -869,8 +869,8 @@
 PNG_CONST char *inname = "pngtest/png";
 PNG_CONST char *outname = "pngout/png";
 #else
-static char *inname = "pngtest.png";
-static char *outname = "pngout.png";
+static PNG_CONST char *inname = "pngtest.png";
+static PNG_CONST char *outname = "pngout.png";
 #endif
 
 int
diff --git a/pngwrite.c b/pngwrite.c
index afb4b43..e7e1fb3 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -834,10 +834,10 @@
 
       if (png_ptr->filter_weights == NULL)
       {
-         png_ptr->filter_weights = png_malloc(png_ptr,
+         png_ptr->filter_weights = (png_uint_16p) png_malloc(png_ptr,
             (png_uint_32)(sizeof(png_uint_16) * num_weights));
 
-         png_ptr->inv_filter_weights = png_malloc(png_ptr,
+         png_ptr->inv_filter_weights = (png_uint_16p) png_malloc(png_ptr,
             (png_uint_32)(sizeof(png_uint_16) * num_weights));
 
          for (i = 0; i < num_weights; i++)
@@ -869,10 +869,10 @@
     */
    if (png_ptr->filter_costs == NULL)
    {
-      png_ptr->filter_costs = png_malloc(png_ptr,
+      png_ptr->filter_costs = (png_uint_16p) png_malloc(png_ptr,
          (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
 
-      png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
+      png_ptr->inv_filter_costs = (png_uint_16p) png_malloc(png_ptr,
          (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
 
       for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)