diff --git a/frameworks/js/napi/vibrator/src/vibrator_js.cpp b/frameworks/js/napi/vibrator/src/vibrator_js.cpp index bcec8e5fb619c7c9f353e0be1304fb3d373ef6af..0e678f9356d51b4a20ba2433f9de4d6ca397aaba 100644 --- a/frameworks/js/napi/vibrator/src/vibrator_js.cpp +++ b/frameworks/js/napi/vibrator/src/vibrator_js.cpp @@ -273,7 +273,7 @@ static bool ParseVibrateEvent(napi_env env, napi_value eventArray, int32_t index uint32_t pointsLength = 0; CHKCF((napi_get_array_length(env, pointsArray, &pointsLength) == napi_ok), "napi_get_array_length pointsArray fail"); - event.pointNum = pointsLength; + event.pointNum = static_cast(pointsLength); if (pointsLength > 0) { if (!ParseVibratorCurvePointArray(env, pointsArray, pointsLength, event)) { MISC_HILOGE("ParseVibratorCurvePointArray failed"); @@ -296,7 +296,7 @@ static bool ParseVibratorPattern(napi_env env, napi_value args[], VibrateInfo &i CHKCF(IsMatchArrayType(env, eventArray), "Wrong argument type, Napi array expected"); uint32_t length = 0; CHKCF((napi_get_array_length(env, eventArray, &length) == napi_ok), "napi_get_array_length fail"); - info.vibratorPattern.eventNum = length; + info.vibratorPattern.eventNum = static_cast(length); if (length <= 0 || length > EVENT_NUM_MAX) { MISC_HILOGE("length should not be less than or equal to 0 or greater than EVENT_NUM_MAX"); return false; diff --git a/frameworks/native/vibrator/src/vibrator_service_client.cpp b/frameworks/native/vibrator/src/vibrator_service_client.cpp index 455efce4f543b91b900a3f50017d00e394fd34b9..ab9b01b8f0d623ceea59eb41cd40e11161208ab8 100644 --- a/frameworks/native/vibrator/src/vibrator_service_client.cpp +++ b/frameworks/native/vibrator/src/vibrator_service_client.cpp @@ -609,7 +609,7 @@ void VibratorServiceClient::ConvertSeekVibratorPackage(const VibratorPackage &co vibrateEvent.intensity = completePackage.patterns[i].events[j].intensity; vibrateEvent.frequency = completePackage.patterns[i].events[j].frequency; vibrateEvent.index = completePackage.patterns[i].events[j].index; - for (size_t k = 0; k < completePackage.patterns[i].events[j].pointNum; ++k) { + for (size_t k = 0; k < static_cast(completePackage.patterns[i].events[j].pointNum); ++k) { VibrateCurvePoint vibrateCurvePoint = {}; vibrateCurvePoint.time = completePackage.patterns[i].events[j].points[k].time; vibrateCurvePoint.intensity = completePackage.patterns[i].events[j].points[k].intensity; @@ -639,7 +639,7 @@ void VibratorServiceClient::ConvertVibratorPattern(const VibratorPattern &vibrat vibrateEvent.intensity = vibratorPattern.events[j].intensity; vibrateEvent.frequency = vibratorPattern.events[j].frequency; vibrateEvent.index = vibratorPattern.events[j].index; - for (size_t k = 0; k < vibratorPattern.events[j].pointNum; ++k) { + for (size_t k = 0; k < static_cast(vibratorPattern.events[j].pointNum); ++k) { VibrateCurvePoint vibrateCurvePoint = {}; vibrateCurvePoint.time = vibratorPattern.events[j].points[k].time; vibrateCurvePoint.intensity = vibratorPattern.events[j].points[k].intensity;