From 59ef2f0ecce5b0e9262a41d1fa2e5e3df7d4acef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=92=A6=E8=A1=97?= <15390014138@163.com> Date: Wed, 23 Sep 2020 09:26:27 +0800 Subject: [PATCH] =?UTF-8?q?update=20js/builtin/deviceinfokit/src/nativeapi?= =?UTF-8?q?=5Fdeviceinfo.cpp.=20=E5=87=8F=E5=B0=91=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=97=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/nativeapi_deviceinfo.cpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp index 88c0b17..9559661 100755 --- a/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp +++ b/js/builtin/deviceinfokit/src/nativeapi_deviceinfo.cpp @@ -51,27 +51,18 @@ void ExecuteGetInfo(void* data) JSIValue thisVal = params->thisVal; char* brand = GetBrand(); if (brand == nullptr) { - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } char* manufacture = GetManufacture(); if (manufacture == nullptr) { free(brand); - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } char* model = GetProductModel(); if (model == nullptr) { free(brand); free(manufacture); - NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); - JSI::ReleaseValueList(args, thisVal, ARGS_END); - delete params; - return; + goto _fail; } JSIValue result = JSI::CreateObject(); JSI::SetStringProperty(result, "brand", brand); @@ -88,6 +79,12 @@ void ExecuteGetInfo(void* data) JSI::ReleaseValueList(args, thisVal, result, ARGS_END); delete params; params = nullptr; + return; +_fail: + NativeapiCommon::FailCallBack(args, thisVal, ERROR_CODE_GENERAL); + JSI::ReleaseValueList(args, thisVal, ARGS_END); + delete params; + return; } } -- Gitee