Match-id-2a905d507cbceee439b94e4b2f4958654603e555

This commit is contained in:
BianTanggui
2022-05-16 18:12:18 +08:00
parent cc8c89e6ad
commit 14bf63b920
2 changed files with 7 additions and 5 deletions

View File

@@ -87,6 +87,10 @@ static bool PidCmdArgParser(struct CmdArgs *args, const char *arg)
FILE* pFile = NULL; FILE* pFile = NULL;
pFile = fopen(pidMax, "r"); pFile = fopen(pidMax, "r");
if ((pFile == NULL) || (fgets(buff, PATH_MAX, pFile) == NULL)) { if ((pFile == NULL) || (fgets(buff, PATH_MAX, pFile) == NULL)) {
if (pFile != NULL) {
(void)fclose(pFile);
}
pFile = NULL;
Logger("failed to get pid_max buff.", LEVEL_ERROR, SCREEN_YES); Logger("failed to get pid_max buff.", LEVEL_ERROR, SCREEN_YES);
return false; return false;
} }
@@ -218,7 +222,7 @@ static bool MountFileCmdArgParser(struct CmdArgs *args, const char *arg)
char* str = FormatLogMessage("too many files to mount, max number is %u", MAX_MOUNT_NR); char* str = FormatLogMessage("too many files to mount, max number is %u", MAX_MOUNT_NR);
Logger(str, LEVEL_ERROR, SCREEN_YES); Logger(str, LEVEL_ERROR, SCREEN_YES);
free(str); free(str);
return -1; return false;
} }
char *dst = &args->files.list[args->files.count++][0]; char *dst = &args->files.list[args->files.count++][0];
@@ -252,7 +256,7 @@ static bool MountDirCmdArgParser(struct CmdArgs *args, const char *arg)
char* str = FormatLogMessage("too many directories to mount, max number is %u", MAX_MOUNT_NR); char* str = FormatLogMessage("too many directories to mount, max number is %u", MAX_MOUNT_NR);
Logger(str, LEVEL_ERROR, SCREEN_YES); Logger(str, LEVEL_ERROR, SCREEN_YES);
free(str); free(str);
return -1; return false;
} }
char *dst = &args->dirs.list[args->dirs.count++][0]; char *dst = &args->dirs.list[args->dirs.count++][0];

View File

@@ -117,7 +117,6 @@ static int GetDeviceMntSrcDst(const char *rootfs, const char *srcDeviceName,
int MountDevice(const char *rootfs, const char *srcDeviceName, const char *dstDeviceName) int MountDevice(const char *rootfs, const char *srcDeviceName, const char *dstDeviceName)
{ {
int ret; int ret;
char *str = NULL;
char src[BUF_SIZE] = {0}; char src[BUF_SIZE] = {0};
char dst[BUF_SIZE] = {0}; char dst[BUF_SIZE] = {0};
struct PathInfo pathInfo = {src, BUF_SIZE, dst, BUF_SIZE}; struct PathInfo pathInfo = {src, BUF_SIZE, dst, BUF_SIZE};
@@ -156,13 +155,12 @@ int MountDevice(const char *rootfs, const char *srcDeviceName, const char *dstDe
Logger("failed to mount dev.", LEVEL_ERROR, SCREEN_YES); Logger("failed to mount dev.", LEVEL_ERROR, SCREEN_YES);
return -1; return -1;
} }
free(str);
return 0; return 0;
} }
int DoDeviceMounting(const char *rootfs, const char *device_name, const unsigned int ids[], size_t idsNr) int DoDeviceMounting(const char *rootfs, const char *device_name, const unsigned int ids[], size_t idsNr)
{ {
if (rootfs == NULL || device_name == NULL) { if (rootfs == NULL || device_name == NULL || ids == NULL) {
Logger("rootfs, device_name pointer is null!", LEVEL_ERROR, SCREEN_YES); Logger("rootfs, device_name pointer is null!", LEVEL_ERROR, SCREEN_YES);
return -1; return -1;
} }