fix: iccarm编译修复

close: #I5JXMJ

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3fbaf459ad4807a44396f319a4d53d3cc1e7700c
This commit is contained in:
arvinzzz 2022-08-01 16:30:00 +08:00
parent 63bf098b0f
commit d0c50a4af0
26 changed files with 166 additions and 147 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -32,6 +32,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H #define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h" #include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -89,14 +89,14 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) { if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
errno = EFAULT; errno = EFAULT;
ret = LOS_NOK; ret = (int)LOS_NOK;
goto errout; goto errout;
} }
mountHdl = (lfs_t *)malloc(sizeof(lfs_t)); mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
if (mountHdl == NULL) { if (mountHdl == NULL) {
errno = ENODEV; errno = ENODEV;
ret = LOS_NOK; ret = (int)LOS_NOK;
goto errout; goto errout;
} }
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t)); (void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
@ -113,7 +113,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
if (ret != 0) { if (ret != 0) {
free(mountHdl); free(mountHdl);
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
errout: errout:
@ -126,18 +126,18 @@ int LfsUmount(struct MountPoint *mp)
if (mp == NULL) { if (mp == NULL) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_unmount((lfs_t *)mp->mData); ret = lfs_unmount((lfs_t *)mp->mData);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
free(mp->mData); free(mp->mData);
@ -151,18 +151,18 @@ int LfsUnlink(struct MountPoint *mp, const char *fileName)
if ((mp == NULL) || (fileName == NULL)) { if ((mp == NULL) || (fileName == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_remove((lfs_t *)mp->mData, fileName); ret = lfs_remove((lfs_t *)mp->mData, fileName);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
@ -174,12 +174,12 @@ int LfsMkdir(struct MountPoint *mp, const char *dirName)
if ((dirName == NULL) || (mp == NULL)) { if ((dirName == NULL) || (mp == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
lfs_t *lfs = (lfs_t *)mp->mData; lfs_t *lfs = (lfs_t *)mp->mData;
@ -187,7 +187,7 @@ int LfsMkdir(struct MountPoint *mp, const char *dirName)
ret = lfs_mkdir(lfs, dirName); ret = lfs_mkdir(lfs, dirName);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
@ -200,25 +200,25 @@ int LfsRmdir(struct MountPoint *mp, const char *dirName)
if (mp == NULL) { if (mp == NULL) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
lfs = (lfs_t *)mp->mData; lfs = (lfs_t *)mp->mData;
if (dirName == NULL) { if (dirName == NULL) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_remove(lfs, dirName); ret = lfs_remove(lfs, dirName);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
@ -230,14 +230,14 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) { if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
lfs_t *lfs = (lfs_t *)dir->dMp->mData; lfs_t *lfs = (lfs_t *)dir->dMp->mData;
lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t)); lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t));
if (dirInfo == NULL) { if (dirInfo == NULL) {
errno = ENOMEM; errno = ENOMEM;
return LOS_NOK; return (int)LOS_NOK;
} }
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t)); (void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
@ -254,7 +254,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
return LOS_OK; return LOS_OK;
errout: errout:
return LOS_NOK; return (int)LOS_NOK;
} }
int LfsReaddir(struct Dir *dir, struct dirent *dent) int LfsReaddir(struct Dir *dir, struct dirent *dent)
@ -265,12 +265,12 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL) || if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL) ||
(dent == NULL)) { (dent == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (dir->dData == NULL) { if (dir->dData == NULL) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
lfs_t *lfs = (lfs_t *)dir->dMp->mData; lfs_t *lfs = (lfs_t *)dir->dMp->mData;
@ -296,7 +296,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
} }
return LOS_NOK; return (int)LOS_NOK;
} }
int LfsClosedir(struct Dir *dir) int LfsClosedir(struct Dir *dir)
@ -305,12 +305,12 @@ int LfsClosedir(struct Dir *dir)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) { if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (dir->dData == NULL) { if (dir->dData == NULL) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
lfs_t *lfs = (lfs_t *)dir->dMp->mData; lfs_t *lfs = (lfs_t *)dir->dMp->mData;
@ -319,7 +319,7 @@ int LfsClosedir(struct Dir *dir)
ret = lfs_dir_close(lfs, dirInfo); ret = lfs_dir_close(lfs, dirInfo);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
free(dirInfo); free(dirInfo);
@ -336,13 +336,13 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
if ((pathName == NULL) || (file == NULL) || (file->fMp == NULL) || if ((pathName == NULL) || (file == NULL) || (file->fMp == NULL) ||
(file->fMp->mData == NULL)) { (file->fMp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t)); lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
if (lfsHandle == NULL) { if (lfsHandle == NULL) {
errno = ENOMEM; errno = ENOMEM;
return LOS_NOK; return (int)LOS_NOK;
} }
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag); int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
@ -368,25 +368,25 @@ int LfsRead(struct File *file, char *buf, size_t len)
if (buf == NULL) { if (buf == NULL) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if ((file == NULL) || (file->fData == NULL)) { if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
lfsHandle = (lfs_file_t *)file->fData; lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp; mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) { if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_file_read((lfs_t *)mp->mData, lfsHandle, buf, len); ret = lfs_file_read((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) { if (ret < 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
} }
@ -399,25 +399,25 @@ int LfsWrite(struct File *file, const char *buf, size_t len)
if (buf == NULL) { if (buf == NULL) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if ((file == NULL) || (file->fData == NULL)) { if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
lfsHandle = (lfs_file_t *)file->fData; lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp; mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) { if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_file_write((lfs_t *)mp->mData, lfsHandle, buf, len); ret = lfs_file_write((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) { if (ret < 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
} }
@ -430,20 +430,20 @@ off_t LfsSeek(struct File *file, off_t offset, int whence)
if ((file == NULL) || (file->fData == NULL)) { if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (off_t)LOS_NOK;
} }
lfsHandle = (lfs_file_t *)file->fData; lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp; mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) { if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (off_t)LOS_NOK;
} }
ret = (off_t)lfs_file_seek((lfs_t *)mp->mData, lfsHandle, offset, whence); ret = (off_t)lfs_file_seek((lfs_t *)mp->mData, lfsHandle, offset, whence);
if (ret < 0) { if (ret < 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (off_t)LOS_NOK;
} }
return ret; return ret;
@ -451,20 +451,20 @@ off_t LfsSeek(struct File *file, off_t offset, int whence)
int LfsClose(struct File *file) int LfsClose(struct File *file)
{ {
INT32 ret; int ret;
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL; lfs_file_t *lfsHandle = NULL;
if ((file == NULL) || (file->fData == NULL)) { if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
lfsHandle = (lfs_file_t *)file->fData; lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp; mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) { if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
pthread_mutex_lock(&g_FslocalMutex); pthread_mutex_lock(&g_FslocalMutex);
@ -473,7 +473,7 @@ int LfsClose(struct File *file)
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
free(file->fData); free(file->fData);
@ -487,18 +487,18 @@ int LfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
if ((mp == NULL) || (oldName == NULL) || (newName == NULL)) { if ((mp == NULL) || (oldName == NULL) || (newName == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_rename((lfs_t *)mp->mData, oldName, newName); ret = lfs_rename((lfs_t *)mp->mData, oldName, newName);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
@ -511,12 +511,12 @@ int LfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
if ((mp == NULL) || (path == NULL) || (buf == NULL)) { if ((mp == NULL) || (path == NULL) || (buf == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
if (mp->mData == NULL) { if (mp->mData == NULL) {
errno = ENOENT; errno = ENOENT;
return LOS_NOK; return (int)LOS_NOK;
} }
ret = lfs_stat((lfs_t *)mp->mData, path, &info); ret = lfs_stat((lfs_t *)mp->mData, path, &info);
@ -529,7 +529,7 @@ int LfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
} }
} else { } else {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
@ -542,19 +542,19 @@ int LfsSync(struct File *file)
if ((file == NULL) || (file->fData == NULL)) { if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF; errno = EBADF;
return LOS_NOK; return (int)LOS_NOK;
} }
if ((file->fMp == NULL) || (file->fMp->mData == NULL)) { if ((file->fMp == NULL) || (file->fMp->mData == NULL)) {
errno = EFAULT; errno = EFAULT;
return LOS_NOK; return (int)LOS_NOK;
} }
mp = file->fMp; mp = file->fMp;
ret = lfs_file_sync((lfs_t *)mp->mData, (lfs_file_t *)file->fData); ret = lfs_file_sync((lfs_t *)mp->mData, (lfs_file_t *)file->fData);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
} }

View File

@ -50,7 +50,9 @@ kernel_module(module_name) {
deps = [ "//kernel/liteos_m/kal" ] deps = [ "//kernel/liteos_m/kal" ]
configs += [ "$LITEOSTOPDIR:warn_config" ] configs += [ "$LITEOSTOPDIR:warn_config" ]
cflags = [ "-Wno-parentheses" ] if (!defined(LOSCFG_COMPILER_ICCARM)) {
cflags = [ "-Wno-parentheses" ]
}
} }
config("public") { config("public") {

View File

@ -42,7 +42,7 @@ static struct File g_files[NR_OPEN_DEFAULT];
int FileToFd(struct File *file) int FileToFd(struct File *file)
{ {
if (file == NULL) { if (file == NULL) {
return LOS_NOK; return (int)LOS_NOK;
} }
return file - g_files + MIN_START_FD; return file - g_files + MIN_START_FD;
} }

View File

@ -98,7 +98,7 @@ int VfsLock(void)
{ {
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) { if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("VfsLock failed!"); PRINT_ERR("VfsLock failed!");
return LOS_NOK; return (int)LOS_NOK;
} }
return LOS_OK; return LOS_OK;
@ -245,7 +245,7 @@ static int VfsOpen(const char *path, int flags)
VFS_ERRNO_SET(ENOMEM); VFS_ERRNO_SET(ENOMEM);
VfsFilePut(file); VfsFilePut(file);
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (int)LOS_NOK;
} }
file->fFlags = (UINT32)flags; file->fFlags = (UINT32)flags;
@ -319,7 +319,7 @@ static void VfsDetachFile(const struct File *file)
static int VfsClose(int fd) static int VfsClose(int fd)
{ {
struct File *file = NULL; struct File *file = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
file = VfsAttachFileWithStatus(fd, FILE_STATUS_CLOSING); file = VfsAttachFileWithStatus(fd, FILE_STATUS_CLOSING);
if (file == NULL) { if (file == NULL) {
@ -383,7 +383,7 @@ static ssize_t VfsRead(int fd, char *buff, size_t bytes)
static ssize_t VfsWrite(int fd, const void *buff, size_t bytes) static ssize_t VfsWrite(int fd, const void *buff, size_t bytes)
{ {
struct File *file = NULL; struct File *file = NULL;
ssize_t ret = LOS_NOK; ssize_t ret = (ssize_t)LOS_NOK;
if ((buff == NULL) || (bytes == 0)) { if ((buff == NULL) || (bytes == 0)) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
@ -412,7 +412,7 @@ static ssize_t VfsWrite(int fd, const void *buff, size_t bytes)
static off_t VfsLseek(int fd, off_t off, int whence) static off_t VfsLseek(int fd, off_t off, int whence)
{ {
struct File *file; struct File *file;
off_t ret = LOS_NOK; off_t ret = (off_t)LOS_NOK;
file = VfsAttachFileReady(fd); file = VfsAttachFileReady(fd);
if (file == NULL) { if (file == NULL) {
@ -434,7 +434,7 @@ static int VfsStat(const char *path, struct stat *stat)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
if ((path == NULL) || (stat == NULL)) { if ((path == NULL) || (stat == NULL)) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
@ -467,7 +467,7 @@ static int VfsStatfs(const char *path, struct statfs *buf)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
if ((path == NULL) || (buf == NULL)) { if ((path == NULL) || (buf == NULL)) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
@ -500,7 +500,7 @@ static int VfsUnlink(const char *path)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
if (path == NULL) { if (path == NULL) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
@ -532,7 +532,7 @@ static int VfsRename(const char *old, const char *new)
struct MountPoint *mpNew = NULL; struct MountPoint *mpNew = NULL;
const char *pathInMpOld = NULL; const char *pathInMpOld = NULL;
const char *pathInMpNew = NULL; const char *pathInMpNew = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
if ((old == NULL) || (new == NULL)) { if ((old == NULL) || (new == NULL)) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
@ -587,7 +587,7 @@ static int VfsIoctl(int fd, int func, ...)
va_list ap; va_list ap;
unsigned long arg; unsigned long arg;
struct File *file = NULL; struct File *file = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
va_start(ap, func); va_start(ap, func);
arg = va_arg(ap, unsigned long); arg = va_arg(ap, unsigned long);
@ -612,7 +612,7 @@ static int VfsIoctl(int fd, int func, ...)
static int VfsSync(int fd) static int VfsSync(int fd)
{ {
struct File *file; struct File *file;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
file = VfsAttachFileReady(fd); file = VfsAttachFileReady(fd);
if (file == NULL) { if (file == NULL) {
@ -724,7 +724,7 @@ static struct dirent *VfsReaddir(DIR *d)
static int VfsClosedir(DIR *d) static int VfsClosedir(DIR *d)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
struct Dir *dir = (struct Dir *)d; struct Dir *dir = (struct Dir *)d;
if ((dir == NULL) || (dir->dMp == NULL)) { if ((dir == NULL) || (dir->dMp == NULL)) {
@ -762,7 +762,7 @@ static int VfsMkdir(const char *path, int mode)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
(void)mode; (void)mode;
if (path == NULL) { if (path == NULL) {
@ -786,7 +786,7 @@ static int VfsMkdir(const char *path, int mode)
ret = mp->mFs->fsFops->mkdir(mp, pathInMp); ret = mp->mFs->fsFops->mkdir(mp, pathInMp);
} else { } else {
VFS_ERRNO_SET(ENOTSUP); VFS_ERRNO_SET(ENOTSUP);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
VfsUnlock(); VfsUnlock();
@ -823,7 +823,7 @@ static ssize_t VfsPread(int fd, void *buff, size_t bytes, off_t off)
if (buff == NULL) { if (buff == NULL) {
VFS_ERRNO_SET(EFAULT); VFS_ERRNO_SET(EFAULT);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
if (bytes == 0) { if (bytes == 0) {
@ -832,26 +832,26 @@ static ssize_t VfsPread(int fd, void *buff, size_t bytes, off_t off)
if (VfsLock() != LOS_OK) { if (VfsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN); VFS_ERRNO_SET(EAGAIN);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
savepos = LOS_Lseek(fd, 0, SEEK_CUR); savepos = LOS_Lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) { if (savepos == (off_t)-1) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
pos = LOS_Lseek(fd, off, SEEK_SET); pos = LOS_Lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) { if (pos == (off_t)-1) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
ret = LOS_Read(fd, buff, bytes); ret = LOS_Read(fd, buff, bytes);
pos = LOS_Lseek(fd, savepos, SEEK_SET); pos = LOS_Lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) { if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
VfsUnlock(); VfsUnlock();
@ -865,7 +865,7 @@ static ssize_t VfsPwrite(int fd, const void *buff, size_t bytes, off_t off)
if (buff == NULL) { if (buff == NULL) {
VFS_ERRNO_SET(EFAULT); VFS_ERRNO_SET(EFAULT);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
if (bytes == 0) { if (bytes == 0) {
@ -874,26 +874,26 @@ static ssize_t VfsPwrite(int fd, const void *buff, size_t bytes, off_t off)
if (VfsLock() != LOS_OK) { if (VfsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN); VFS_ERRNO_SET(EAGAIN);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
savepos = LOS_Lseek(fd, 0, SEEK_CUR); savepos = LOS_Lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) { if (savepos == (off_t)-1) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
pos = LOS_Lseek(fd, off, SEEK_SET); pos = LOS_Lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) { if (pos == (off_t)-1) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
ret = LOS_Write(fd, buff, bytes); ret = LOS_Write(fd, buff, bytes);
pos = LOS_Lseek(fd, savepos, SEEK_SET); pos = LOS_Lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) { if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
VfsUnlock(); VfsUnlock();
@ -912,35 +912,35 @@ int LOS_Open(const char *path, int flags, ...)
unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY; unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
if ((unsigned)flags & ~flagMask) { if ((unsigned)flags & ~flagMask) {
errno = EINVAL; errno = EINVAL;
return LOS_NOK; return (int)LOS_NOK;
} }
size_t pathLen = strlen(path) + 1; size_t pathLen = strlen(path) + 1;
if ((unsigned)pathLen > PATH_MAX) { if ((unsigned)pathLen > PATH_MAX) {
errno = EINVAL; errno = EINVAL;
return LOS_NOK; return (int)LOS_NOK;
} }
char *canonicalPath = (char *)malloc(pathLen); char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) { if (!canonicalPath) {
errno = ENOMEM; errno = ENOMEM;
return LOS_NOK; return (int)LOS_NOK;
} }
if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) { if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) {
FREE_AND_SET_NULL(canonicalPath); FREE_AND_SET_NULL(canonicalPath);
errno = ENOMEM; errno = ENOMEM;
return LOS_NOK; return (int)LOS_NOK;
} }
if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) { if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) {
FREE_AND_SET_NULL(canonicalPath); FREE_AND_SET_NULL(canonicalPath);
if ((O_ACCMODE & (unsigned)flags) != O_RDONLY) { if ((O_ACCMODE & (unsigned)flags) != O_RDONLY) {
errno = EPERM; errno = EPERM;
return LOS_NOK; return (int)LOS_NOK;
} }
if ((unsigned)flags & O_DIRECTORY) { if ((unsigned)flags & O_DIRECTORY) {
errno = ENOTDIR; errno = ENOTDIR;
return LOS_NOK; return (int)LOS_NOK;
} }
return RANDOM_DEV_FD; return RANDOM_DEV_FD;
} }
@ -949,10 +949,10 @@ int LOS_Open(const char *path, int flags, ...)
FREE_AND_SET_NULL(canonicalPath); FREE_AND_SET_NULL(canonicalPath);
if ((unsigned)flags & O_DIRECTORY) { if ((unsigned)flags & O_DIRECTORY) {
errno = EPERM; errno = EPERM;
return LOS_NOK; return (int)LOS_NOK;
} }
errno = EISDIR; errno = EISDIR;
return LOS_NOK; return (int)LOS_NOK;
} }
FREE_AND_SET_NULL(canonicalPath); FREE_AND_SET_NULL(canonicalPath);
#endif #endif
@ -984,7 +984,7 @@ int LOS_Close(int fd)
} }
#endif #endif
int ret = LOS_NOK; int ret = (int)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsClose(fd); ret = VfsClose(fd);
} }
@ -1025,7 +1025,7 @@ ssize_t LOS_Read(int fd, void *buff, size_t bytes)
} }
#endif #endif
ssize_t ret = LOS_NOK; ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsRead(fd, buff, bytes); ret = VfsRead(fd, buff, bytes);
} }
@ -1038,7 +1038,7 @@ ssize_t LOS_Write(int fd, const void *buff, size_t bytes)
#ifdef LOSCFG_RANDOM_DEV #ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) { if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */ errno = EBADF; /* "/dev/random" is readonly */
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
#endif #endif
#ifdef LOSCFG_NET_LWIP_SACK #ifdef LOSCFG_NET_LWIP_SACK
@ -1054,7 +1054,7 @@ ssize_t LOS_Write(int fd, const void *buff, size_t bytes)
} }
#endif #endif
ssize_t ret = LOS_NOK; ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsWrite(fd, buff, bytes); ret = VfsWrite(fd, buff, bytes);
} }
@ -1137,7 +1137,7 @@ int LOS_Fstat(int fd, struct stat *buf)
int ret; int ret;
filep = VfsAttachFileReady(fd); filep = VfsAttachFileReady(fd);
if ((filep == NULL) || (filep->fMp == NULL) || filep->fullPath == NULL) { if ((filep == NULL) || (filep->fMp == NULL) || filep->fullPath == NULL) {
return LOS_NOK; return (int)LOS_NOK;
} }
ret = stat(filep->fullPath, buf); ret = stat(filep->fullPath, buf);
VfsDetachFile(filep); VfsDetachFile(filep);
@ -1169,7 +1169,7 @@ int LOS_Fcntl(int fd, int cmd, ...)
if (ret < 0) { if (ret < 0) {
VFS_ERRNO_SET(-ret); VFS_ERRNO_SET(-ret);
ret = LOS_NOK; ret = (int)LOS_NOK;
} }
return ret; return ret;
} }
@ -1207,22 +1207,22 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
const struct iovec *iov = (const struct iovec *)iovBuf; const struct iovec *iov = (const struct iovec *)iovBuf;
if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) { if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
for (i = 0; i < iovcnt; ++i) { for (i = 0; i < iovcnt; ++i) {
if ((SSIZE_MAX - bufLen) < iov[i].iov_len) { if ((SSIZE_MAX - bufLen) < iov[i].iov_len) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
bufLen += iov[i].iov_len; bufLen += iov[i].iov_len;
} }
if (bufLen == 0) { if (bufLen == 0) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
totalLen = bufLen * sizeof(char); totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen); buf = (char *)malloc(totalLen);
if (buf == NULL) { if (buf == NULL) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
totalBytesRead = read(fd, buf, bufLen); totalBytesRead = read(fd, buf, bufLen);
@ -1238,7 +1238,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead); ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead);
if (ret != EOK) { if (ret != EOK) {
free(buf); free(buf);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
if (totalLen < (size_t)bytesToRead) { if (totalLen < (size_t)bytesToRead) {
break; break;
@ -1264,23 +1264,23 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
const struct iovec *iov = iovBuf; const struct iovec *iov = iovBuf;
if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) { if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
for (i = 0; i < iovcnt; ++i) { for (i = 0; i < iovcnt; ++i) {
if ((SSIZE_MAX - bufLen) < iov[i].iov_len) { if ((SSIZE_MAX - bufLen) < iov[i].iov_len) {
VFS_ERRNO_SET(EINVAL); VFS_ERRNO_SET(EINVAL);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
bufLen += iov[i].iov_len; bufLen += iov[i].iov_len;
} }
if (bufLen == 0) { if (bufLen == 0) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
totalLen = bufLen * sizeof(char); totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen); buf = (char *)malloc(totalLen);
if (buf == NULL) { if (buf == NULL) {
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
curBuf = buf; curBuf = buf;
for (i = 0; i < iovcnt; ++i) { for (i = 0; i < iovcnt; ++i) {
@ -1292,7 +1292,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
ret = memcpy_s(curBuf, totalLen, writeBuf, bytesToWrite); ret = memcpy_s(curBuf, totalLen, writeBuf, bytesToWrite);
if (ret != EOK) { if (ret != EOK) {
free(buf); free(buf);
return LOS_NOK; return (ssize_t)LOS_NOK;
} }
curBuf += bytesToWrite; curBuf += bytesToWrite;
totalLen -= bytesToWrite; totalLen -= bytesToWrite;
@ -1318,26 +1318,26 @@ int LOS_Access(const char *path, int amode)
result = stat(path, &buf); result = stat(path, &buf);
if (result != 0) { if (result != 0) {
return LOS_NOK; return (int)LOS_NOK;
} }
mode = buf.st_mode; mode = buf.st_mode;
if ((unsigned int)amode & R_OK) { if ((unsigned int)amode & R_OK) {
if ((mode & (S_IROTH | S_IRGRP | S_IRUSR)) == 0) { if ((mode & (S_IROTH | S_IRGRP | S_IRUSR)) == 0) {
VFS_ERRNO_SET(EACCES); VFS_ERRNO_SET(EACCES);
return LOS_NOK; return (int)LOS_NOK;
} }
} }
if ((unsigned int)amode & W_OK) { if ((unsigned int)amode & W_OK) {
if ((mode & (S_IWOTH | S_IWGRP | S_IWUSR)) == 0) { if ((mode & (S_IWOTH | S_IWGRP | S_IWUSR)) == 0) {
VFS_ERRNO_SET(EACCES); VFS_ERRNO_SET(EACCES);
return LOS_NOK; return (int)LOS_NOK;
} }
} }
if ((unsigned int)amode & X_OK) { if ((unsigned int)amode & X_OK) {
if ((mode & (S_IXOTH | S_IXGRP | S_IXUSR)) == 0) { if ((mode & (S_IXOTH | S_IXGRP | S_IXUSR)) == 0) {
VFS_ERRNO_SET(EACCES); VFS_ERRNO_SET(EACCES);
return LOS_NOK; return (int)LOS_NOK;
} }
} }
return 0; return 0;
@ -1345,7 +1345,7 @@ int LOS_Access(const char *path, int amode)
int LOS_Ftruncate(int fd, off_t length) int LOS_Ftruncate(int fd, off_t length)
{ {
int ret = LOS_NOK; int ret = (int)LOS_NOK;
struct File *file = NULL; struct File *file = NULL;
if (length <= 0) { if (length <= 0) {
@ -1379,7 +1379,7 @@ int LOS_Ftruncate(int fd, off_t length)
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off) ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off)
{ {
ssize_t ret = LOS_NOK; ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsPread(fd, buff, bytes, off); ret = VfsPread(fd, buff, bytes, off);
} }
@ -1389,7 +1389,7 @@ ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off)
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off) ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off)
{ {
ssize_t ret = LOS_NOK; ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) { if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsPwrite(fd, buff, bytes, off); ret = VfsPwrite(fd, buff, bytes, off);
} }

View File

@ -41,7 +41,7 @@
int OsVfsInit(void) int OsVfsInit(void)
{ {
if (LOS_MuxCreate(&g_fsMutex) != LOS_OK) { if (LOS_MuxCreate(&g_fsMutex) != LOS_OK) {
return LOS_NOK; return (int)LOS_NOK;
} }
#if (LOSCFG_SUPPORT_FATFS == 1) #if (LOSCFG_SUPPORT_FATFS == 1)
FatFsInit(); FatFsInit();

View File

@ -57,20 +57,20 @@ int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt) struct FileOps *fsFops, struct FsManagement *fsMgt)
{ {
if ((fsMops == NULL) || (fsFops == NULL)) { if ((fsMops == NULL) || (fsFops == NULL)) {
return LOS_NOK; return (int)LOS_NOK;
} }
struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap)); struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap));
if (newfs == NULL) { if (newfs == NULL) {
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType); PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
return LOS_NOK; return (int)LOS_NOK;
} }
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap)); (void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
newfs->fsType = strdup(fsType); newfs->fsType = strdup(fsType);
if (newfs->fsType == NULL) { if (newfs->fsType == NULL) {
free(newfs); free(newfs);
return LOS_NOK; return (int)LOS_NOK;
} }
newfs->fsMops = fsMops; newfs->fsMops = fsMops;

View File

@ -128,11 +128,12 @@ int LOS_FsMount(const char *source, const char *target,
{ {
int ret; int ret;
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
struct FsMap *mFs = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
/* target must begin with '/', for example /system, /data, etc. */ /* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) { if ((target == NULL) || (target[0] != '/')) {
return LOS_NOK; return (int)LOS_NOK;
} }
(void)VfsLock(); (void)VfsLock();
@ -143,9 +144,8 @@ int LOS_FsMount(const char *source, const char *target,
} }
/* Find fsMap coresponding to the fsType */ /* Find fsMap coresponding to the fsType */
struct FsMap *mFs = VfsFsMapGet(fsType); mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
(mFs->fsMops->mount == NULL)) {
goto errout; goto errout;
} }
@ -187,14 +187,14 @@ errout:
free((void *)mp->mDev); free((void *)mp->mDev);
free(mp); free(mp);
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (int)LOS_NOK;
} }
int LOS_FsUmount(const char *target) int LOS_FsUmount(const char *target)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
(void)VfsLock(); (void)VfsLock();
if (target == NULL) { if (target == NULL) {
@ -230,7 +230,7 @@ int LOS_FsUmount(const char *target)
errout: errout:
PRINT_ERR("umount2 failed, target %s.\n", target); PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (int)LOS_NOK;
} }
static void CloseFdsInMp(struct MountPoint *mp) static void CloseFdsInMp(struct MountPoint *mp)
@ -252,7 +252,7 @@ int LOS_FsUmount2(const char *target, int flag)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
int ret = LOS_NOK; int ret = (int)LOS_NOK;
(void)VfsLock(); (void)VfsLock();
if (target == NULL) { if (target == NULL) {
@ -290,5 +290,5 @@ int LOS_FsUmount2(const char *target, int flag)
errout: errout:
PRINT_ERR("umount2 failed, target %s.\n", target); PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock(); VfsUnlock();
return LOS_NOK; return (int)LOS_NOK;
} }

View File

@ -40,7 +40,7 @@
int GetPartIdByPartName(const char *partName) int GetPartIdByPartName(const char *partName)
{ {
if (partName == NULL) { if (partName == NULL) {
return LOS_NOK; return (int)LOS_NOK;
} }
/* the character next to p is the partId */ /* the character next to p is the partId */
@ -49,13 +49,13 @@ int GetPartIdByPartName(const char *partName)
return atoi(p + 1); return atoi(p + 1);
} }
return LOS_NOK; return (int)LOS_NOK;
} }
int GetDevIdByDevName(const char *dev) int GetDevIdByDevName(const char *dev)
{ {
if (dev == NULL) { if (dev == NULL) {
return LOS_NOK; return (int)LOS_NOK;
} }
/* last character is the deviceId */ /* last character is the deviceId */
@ -64,13 +64,13 @@ int GetDevIdByDevName(const char *dev)
return atoi(p); return atoi(p);
} }
return LOS_NOK; return (int)LOS_NOK;
} }
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
int partnum) int partnum)
{ {
int ret = LOS_NOK; int ret = (int)LOS_NOK;
struct FsMap *fMap = VfsFsMapGet(fsType); struct FsMap *fMap = VfsFsMapGet(fsType);
if ((fMap != NULL) && (fMap->fsMgt != NULL) && if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
(fMap->fsMgt->fdisk != NULL)) { (fMap->fsMgt->fdisk != NULL)) {
@ -82,7 +82,7 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
int LOS_PartitionFormat(const char *partName, char *fsType, void *data) int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
{ {
int ret = LOS_NOK; int ret = (int)LOS_NOK;
/* check if the device is mounted by iterate the mp list /* check if the device is mounted by iterate the mp list
format is not allowed when the device has been mounted. */ format is not allowed when the device has been mounted. */
@ -91,7 +91,7 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) && if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
strcmp(iter->mFs->fsType, fsType) == 0) { strcmp(iter->mFs->fsType, fsType) == 0) {
errno = EBUSY; errno = EBUSY;
return LOS_NOK; return (int)LOS_NOK;
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -209,7 +209,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeoutMs)
{ {
if (mbox == NULL) { if (mbox == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_fetch: mbox is null")); LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_fetch: mbox is null"));
return ERR_ARG; return (u32_t)ERR_ARG;
} }
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */ void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
@ -232,7 +232,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
{ {
if (mbox == NULL) { if (mbox == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_tryfetch: mbox is null")); LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_tryfetch: mbox is null"));
return ERR_ARG; return (u32_t)ERR_ARG;
} }
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */ void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
@ -313,7 +313,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeoutMs)
{ {
if (sem == NULL) { if (sem == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_sem_wait: sem is null")); LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_sem_wait: sem is null"));
return ERR_ARG; return (u32_t)ERR_ARG;
} }
UINT64 tick = ROUND_UP_DIV((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND, OS_SYS_MS_PER_SECOND); UINT64 tick = ROUND_UP_DIV((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND, OS_SYS_MS_PER_SECOND);