Bug 921582: Avoid a 'may be used uninitialized' warning. r=waldo

Specifically:

In file included from ./../../dist/include/js/CallArgs.h:39:0,
                 from ./../../dist/include/js/CallNonGenericMethod.h:12,
                 from /home/jimb/moz/dbg/js/src/NamespaceImports.h:15,
                 from /home/jimb/moz/dbg/js/src/builtin/Intl.h:10,
                 from /home/jimb/moz/dbg/js/src/builtin/Intl.cpp:12:
./../../dist/include/js/Value.h: In function ‘bool js::intl_CompareStrings(JSContext*, unsigned int, JS::Value*)’:
./../../dist/include/js/Value.h:653:58: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     JS_RETURN_LAYOUT_FROM_BITS(((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32);
                                                          ^
/home/jimb/moz/dbg/js/src/builtin/Intl.cpp:968:13: note: ‘res’ was declared here
     int32_t res;
             ^
This commit is contained in:
Jim Blandy 2013-09-29 21:18:26 -07:00
parent 0a4f6d7144
commit 5e75884e6a

View File

@ -970,6 +970,7 @@ intl_CompareStrings(JSContext *cx, UCollator *coll, HandleString str1, HandleStr
case UCOL_LESS: res = -1; break; case UCOL_LESS: res = -1; break;
case UCOL_EQUAL: res = 0; break; case UCOL_EQUAL: res = 0; break;
case UCOL_GREATER: res = 1; break; case UCOL_GREATER: res = 1; break;
default: MOZ_ASSUME_UNREACHABLE("ucol_strcoll returned bad UCollationResult");
} }
result.setInt32(res); result.setInt32(res);
return true; return true;