mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-19 06:14:47 +08:00
Match-id-fd706c08945c4519bcefe0d295d55c42c7ad1711
This commit is contained in:
@@ -6,5 +6,10 @@
|
||||
|
||||
void InitParsedConfig(struct ParsedConfig *parsedConfig)
|
||||
{
|
||||
if (parsedConfig != NULL)
|
||||
{
|
||||
Logger("parsedConfig Pointer is null!.");
|
||||
return;
|
||||
}
|
||||
parsedConfig->devicesNr = MAX_DEVICE_NR;
|
||||
}
|
@@ -26,6 +26,10 @@
|
||||
|
||||
static void ReadJsonFile(FILE *pf, char *text, int maxBufferSize)
|
||||
{
|
||||
if (pf == NULL || text == NULL) {
|
||||
fprintf(stderr, "file pointer or text pointer are null!\n");
|
||||
return NULL;
|
||||
}
|
||||
(void)fseek(pf, 0, SEEK_END);
|
||||
|
||||
int size = (int)ftell(pf);
|
||||
@@ -43,6 +47,10 @@ static void ReadJsonFile(FILE *pf, char *text, int maxBufferSize)
|
||||
|
||||
static cJSON *CreateAscendRuntimeInfo(const char *runtimePath)
|
||||
{
|
||||
if (runtimePath = NULL) {
|
||||
fprintf(stderr, "runtimePath pointer are null!\n");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *root = NULL;
|
||||
root = cJSON_CreateObject();
|
||||
if (root == NULL) {
|
||||
@@ -75,6 +83,10 @@ static cJSON *CreateAscendRuntimeInfo(const char *runtimePath)
|
||||
|
||||
static cJSON *CreateRuntimes(const char *runtimePath)
|
||||
{
|
||||
if (runtimePath == NULL) {
|
||||
fprintf(stderr, "runtimePath pointer is null!\n");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *ascendRuntime = NULL;
|
||||
ascendRuntime = CreateAscendRuntimeInfo(runtimePath);
|
||||
if (ascendRuntime == NULL) {
|
||||
@@ -97,6 +109,10 @@ static cJSON *CreateRuntimes(const char *runtimePath)
|
||||
|
||||
static int DelJsonContent(cJSON *root, const char *key)
|
||||
{
|
||||
if (root == NULL || key == NULL) {
|
||||
fprintf(stderr, "userInfo pointer is null!\n");
|
||||
return NULL;
|
||||
}
|
||||
cJSON *existItem = NULL;
|
||||
existItem = cJSON_GetObjectItem(root, key);
|
||||
if (existItem == NULL) {
|
||||
@@ -116,6 +132,10 @@ static int DelJsonContent(cJSON *root, const char *key)
|
||||
|
||||
static cJSON *CreateContent(const char *runtimePath)
|
||||
{
|
||||
if (runtimePath == NULL) {
|
||||
fprintf(stderr, "runtimePath pointer is null!\n");
|
||||
return NULL;
|
||||
}
|
||||
/* 插入ascend runtime */
|
||||
cJSON *runtimes = NULL;
|
||||
runtimes = CreateRuntimes(runtimePath);
|
||||
@@ -150,6 +170,10 @@ static cJSON *CreateContent(const char *runtimePath)
|
||||
|
||||
static cJSON *ModifyContent(FILE *pf, const char *runtimePath)
|
||||
{
|
||||
if (pf == NULL || runtimePath == NULL) {
|
||||
fprintf(stderr, "file pointer or runtimePath pointer is null!\n");
|
||||
return NULL;
|
||||
}
|
||||
char jsonStr[MAX_JSON_FILE_SIZE] = {0x0};
|
||||
ReadJsonFile(pf, &jsonStr[0], MAX_JSON_FILE_SIZE);
|
||||
|
||||
@@ -203,6 +227,10 @@ static cJSON *ModifyContent(FILE *pf, const char *runtimePath)
|
||||
|
||||
static cJSON *RemoveContent(FILE *pf)
|
||||
{
|
||||
if (pf == NULL) {
|
||||
fprintf(stderr, "file pointer is null!\n");
|
||||
return NULL;
|
||||
}
|
||||
char jsonStr[MAX_JSON_FILE_SIZE] = {0x0};
|
||||
ReadJsonFile(pf, &jsonStr[0], MAX_JSON_FILE_SIZE);
|
||||
|
||||
@@ -241,6 +269,10 @@ static cJSON *RemoveContent(FILE *pf)
|
||||
|
||||
static int DetectAndCreateJsonFile(const char *filePath, const char *tempPath, const char *runtimePath)
|
||||
{
|
||||
if (filePath = NULL || tempPath = NULL || runtimePath = NULL) {
|
||||
fprintf(stderr, "filePath Pointer or tempPath or runtimePath are null!\n");
|
||||
return -1;
|
||||
}
|
||||
cJSON *root = NULL;
|
||||
FILE *pf = NULL;
|
||||
pf = fopen(filePath, "r+");
|
||||
@@ -277,6 +309,10 @@ static int DetectAndCreateJsonFile(const char *filePath, const char *tempPath, c
|
||||
|
||||
static int CreateRevisedJsonFile(const char *filePath, const char *tempPath)
|
||||
{
|
||||
if (filePath == NULL || tempPath == NULL) {
|
||||
fprintf(stderr, "filePath Pointer or tempPath are null!\n");
|
||||
return -1;
|
||||
}
|
||||
FILE *pf = NULL;
|
||||
pf = fopen(filePath, "r+");
|
||||
if (pf == NULL) {
|
||||
|
Reference in New Issue
Block a user