support GCC 4.4



git-svn-id: http://ots.googlecode.com/svn/trunk@3 a4e77c2c-9104-11de-800e-5b313e0d2bf3
diff --git a/src/cff.cc b/src/cff.cc
index 28676b5..91b86fb 100644
--- a/src/cff.cc
+++ b/src/cff.cc
@@ -626,7 +626,7 @@
             }
             // TODO(yusukes): check fd value?
           } else if (format == 3) {
-            uint16_t n_ranges;
+            uint16_t n_ranges = 0;
             if (!table.ReadU16(&n_ranges)) {
               return OTS_FAILURE();
             }
@@ -636,7 +636,7 @@
 
             uint16_t last_gid = 0;
             for (unsigned j = 0; j < n_ranges; ++j) {
-              uint16_t first;  // GID
+              uint16_t first = 0;  // GID
               if (!table.ReadU16(&first)) {
                 return OTS_FAILURE();
               }
@@ -739,7 +739,7 @@
       switch (format) {
         case 0:
           for (unsigned j = 1 /* .notdef is omitted */; j < glyphs; ++j) {
-            uint16_t sid;
+            uint16_t sid = 0;
             if (!table.ReadU16(&sid)) {
               return OTS_FAILURE();
             }
@@ -754,7 +754,7 @@
         case 2: {
           uint32_t total = 1;  // .notdef is omitted.
           while (total < glyphs) {
-            uint16_t sid;
+            uint16_t sid = 0;
             if (!table.ReadU16(&sid)) {
               return OTS_FAILURE();
             }
@@ -770,7 +770,7 @@
               }
               total += (left + 1);
             } else {
-              uint16_t left;
+              uint16_t left = 0;
               if (!table.ReadU16(&left)) {
                 return OTS_FAILURE();
               }
diff --git a/src/cmap.cc b/src/cmap.cc
index a65c551..e7db21b 100644
--- a/src/cmap.cc
+++ b/src/cmap.cc
@@ -45,7 +45,7 @@
   if (!subtable.Skip(4)) {
     return OTS_FAILURE();
   }
-  uint16_t language;
+  uint16_t language = 0;
   if (!subtable.ReadU16(&language)) {
     return OTS_FAILURE();
   }
@@ -54,6 +54,7 @@
   }
 
   uint16_t segcountx2, search_range, entry_selector, range_shift;
+  segcountx2 = search_range = entry_selector = range_shift = 0;
   if (!subtable.ReadU16(&segcountx2) ||
       !subtable.ReadU16(&search_range) ||
       !subtable.ReadU16(&entry_selector) ||
@@ -224,7 +225,7 @@
   if (!subtable.Skip(8)) {
     return OTS_FAILURE();
   }
-  uint32_t language;
+  uint32_t language = 0;
   if (!subtable.ReadU32(&language)) {
     return OTS_FAILURE();
   }
@@ -232,7 +233,7 @@
     return OTS_FAILURE();
   }
 
-  uint32_t num_groups;
+  uint32_t num_groups = 0;
   if (!subtable.ReadU32(&num_groups)) {
     return OTS_FAILURE();
   }
@@ -296,7 +297,7 @@
   if (!subtable.Skip(8)) {
     return OTS_FAILURE();
   }
-  uint16_t language;
+  uint16_t language = 0;
   if (!subtable.ReadU16(&language)) {
     return OTS_FAILURE();
   }
@@ -304,7 +305,7 @@
     return OTS_FAILURE();
   }
 
-  uint32_t num_groups;
+  uint32_t num_groups = 0;
   if (!subtable.ReadU32(&num_groups)) {
     return OTS_FAILURE();
   }
@@ -360,7 +361,7 @@
   if (!subtable.Skip(4)) {
     return OTS_FAILURE();
   }
-  uint16_t language;
+  uint16_t language = 0;
   if (!subtable.ReadU16(&language)) {
     return OTS_FAILURE();
   }
@@ -389,7 +390,8 @@
   Buffer table(data, length);
   file->cmap = new OpenTypeCMAP;
 
-  uint16_t version, num_tables;
+  uint16_t version = 0;
+  uint16_t num_tables = 0;
   if (!table.ReadU16(&version) ||
       !table.ReadU16(&num_tables)) {
     return OTS_FAILURE();
@@ -450,7 +452,7 @@
 
     if ((subtable_headers[i].format == 0) ||
         (subtable_headers[i].format == 4)) {
-      uint16_t len;
+      uint16_t len = 0;
       if (!table.ReadU16(&len)) {
         return OTS_FAILURE();
       }
diff --git a/src/gasp.cc b/src/gasp.cc
index 2adcc94..d9d68be 100644
--- a/src/gasp.cc
+++ b/src/gasp.cc
@@ -18,7 +18,7 @@
   OpenTypeGASP *gasp = new OpenTypeGASP;
   file->gasp = gasp;
 
-  uint16_t num_ranges;
+  uint16_t num_ranges = 0;
   if (!table.ReadU16(&gasp->version) ||
       !table.ReadU16(&num_ranges)) {
     return OTS_FAILURE();
@@ -39,8 +39,8 @@
 
   gasp->gasp_ranges.reserve(num_ranges);
   for (unsigned i = 0; i < num_ranges; ++i) {
-    uint16_t max_ppem;
-    uint16_t behavior;
+    uint16_t max_ppem = 0;
+    uint16_t behavior = 0;
     if (!table.ReadU16(&max_ppem) ||
         !table.ReadU16(&behavior)) {
       return OTS_FAILURE();
diff --git a/src/glyf.cc b/src/glyf.cc
index bae147c..9098cfe 100644
--- a/src/glyf.cc
+++ b/src/glyf.cc
@@ -93,7 +93,7 @@
       // read the end-points array
       uint16_t num_flags = 0;
       for (int j = 0; j < num_contours; ++j) {
-        uint16_t tmp_index;
+        uint16_t tmp_index = 0;
         if (!table.ReadU16(&tmp_index)) {
           return OTS_FAILURE();
         }
diff --git a/src/head.cc b/src/head.cc
index f9b456d..840f7df 100644
--- a/src/head.cc
+++ b/src/head.cc
@@ -15,7 +15,7 @@
   Buffer table(data, length);
   file->head = new OpenTypeHEAD;
 
-  uint32_t version;
+  uint32_t version = 0;
   if (!table.ReadU32(&version) ||
       !table.ReadU32(&file->head->revision)) {
     return OTS_FAILURE();
diff --git a/src/hhea.cc b/src/hhea.cc
index 68704ef..a97260e 100644
--- a/src/hhea.cc
+++ b/src/hhea.cc
@@ -17,7 +17,7 @@
   OpenTypeHHEA *hhea = new OpenTypeHHEA;
   file->hhea = hhea;
 
-  uint32_t version;
+  uint32_t version = 0;
   if (!table.ReadU32(&version)) {
     return OTS_FAILURE();
   }
diff --git a/src/hmtx.cc b/src/hmtx.cc
index 3b6ece0..05fca9e 100644
--- a/src/hmtx.cc
+++ b/src/hmtx.cc
@@ -35,8 +35,8 @@
 
   hmtx->metrics.reserve(num_hmetrics);
   for (unsigned i = 0; i < num_hmetrics; ++i) {
-    uint16_t adv;
-    int16_t lsb;
+    uint16_t adv = 0;
+    int16_t lsb = 0;
     if (!table.ReadU16(&adv) || !table.ReadS16(&lsb)) {
       return OTS_FAILURE();
     }
diff --git a/src/loca.cc b/src/loca.cc
index 49588e3..5cafaac 100644
--- a/src/loca.cc
+++ b/src/loca.cc
@@ -35,7 +35,7 @@
     // than the number of glyphs in order to give the length of the final
     // glyph.
     for (unsigned i = 0; i <= num_glyphs; ++i) {
-      uint16_t offset;
+      uint16_t offset = 0;
       if (!table.ReadU16(&offset)) {
         return OTS_FAILURE();
       }
@@ -47,7 +47,7 @@
     }
   } else {
     for (unsigned i = 0; i <= num_glyphs; ++i) {
-      uint32_t offset;
+      uint32_t offset = 0;
       if (!table.ReadU32(&offset)) {
         return OTS_FAILURE();
       }
diff --git a/src/ltsh.cc b/src/ltsh.cc
index 57118c1..3e504d4 100644
--- a/src/ltsh.cc
+++ b/src/ltsh.cc
@@ -24,7 +24,7 @@
   OpenTypeLTSH *ltsh = new OpenTypeLTSH;
   file->ltsh = ltsh;
 
-  uint16_t num_glyphs;
+  uint16_t num_glyphs = 0;
   if (!table.ReadU16(&ltsh->version) ||
       !table.ReadU16(&num_glyphs)) {
     return OTS_FAILURE();
diff --git a/src/maxp.cc b/src/maxp.cc
index b984fe9..44a1347 100644
--- a/src/maxp.cc
+++ b/src/maxp.cc
@@ -15,7 +15,7 @@
   OpenTypeMAXP *maxp = new OpenTypeMAXP;
   file->maxp = maxp;
 
-  uint32_t version;
+  uint32_t version = 0;
   if (!table.ReadU32(&version)) {
     return OTS_FAILURE();
   }
diff --git a/src/post.cc b/src/post.cc
index cb42417..4e7eae1 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -46,7 +46,7 @@
     return OTS_FAILURE();
   }
 
-  uint16_t num_glyphs;
+  uint16_t num_glyphs = 0;
   if (!table.ReadU16(&num_glyphs)) {
     return OTS_FAILURE();
   }
diff --git a/test/SConstruct b/test/SConstruct
index 4e688d3..1f639d6 100644
--- a/test/SConstruct
+++ b/test/SConstruct
@@ -8,7 +8,7 @@
 
 # Since the validator-checker tool might handle malicious font files, all hardening options for recent g++/ld are enabled just in case.
 # See http://wiki.debian.org/Hardening for details.
-env = Environment(CCFLAGS = ['-O2', '-I../include', '-I/usr/include/freetype2', '-ggdb', '-Wall', '-W', '-Wno-unused-parameter', '-fPIE', '-fstack-protector', '-D_FORTIFY_SOURCE=2', '-DOTS_DEBUG'], LINKFLAGS = ['-ggdb', '-Wl,-z,relro', '-Wl,-z,now', '-pie'])
+env = Environment(CCFLAGS = ['-O2', '-I../include', '-I/usr/include/freetype2', '-ggdb', '-Wall', '-W', '-Wno-unused-parameter', '-fno-strict-aliasing', '-fPIE', '-fstack-protector', '-D_FORTIFY_SOURCE=2', '-DOTS_DEBUG'], LINKFLAGS = ['-ggdb', '-Wl,-z,relro', '-Wl,-z,now', '-pie'])
 # TODO(yusukes): better to use pkg-config freetype2 --cflags
  
 env.Library('../src/libots.a',
diff --git a/test/perf.cc b/test/perf.cc
index 34fe931..729bbe1 100644
--- a/test/perf.cc
+++ b/test/perf.cc
@@ -72,7 +72,7 @@
   timersub(&end, &start, &elapsed);
 
   uint64_t us = ((elapsed.tv_sec * 1000 * 1000) + elapsed.tv_usec) / num_repeat;
-  std::fprintf(stderr, "%lu [us] %s (%lu bytes, %lu [byte/us])\n",
+  std::fprintf(stderr, "%llu [us] %s (%lu bytes, %llu [byte/us])\n",
                us, argv[1], st.st_size, (us ? st.st_size / us : 0));
 
   return 0;
diff --git a/test/side-by-side.cc b/test/side-by-side.cc
index 1b5ff90..08056ba 100644
--- a/test/side-by-side.cc
+++ b/test/side-by-side.cc
@@ -8,6 +8,7 @@
 #include FT_FREETYPE_H
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include <cstdio>
 #include <cstdlib>
diff --git a/test/validator-checker.cc b/test/validator-checker.cc
index 66c2b75..e01b0fb 100644
--- a/test/validator-checker.cc
+++ b/test/validator-checker.cc
@@ -7,6 +7,7 @@
 #include FT_FREETYPE_H
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include <cstdio>
 #include <cstdlib>