From cb7be7ec707345fa7e748135fe6c998825eaaa4d Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Wed, 1 Feb 2017 15:42:53 +0900 Subject: [PATCH] Initialize pointers to prevent warnings during initial assignment In convert_from_v8.cc, the unwrapping of values uses two separate lines of code for variable declaration and variable assignment. When a pointer (or double pointer) is present, the assignment to the newly declared variable creates a compiler warning. To prevent the compilation logs from filling up unnecessarily, pointer variables should initially be assigned a `NULL` value upon its declaration so that the compiler will not emit a warning on the subseqent variable assignment line. --- generate/templates/partials/convert_from_v8.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generate/templates/partials/convert_from_v8.cc b/generate/templates/partials/convert_from_v8.cc index 425e691f4..f7c4da469 100644 --- a/generate/templates/partials/convert_from_v8.cc +++ b/generate/templates/partials/convert_from_v8.cc @@ -1,6 +1,12 @@ {%if not isPayload %} // start convert_from_v8 block + {%if cType|isPointer %} + {{ cType }} from_{{ name }} = NULL; + {%elsif cType|isDoublePointer %} + {{ cType }} from_{{ name }} = NULL; + {%else%} {{ cType }} from_{{ name }}; + {%endif%} {%if isOptional | or isBoolean %} {%if cppClassName == 'GitStrarray'%}