From: Jay Krell Date: Thu, 13 Jun 2019 09:09:58 +0000 (-0700) Subject: intrinsics.c: In function 'mini_emit_inst_for_method': X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~1132 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca6258df8db9c968f75f62e9dad7107eec01bd54;p=platform%2Fupstream%2Fdotnet%2Fruntime.git intrinsics.c: In function 'mini_emit_inst_for_method': intrinsics.c:1580:11: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized] *dest = result; ~~~~~~^~~~~~~~ Commit migrated from https://github.com/mono/mono/commit/9c70b53cc39bd1347ed714e7a2e567a0c761246a --- diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index 18b9d28..dbff853 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -1462,7 +1462,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign * we avoid folding constants that when computed would raise an error, in * case the user code was expecting to get that error raised */ - if (fsig->param_count == 1 && args [0]->opcode == OP_R8CONST){ + if (fsig->param_count == 1 && args [0]->opcode == OP_R8CONST) { double source = *(double *)args [0]->inst_p0; int opcode = 0; const char *mname = cmethod->name; @@ -1471,63 +1471,63 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign if (c == 'A'){ if (strcmp (mname, "Abs") == 0 && fsig->params [0]->type == MONO_TYPE_R8) { opcode = OP_ABS; - } else if (strcmp (mname, "Asin") == 0){ + } else if (strcmp (mname, "Asin") == 0) { if (fabs (source) <= 1) opcode = OP_ASIN; - } else if (strcmp (mname, "Asinh") == 0){ + } else if (strcmp (mname, "Asinh") == 0) { opcode = OP_ASINH; - } else if (strcmp (mname, "Acos") == 0){ + } else if (strcmp (mname, "Acos") == 0) { if (fabs (source) <= 1) opcode = OP_ACOS; - } else if (strcmp (mname, "Acosh") == 0){ + } else if (strcmp (mname, "Acosh") == 0) { if (source >= 1) opcode = OP_ACOSH; - } else if (strcmp (mname, "Atan") == 0){ + } else if (strcmp (mname, "Atan") == 0) { opcode = OP_ATAN; - } else if (strcmp (mname, "Atanh") == 0){ + } else if (strcmp (mname, "Atanh") == 0) { if (fabs (source) < 1) opcode = OP_ATANH; } - } else if (c == 'C'){ + } else if (c == 'C') { if (strcmp (mname, "Cos") == 0) { if (!isinf (source)) opcode = OP_COS; - } else if (strcmp (mname, "Cbrt") == 0){ + } else if (strcmp (mname, "Cbrt") == 0) { opcode = OP_CBRT; - } else if (strcmp (mname, "Cosh") == 0){ + } else if (strcmp (mname, "Cosh") == 0) { opcode = OP_COSH; } - } else if (c == 'R'){ + } else if (c == 'R') { if (strcmp (mname, "Round") == 0) opcode = OP_ROUND; - } else if (c == 'S'){ + } else if (c == 'S') { if (strcmp (mname, "Sin") == 0) { if (!isinf (source)) opcode = OP_SIN; } else if (strcmp (mname, "Sqrt") == 0) { if (source >= 0) opcode = OP_SQRT; - } else if (strcmp (mname, "Sinh") == 0){ + } else if (strcmp (mname, "Sinh") == 0) { opcode = OP_SINH; } - } else if (c == 'T'){ + } else if (c == 'T') { if (strcmp (mname, "Tan") == 0){ if (!isinf (source)) opcode = OP_TAN; - } else if (strcmp (mname, "Tanh") == 0){ + } else if (strcmp (mname, "Tanh") == 0) { opcode = OP_TANH; } } if (opcode) { double *dest = (double *) mono_domain_alloc (cfg->domain, sizeof (double)); - double result; + double result = 0; MONO_INST_NEW (cfg, ins, OP_R8CONST); ins->type = STACK_R8; ins->dreg = mono_alloc_dreg (cfg, (MonoStackType) ins->type); ins->inst_p0 = dest; - switch (opcode){ + switch (opcode) { case OP_ABS: result = fabs (source); break; @@ -1576,6 +1576,8 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign case OP_TANH: result = tanh (source); break; + default: + g_error ("invalid opcode %d", (int)opcode); } *dest = result; MONO_ADD_INS (cfg->cbb, ins);