changeset 5:e4da36a2abae

Changes to keep -Wall happy
author Norman Gray <norman@astro.gla.ac.uk>
date Fri, 06 Sep 2013 19:00:17 +0100
parents f737659096e9
children be345cbc031f
files src/jason.c src/json2der.c
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/jason.c	Thu Sep 05 21:11:19 2013 +0100
+++ b/src/jason.c	Fri Sep 06 19:00:17 2013 +0100
@@ -1120,10 +1120,10 @@
         return make_real(0.0);
     } else {
         int sign;
-        int exponent;
+        int exponent = 0;       /* initialise to keep -Wall happy */
         int nexp;
         jsonint mantissa;
-        size_t mantidx;
+        size_t mantidx = 0;
         double result;
 
         if (! (b[0] & 0x80) || (b[0] & 0x3c)) {
@@ -1145,7 +1145,10 @@
             break;
           default:
             unsupported_operation("unexpected exponent size: %d bytes", nexp+1);
+            // don't get here
         }
+
+        assert(mantidx > 0);
         mantissa = parse_der_integer_content_to_integer(&b[mantidx], blen-mantidx);
         result = copysign(ldexp((double)mantissa, exponent), sign);
 
@@ -1197,8 +1200,8 @@
     JsonObject list_of_objects = NULL;
     size_t olen;
     JsonObject obj;
-    JsonObject key;
-    JsonObject value;
+    JsonObject key = NULL;
+    JsonObject value = NULL;
 
     // Parse each of the der objects in the content of this byte
     // array.  Each of these should be a two-element sequence (ie,
@@ -1241,6 +1244,8 @@
         fprintf(stderr, "; value=%s\n", pp);
 #endif
 
+        assert(ok_object && key != NULL && value != NULL);
+
         obj = make_kv(key->x.s, value);
         free_json_object_internal(key, 0);
         free_json_object_internal(array_obj, 0);
--- a/src/json2der.c	Thu Sep 05 21:11:19 2013 +0100
+++ b/src/json2der.c	Fri Sep 06 19:00:17 2013 +0100
@@ -37,8 +37,8 @@
     int ch;
     Format input_format = FMT_JSON;
     Format output_format = FMT_DER;
-    byte* input_string;
-    size_t input_string_length;
+    byte* input_string = NULL;
+    size_t input_string_length = 0;
     FILE* infile = stdin;
     FILE* outfile = stdout;
 
@@ -119,6 +119,8 @@
         Usage();
     }
 
+    assert(input_string != NULL);
+
     if ((input_format == FMT_JSON || input_format == FMT_DER)
         && (output_format == FMT_JSON || output_format == FMT_DER)) {
         parse_and_display(input_format, output_format,
@@ -135,7 +137,7 @@
                               byte* input_string, size_t input_string_length,
                               FILE* out)
 {
-    JsonObject parse_val;
+    JsonObject parse_val = NULL;
 
     switch (input) {
       case FMT_JSON: