Declare lead_surrogate only in the block where it's used.

That makes it a bit clearer that we don't need to initialize it to zero
before the loop.

This fixes a Dead Store (Dead assignement/Dead increment) Warning found
by Clang.

Change-Id: Iabfc4b47a3c6300814492c37ccfb321afd0c54ea
Reviewed-on: https://code.wireshark.org/review/28374
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-06-21 23:55:00 -07:00
parent edc2bebcec
commit 590d0a483e
1 changed files with 5 additions and 3 deletions

View File

@ -235,7 +235,7 @@ static guint8 *
utf_16_to_utf_8(const guint8 *in, guint32 length) utf_16_to_utf_8(const guint8 *in, guint32 length)
{ {
guint8 *result, *out; guint8 *result, *out;
gunichar2 uchar2, lead_surrogate; gunichar2 uchar2;
gunichar uchar; gunichar uchar;
size_t n_bytes; size_t n_bytes;
guint32 i; guint32 i;
@ -245,7 +245,6 @@ utf_16_to_utf_8(const guint8 *in, guint32 length)
* the input string in the process. * the input string in the process.
*/ */
n_bytes = 0; n_bytes = 0;
lead_surrogate = 0;
for (i = 0; i + 1 < length && (uchar2 = pletoh16(in + i)) != '\0'; for (i = 0; i + 1 < length && (uchar2 = pletoh16(in + i)) != '\0';
i += 2) { i += 2) {
if (IS_LEAD_SURROGATE(uchar2)) { if (IS_LEAD_SURROGATE(uchar2)) {
@ -253,6 +252,8 @@ utf_16_to_utf_8(const guint8 *in, guint32 length)
* Lead surrogate. Must be followed by a trail * Lead surrogate. Must be followed by a trail
* surrogate. * surrogate.
*/ */
gunichar2 lead_surrogate;
i += 2; i += 2;
if (i + 1 >= length) { if (i + 1 >= length) {
/* /*
@ -311,7 +312,6 @@ utf_16_to_utf_8(const guint8 *in, guint32 length)
*/ */
result = (guint8 *)g_malloc(n_bytes + 1); result = (guint8 *)g_malloc(n_bytes + 1);
lead_surrogate = 0;
out = result; out = result;
for (i = 0; i + 1 < length && (uchar2 = pletoh16(in + i)) != '\0'; for (i = 0; i + 1 < length && (uchar2 = pletoh16(in + i)) != '\0';
i += 2) { i += 2) {
@ -320,6 +320,8 @@ utf_16_to_utf_8(const guint8 *in, guint32 length)
* Lead surrogate. Must be followed by a trail * Lead surrogate. Must be followed by a trail
* surrogate. * surrogate.
*/ */
gunichar2 lead_surrogate;
i += 2; i += 2;
if (i + 1 >= length) { if (i + 1 >= length) {
/* /*