diff --git a/samgr_endpoint/source/endpoint_rpc.c b/samgr_endpoint/source/endpoint_rpc.c index f3048b76a3aa9ed7b432689f59e74361a7e520c7..65dc2481cb4d93d70823d1d77a19fd9135b7db09 100644 --- a/samgr_endpoint/source/endpoint_rpc.c +++ b/samgr_endpoint/source/endpoint_rpc.c @@ -115,7 +115,7 @@ int32 SAMGR_AddSysCap(const Endpoint *endpoint, const char *sysCap, BOOL isReg) IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } @@ -153,7 +153,7 @@ int32 SAMGR_GetSysCap(const Endpoint *endpoint, const char *sysCap, BOOL *isReg) IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } @@ -186,7 +186,7 @@ static int SendGetAllSysCapsRequest(const Endpoint *endpoint, uint32 startIdx, I WriteUint32(&req, RES_SYSCAP); WriteUint32(&req, OP_ALL); WriteUint32(&req, startIdx); - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } diff --git a/samgr_endpoint/source/samgr_small_ipc_adapter.c b/samgr_endpoint/source/samgr_small_ipc_adapter.c index ad287dfc0ca8a9a9251d6046e3b742b18909878b..0203209a41b156b71efde67772f96374d253da18 100644 --- a/samgr_endpoint/source/samgr_small_ipc_adapter.c +++ b/samgr_endpoint/source/samgr_small_ipc_adapter.c @@ -18,8 +18,8 @@ typedef struct IRegisterEpArg IRegisterEpArg; struct IRegisterEpArg { Endpoint *endpoint; int token; - char *service; - char *feature; + const char *service; + const char *feature; }; static int Dispatch(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); static void HandleIpc(const Request *request, const Response *response); @@ -49,8 +49,9 @@ int ClientRegisterRemoteEndpoint(SvcIdentity *identity, int token, const char *s void *replyBuf = NULL; MessageOption option; MessageOptionInit(&option); - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { + usleep(RETRY_INTERVAL); continue; } int err = SendRequest(*samgr, INVALID_INDEX, &req, &reply, option, (uintptr_t *)&replyBuf); @@ -113,14 +114,13 @@ static void *Receive(void *argv) ret = registerEpArg->endpoint->registerEP(®isterEpArg->endpoint->identity, registerEpArg->token, registerEpArg->service, registerEpArg->feature); if (ret == EC_SUCCESS) { - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { - continue; + (void)RemoveDeathRecipient(*samgr, registerEpArg->endpoint->deadId); + (void)AddDeathRecipient(*samgr, OnSamgrServerExit, registerEpArg->endpoint, + ®isterEpArg->endpoint->deadId); + break; } - (void)RemoveDeathRecipient(*samgr, registerEpArg->endpoint->deadId); - (void)AddDeathRecipient(*samgr, OnSamgrServerExit, registerEpArg->endpoint, - ®isterEpArg->endpoint->deadId); - break; } ++retry; usleep(RETRY_INTERVAL); @@ -182,7 +182,7 @@ int RegisterIdentity(const SaName *saName, SvcIdentity *saInfo, PolicyTrans **po WriteUint32(&req, saInfo->token); IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 6970ae617ab92c86315ed9d6183b305d17fe0fa3..2f4a82cdf82b3465f232e76ee7d7e5e452cf2e7c 100644 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -674,9 +674,10 @@ static cJSON *GetJsonStream() struct stat fileInfo; int32_t size = 0; - if (stat(path, &fileInfo) != 0 || (size = fileInfo.st_size) == 0) { + if (stat(path, &fileInfo) != 0 || fileInfo.st_size == 0) { return NULL; } + size = fileInfo.st_size; int32_t fp = open(path, O_RDONLY, S_IRUSR); if (fp < 0) {