mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-27 10:50:41 +00:00
[fix]:Rectify super large functions in the source file
Signed-off-by: huxianghao <huxianghao@huawei.com>
This commit is contained in:
parent
5794782ab5
commit
0e8da8af2c
@ -28,6 +28,38 @@ static bool g_init_lock = false;
|
||||
static SoftBusMutex g_dfx_lock;
|
||||
static HiSysEventParam g_dstParam[SOFTBUS_EVT_PARAM_BUTT];
|
||||
|
||||
static int32_t ConvertToHisEventString(SoftBusEvtParam *srcParam, HiSysEventParam *dstParam)
|
||||
{
|
||||
dstParam->t = HISYSEVENT_STRING;
|
||||
dstParam->v.s = reinterpret_cast<char *>(SoftBusCalloc(sizeof(char) * SOFTBUS_HISYSEVT_PARAM_LEN));
|
||||
if (dstParam->v.s == nullptr) {
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam: SoftBusMalloc fail");
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
if (strcpy_s(dstParam->v.s, SOFTBUS_HISYSEVT_PARAM_LEN, srcParam->paramValue.str) != EOK) {
|
||||
SoftBusFree(dstParam->v.s);
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam:copy string var fail");
|
||||
return SOFTBUS_STRCPY_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t ConvertToHisEventUint32Array(SoftBusEvtParam *srcParam, HiSysEventParam *dstParam, uint32_t arraySize)
|
||||
{
|
||||
dstParam->t = HISYSEVENT_UINT32_ARRAY;
|
||||
dstParam->v.array = reinterpret_cast<uint32_t *>(SoftBusCalloc(arraySize));
|
||||
if (dstParam->v.array == nullptr) {
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam: SoftBusMalloc fail");
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
if (memcpy_s(dstParam->v.array, arraySize, srcParam->paramValue.u32a, arraySize) != EOK) {
|
||||
SoftBusFree(dstParam->v.array);
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam:copy uint32 array var fail");
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t ConvertEventParam(SoftBusEvtParam *srcParam, HiSysEventParam *dstParam)
|
||||
{
|
||||
uint32_t arraySize = sizeof(uint32_t) * SOFTBUS_HISYSEVT_PARAM_UINT32_ARRAY_SIZE;
|
||||
@ -69,31 +101,9 @@ static int32_t ConvertEventParam(SoftBusEvtParam *srcParam, HiSysEventParam *dst
|
||||
dstParam->v.d = srcParam->paramValue.d;
|
||||
break;
|
||||
case SOFTBUS_EVT_PARAMTYPE_STRING:
|
||||
dstParam->t = HISYSEVENT_STRING;
|
||||
dstParam->v.s = reinterpret_cast<char *>(SoftBusCalloc(sizeof(char) * SOFTBUS_HISYSEVT_PARAM_LEN));
|
||||
if (dstParam->v.s == nullptr) {
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam: SoftBusMalloc fail");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (strcpy_s(dstParam->v.s, SOFTBUS_HISYSEVT_PARAM_LEN, srcParam->paramValue.str) != EOK) {
|
||||
SoftBusFree(dstParam->v.s);
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam:copy string var fail");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
break;
|
||||
return ConvertToHisEventString(srcParam, dstParam);
|
||||
case SOFTBUS_EVT_PARAMTYPE_UINT32_ARRAY:
|
||||
dstParam->t = HISYSEVENT_UINT32_ARRAY;
|
||||
dstParam->v.array = reinterpret_cast<uint32_t *>(SoftBusCalloc(arraySize));
|
||||
if (dstParam->v.array == nullptr) {
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam: SoftBusMalloc fail");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (memcpy_s(dstParam->v.array, arraySize, srcParam->paramValue.u32a, arraySize) != EOK) {
|
||||
SoftBusFree(dstParam->v.array);
|
||||
COMM_LOGE(COMM_ADAPTER, "ConvertEventParam:copy uint32 array var fail");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
break;
|
||||
return ConvertToHisEventUint32Array(srcParam, dstParam, arraySize);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -625,10 +625,8 @@ static int32_t StartScan(int32_t scannerId, const SoftBusBcScanParams *param, co
|
||||
DISC_LOGE(DISC_BLE_ADAPTER, "invalid param, scannerId=%{public}d", scannerId);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (SoftBusMutexLock(&g_scannerLock) != SOFTBUS_OK) {
|
||||
DISC_LOGE(DISC_BLE_ADAPTER, "lock failed, scannerId=%{public}d", scannerId);
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(SoftBusMutexLock(&g_scannerLock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, DISC_BLE_ADAPTER,
|
||||
"lock failed, scannerId=%{public}d", scannerId);
|
||||
if (!CheckScanChannelInUsed(scannerId)) {
|
||||
DISC_LOGE(DISC_BLE_ADAPTER, "scanner is not in used, scannerId=%{public}d", scannerId);
|
||||
SoftBusMutexUnlock(&g_scannerLock);
|
||||
|
@ -324,10 +324,8 @@ static int32_t OpensslAesGcmEncrypt(
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
EVP_CIPHER_CTX *ctx = NULL;
|
||||
if (GcmOpensslEvpInit(&ctx, cipherKey->keyLen, ENCRYPT_MODE) != SOFTBUS_OK) {
|
||||
COMM_LOGE(COMM_ADAPTER, "GcmOpensslEvpInit failed.");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
int32_t ret = GcmOpensslEvpInit(&ctx, cipherKey->keyLen, ENCRYPT_MODE);
|
||||
COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, SOFTBUS_ERR, COMM_ADAPTER, "GcmOpensslEvpInit failed.");
|
||||
if (EVP_EncryptInit_ex(ctx, NULL, NULL, cipherKey->key, cipherKey->iv) != 1) {
|
||||
COMM_LOGE(COMM_ADAPTER, "EVP_EncryptInit_ex failed.");
|
||||
goto EXIT;
|
||||
|
Loading…
Reference in New Issue
Block a user