提交 987a722d 编写于 作者: F Far

fix: 修复一些静态检查工具发现的问题

Signed-off-by: NFar <yesiyuan2@huawei.com>
Change-Id: I2b93259d55a9eb1a9dfd5887fd7821c15274bb7f
上级 ccdfa724
...@@ -780,7 +780,6 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen) ...@@ -780,7 +780,6 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen; cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen;
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) { if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
cnt = 0;
LOS_MuxUnlock(&g_jffs2FsLock); LOS_MuxUnlock(&g_jffs2FsLock);
return -EFAULT; return -EFAULT;
} }
......
...@@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = { ...@@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = {
.unlink = ErrorFopUnlink, .unlink = ErrorFopUnlink,
}; };
static struct Mount* GetDevMountPoint(struct Vnode *dev) static struct Mount* GetDevMountPoint(const struct Vnode *dev)
{ {
struct Mount *mnt = NULL; struct Mount *mnt = NULL;
LIST_HEAD *mntList = GetMountList(); LIST_HEAD *mntList = GetMountList();
...@@ -394,7 +394,7 @@ static void FilePreClose(struct file *filep, const struct file_operations_vfs *o ...@@ -394,7 +394,7 @@ static void FilePreClose(struct file *filep, const struct file_operations_vfs *o
} }
} }
static void FileDisableAndClean(struct Mount *mnt) static void FileDisableAndClean(const struct Mount *mnt)
{ {
struct filelist *flist = &tg_filelist; struct filelist *flist = &tg_filelist;
struct file *filep = NULL; struct file *filep = NULL;
...@@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode) ...@@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode)
vnode->fop = &g_errorFileOps; vnode->fop = &g_errorFileOps;
} }
static void VnodeTryFreeAll(struct Mount *mount) static void VnodeTryFreeAll(const struct Mount *mount)
{ {
struct Vnode *vnode = NULL; struct Vnode *vnode = NULL;
struct Vnode *nextVnode = NULL; struct Vnode *nextVnode = NULL;
......
...@@ -66,7 +66,6 @@ static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov ...@@ -66,7 +66,6 @@ static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov
} else { } else {
writepart = bytestowrite - ret; writepart = bytestowrite - ret;
curbuf += writepart; curbuf += writepart;
totallen -= writepart;
break; break;
} }
} }
......
...@@ -70,7 +70,7 @@ VOID OsVmPhysDump(VOID); ...@@ -70,7 +70,7 @@ VOID OsVmPhysDump(VOID);
VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount); VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount);
INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region); INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region);
VOID OsDumpPte(VADDR_T vaddr); VOID OsDumpPte(VADDR_T vaddr);
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space); LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space);
CHAR *OsArchFlagsToStr(const UINT32 archFlags); CHAR *OsArchFlagsToStr(const UINT32 archFlags);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -193,7 +193,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB); ...@@ -193,7 +193,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB);
LosFilePage *OsPageCacheAlloc(struct page_mapping *mapping, VM_OFFSET_T pgoff); LosFilePage *OsPageCacheAlloc(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosFilePage *OsFindGetEntry(struct page_mapping *mapping, VM_OFFSET_T pgoff); LosFilePage *OsFindGetEntry(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr); LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr); VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty); VOID OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty);
VOID OsFileCacheFlush(struct page_mapping *mapping); VOID OsFileCacheFlush(struct page_mapping *mapping);
...@@ -208,7 +208,7 @@ VOID OsDeletePageCacheLru(LosFilePage *page); ...@@ -208,7 +208,7 @@ VOID OsDeletePageCacheLru(LosFilePage *page);
VOID OsPageRefDecNoLock(LosFilePage *page); VOID OsPageRefDecNoLock(LosFilePage *page);
VOID OsPageRefIncLocked(LosFilePage *page); VOID OsPageRefIncLocked(LosFilePage *page);
int OsTryShrinkMemory(size_t nPage); int OsTryShrinkMemory(size_t nPage);
VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, int off, int len); VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, int off, int len);
#ifdef LOSCFG_DEBUG_VERSION #ifdef LOSCFG_DEBUG_VERSION
VOID ResetPageCacheHitInfo(int *try, int *hit); VOID ResetPageCacheHitInfo(int *try, int *hit);
......
...@@ -96,7 +96,7 @@ UINT32 LOS_RwlockDestroy(LosRwlock *rwlock) ...@@ -96,7 +96,7 @@ UINT32 LOS_RwlockDestroy(LosRwlock *rwlock)
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 OsRwlockCheck(LosRwlock *rwlock) STATIC UINT32 OsRwlockCheck(const LosRwlock *rwlock)
{ {
if (rwlock == NULL) { if (rwlock == NULL) {
return LOS_EINVAL; return LOS_EINVAL;
......
...@@ -78,7 +78,6 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo) ...@@ -78,7 +78,6 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
/* delete tmpinfo from tmpList. */ /* delete tmpinfo from tmpList. */
*prevHook = tmpInfoNode->next; *prevHook = tmpInfoNode->next;
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode); (VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
tmpInfoNode = *prevHook;
break; break;
} }
prevHook = &tmpInfoNode->next; prevHook = &tmpInfoNode->next;
......
...@@ -918,7 +918,7 @@ STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size) ...@@ -918,7 +918,7 @@ STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size)
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 OsMemPoolDelete(VOID *pool) STATIC UINT32 OsMemPoolDelete(const VOID *pool)
{ {
UINT32 ret = LOS_NOK; UINT32 ret = LOS_NOK;
VOID *nextPool = NULL; VOID *nextPool = NULL;
......
...@@ -253,7 +253,7 @@ UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm) ...@@ -253,7 +253,7 @@ UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
return pmSize; return pmSize;
} }
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space) LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space)
{ {
UINT32 pid; UINT32 pid;
UINT32 intSave; UINT32 intSave;
......
...@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr) ...@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
page->n_maps++; page->n_maps++;
} }
LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr) LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr)
{ {
LosMapInfo *info = NULL; LosMapInfo *info = NULL;
LOS_DL_LIST *immap = &page->i_mmap; const LOS_DL_LIST *immap = &page->i_mmap;
LOS_DL_LIST_FOR_EACH_ENTRY(info, immap, LosMapInfo, node) { LOS_DL_LIST_FOR_EACH_ENTRY(info, immap, LosMapInfo, node) {
if ((info->archMmu == archMmu) && (info->vaddr == vaddr) && (info->page == page)) { if ((info->archMmu == archMmu) && (info->vaddr == vaddr) && (info->page == page)) {
...@@ -214,7 +214,7 @@ VOID OsVmmFileRemove(LosVmMapRegion *region, LosArchMmu *archMmu, VM_OFFSET_T pg ...@@ -214,7 +214,7 @@ VOID OsVmmFileRemove(LosVmMapRegion *region, LosArchMmu *archMmu, VM_OFFSET_T pg
return; return;
} }
VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, INT32 off, INT32 len) VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, INT32 off, INT32 len)
{ {
if (region != NULL) { if (region != NULL) {
OsSetPageDirty(fpage->vmPage); OsSetPageDirty(fpage->vmPage);
......
...@@ -233,7 +233,7 @@ LosVmSpace *OsCreateUserVmSpace(VOID) ...@@ -233,7 +233,7 @@ LosVmSpace *OsCreateUserVmSpace(VOID)
return space; return space;
} }
STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace) STATIC BOOL OsVmSpaceParamCheck(const LosVmSpace *vmSpace)
{ {
if (vmSpace == NULL) { if (vmSpace == NULL) {
return FALSE; return FALSE;
......
...@@ -289,7 +289,7 @@ STATIC UINT32 OsPerfCollectData(Event *event, PerfSampleData *data, PerfRegs *re ...@@ -289,7 +289,7 @@ STATIC UINT32 OsPerfCollectData(Event *event, PerfSampleData *data, PerfRegs *re
* return TRUE if user haven't specified any taskId(which is supposed * return TRUE if user haven't specified any taskId(which is supposed
* to instrument the whole system) * to instrument the whole system)
*/ */
STATIC INLINE BOOL OsFilterId(UINT32 id, UINT32 *ids, UINT8 idsNr) STATIC INLINE BOOL OsFilterId(UINT32 id, const UINT32 *ids, UINT8 idsNr)
{ {
UINT32 i; UINT32 i;
if (!idsNr) { if (!idsNr) {
......
...@@ -300,7 +300,7 @@ UINT32 LOS_PmRegister(LOS_PmNodeType type, VOID *node) ...@@ -300,7 +300,7 @@ UINT32 LOS_PmRegister(LOS_PmNodeType type, VOID *node)
return LOS_EINVAL; return LOS_EINVAL;
} }
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, LosPmDevice *device) STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, const LosPmDevice *device)
{ {
LOS_SpinLock(&g_pmSpin); LOS_SpinLock(&g_pmSpin);
if (pm->device == device) { if (pm->device == device) {
......
...@@ -116,8 +116,8 @@ static UINT16 GetFreeVid(VOID) ...@@ -116,8 +116,8 @@ static UINT16 GetFreeVid(VOID)
for (i = 0; i < mapMaxNum; i++) { for (i = 0; i < mapMaxNum; i++) {
num = idMap->bitMap[i]; num = idMap->bitMap[i];
for (j = 0; j < INT_BIT_COUNT; j++) { for (j = 0; j < INT_BIT_COUNT; j++) {
if ((num & (1 << j)) == 0) { if ((num & (1U << j)) == 0) {
num |= 1 << j; num |= 1U << j;
idMap->bitMap[i] = num; idMap->bitMap[i] = num;
return (INT_BIT_COUNT * i + j); return (INT_BIT_COUNT * i + j);
} }
......
...@@ -49,13 +49,13 @@ static VOID NestingPrioHigh(INT32 irq, VOID *data) ...@@ -49,13 +49,13 @@ static VOID NestingPrioHigh(INT32 irq, VOID *data)
UINT64 curTime; UINT64 curTime;
curTime = LOS_CurrNanosec(); curTime = LOS_CurrNanosec();
g_recordTime[g_saveIndex] = curTime - g_intPendTime; g_recordTime[g_saveIndex] = curTime - g_intPendTime;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime); dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime);
dprintf("%lld\n", curTime - g_intPendTime); dprintf("%lld\n", curTime - g_intPendTime);
dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]); dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]);
g_saveIndex++; g_saveIndex++;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
} }
static VOID DumpResult() static VOID DumpResult()
......
...@@ -76,7 +76,7 @@ static void Task01(void) ...@@ -76,7 +76,7 @@ static void Task01(void)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2); ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ret = memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); ret = memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2; ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04; taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04;
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
taskInitParam.pcName = "SmpCpup005_task04"; taskInitParam.pcName = "SmpCpup005_task04";
......
...@@ -65,7 +65,7 @@ static int GetHostByAddrTest(void) ...@@ -65,7 +65,7 @@ static int GetHostByAddrTest(void)
addr = gethostbyaddr(&ia, sizeof ia, AF_INET); addr = gethostbyaddr(&ia, sizeof ia, AF_INET);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
    RecoveryFileEnv(pathList, file_number); RecoveryFileEnv(pathList, file_number);
return ICUNIT_SUCCESS; return ICUNIT_SUCCESS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册