fix: compile warnings

1, function prototypes: LfsSeek, LfsCloseDir
2, fix some other minor warnings and remove some while spaces

close: #I3Y57X
Signed-off-by: Leon Chan <chenwei26@huawei.com>
Change-Id: Id8b77c8a6b2e8d2b9bc5f02e22bfc6a15d70f648
This commit is contained in:
Leon Chan 2021-06-28 15:19:29 +08:00
parent 59225cb6df
commit 75f61870a0
2 changed files with 16 additions and 15 deletions

View File

@ -32,6 +32,7 @@
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include "lfs_api.h" #include "lfs_api.h"
#include "los_config.h" #include "los_config.h"
#include "securec.h"
lfs_t g_lfs; lfs_t g_lfs;
FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0}; FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
@ -64,7 +65,7 @@ static void LfsFreeFd(int fd)
pthread_mutex_lock(&g_FslocalMutex); pthread_mutex_lock(&g_FslocalMutex);
g_handle[fd].useFlag = 0; g_handle[fd].useFlag = 0;
if (g_handle[fd].pathName != NULL) { if (g_handle[fd].pathName != NULL) {
free(g_handle[fd].pathName); free((void *)g_handle[fd].pathName);
g_handle[fd].pathName = NULL; g_handle[fd].pathName = NULL;
} }
@ -168,7 +169,7 @@ BOOL CheckPathIsMounted(const char *pathName, struct FileOpInfo **fileOpInfo)
return FALSE; return FALSE;
} }
struct FileOpInfo *AllocMountRes(const char* target, struct FileOps *fileOps) struct FileOpInfo *AllocMountRes(const char* target, const struct FileOps *fileOps)
{ {
pthread_mutex_lock(&g_FslocalMutex); pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
@ -571,7 +572,7 @@ struct dirent *LfsReaddir(DIR *dir)
return NULL; return NULL;
} }
int LfsClosedir(const DIR *dir) int LfsClosedir(DIR *dir)
{ {
int ret; int ret;
FileDirInfo *dirInfo = (FileDirInfo *)dir; FileDirInfo *dirInfo = (FileDirInfo *)dir;
@ -674,9 +675,9 @@ int LfsWrite(int fd, const void *buf, unsigned int len)
return ret; return ret;
} }
int LfsSeek(int fd, off_t offset, int whence) off_t LfsSeek(int fd, off_t offset, int whence)
{ {
int ret; off_t ret;
if (fd >= LITTLE_FS_MAX_OPEN_FILES || fd < 0) { if (fd >= LITTLE_FS_MAX_OPEN_FILES || fd < 0) {
errno = EFAULT; errno = EFAULT;
return VFS_ERROR; return VFS_ERROR;
@ -687,7 +688,7 @@ int LfsSeek(int fd, off_t offset, int whence)
return VFS_ERROR; return VFS_ERROR;
} }
ret = lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, whence); ret = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, whence);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
} }

View File

@ -65,7 +65,7 @@ typedef struct {
struct FileOpInfo { struct FileOpInfo {
uint8_t useFlag; uint8_t useFlag;
struct FileOps *fsVops; const struct FileOps *fsVops;
char *dirName; char *dirName;
lfs_t lfsInfo; lfs_t lfsInfo;
}; };
@ -103,11 +103,11 @@ int LfsMkdir(const char *dirName, mode_t mode);
int LfsRmdir(const char *dirName); int LfsRmdir(const char *dirName);
DIR *LfsOpendir(const char *dirName); DIR *LfsOpendir(const char *dirName);
struct dirent *LfsReaddir(DIR *dir); struct dirent *LfsReaddir(DIR *dir);
int LfsClosedir(const DIR *dir); int LfsClosedir(DIR *dir);
int LfsOpen(const char *pathName, int openFlag, int mode); int LfsOpen(const char *pathName, int openFlag, int mode);
int LfsRead(int fd, void *buf, unsigned int len); int LfsRead(int fd, void *buf, unsigned int len);
int LfsWrite(int fd, const void *buf, unsigned int len); int LfsWrite(int fd, const void *buf, unsigned int len);
int LfsSeek(int fd, off_t offset, int whence); off_t LfsSeek(int fd, off_t offset, int whence);
int LfsClose(int fd); int LfsClose(int fd);
int LfsRename(const char *oldName, const char *newName); int LfsRename(const char *oldName, const char *newName);
int LfsStat(const char *path, struct stat *buf); int LfsStat(const char *path, struct stat *buf);