未验证 提交 3c098ca8 编写于 作者: O openharmony_ci 提交者: Gitee

!2067 fix coding styles

Merge pull request !2067 from handy/0627
......@@ -379,7 +379,7 @@ int FsHvbConstructVerityTarget(DmVerityTarget *target, const char *devName, stru
}
if (snprintf_s(&devPath[0], sizeof(devPath), sizeof(devPath) - 1, "%s%s",
((strchr(devName "/") == NULL) ? FS_HVB_PARTITION_PREFIX : ""), devName) == -1) {
((strchr(devName, '/') == NULL) ? FS_HVB_PARTITION_PREFIX : ""), devName) == -1) {
BEGET_LOGE("error, snprintf_s devPath");
return -1;
}
......
......@@ -85,7 +85,7 @@ INIT_LOCAL_API int GetParameter_(const char *key, const char *def, char *value,
return GetSystemError(ret);
}
static PropertyValueProcessor propertyGetProcessor = NULL;
static PropertyValueProcessor g_propertyGetProcessor = NULL;
INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder)
{
......@@ -103,8 +103,8 @@ INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder
free(res);
return NULL;
}
if (propertyGetProcessor != NULL) {
res = propertyGetProcessor(key, res);
if (g_propertyGetProcessor != NULL) {
res = g_propertyGetProcessor(key, res);
}
*paramHolder = res;
}
......@@ -113,8 +113,8 @@ INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder
INIT_LOCAL_API PropertyValueProcessor SetPropertyGetProcessor(PropertyValueProcessor processor)
{
PropertyValueProcessor prev = propertyGetProcessor;
propertyGetProcessor = processor;
PropertyValueProcessor prev = g_propertyGetProcessor;
g_propertyGetProcessor = processor;
return prev;
}
......
......@@ -30,7 +30,7 @@ extern "C" {
#define DEV_BUF_LENGTH 3
#define DEV_BUF_MAX_LENGTH 1024
typedef char * (*PropertyValueProcessor)(const char *key, char *value);
typedef char *(*PropertyValueProcessor)(const char *key, char *value);
INIT_LOCAL_API const char *GetProperty(const char *key, const char **paramHolder);
INIT_LOCAL_API PropertyValueProcessor SetPropertyGetProcessor(PropertyValueProcessor processor);
......
......@@ -55,7 +55,7 @@ static void ClearLogo(int fd)
}
static void WriteLogoContent(int fd, const std::string &logoPath, uint32_t size)
{
{
if (size == 0 || size > MAX_LOGO_SIZE) {
BSH_LOGE("logo size is invalid!");
return;
......
......@@ -61,11 +61,11 @@ char *ReadFileToBuf(const char *configFile);
int GetProcCmdlineValue(const char *name, const char *buffer, char *value, int length);
char *ReadFileData(const char *fileName);
typedef struct tagNAME_VALUE_PAIR{
typedef struct NameValuePair {
const char *name;
const char *name_end;
const char *nameEnd;
const char *value;
const char *value_end;
const char *valueEnd;
} NAME_VALUE_PAIR;
int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAIR *nv, void *context), void *context);
......
......@@ -36,15 +36,15 @@
#define OHOS_CMDLINE_PARA_PREFIX "ohos.boot."
#define OHOS_CMDLINE_PARA_PREFIX_LEN 10
typedef struct cmdLineInfo {
typedef struct CmdLineInfo {
const char *name;
int (*processor)(const char *name, const char *value);
} cmdLineInfo;
} CmdLineInfo;
typedef struct cmdLineIteratorCtx {
typedef struct CmdLineIteratorCtx {
char *cmdline;
bool gotSn;
} cmdLineIteratorCtx;
} CmdLineIteratorCtx;
static int CommonDealFun(const char *name, const char *value)
{
......@@ -109,9 +109,9 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
const char *name;
const char *matched;
char fullName[PARAM_NAME_LEN_MAX];
cmdLineIteratorCtx *ctx = (cmdLineIteratorCtx *)context;
CmdLineIteratorCtx *ctx = (CmdLineIteratorCtx *)context;
char *data = (char *)ctx->cmdline;
static const cmdLineInfo CMDLINES[] = {
static const CmdLineInfo CMDLINES[] = {
{ "hardware", CommonDealFun },
{ "bootgroup", CommonDealFun },
{ "reboot_reason", CommonDealFun },
......@@ -121,8 +121,8 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
{ "serialno", SnDealFun }
};
data[nv->name_end - data] = '\0';
data[nv->value_end - data] = '\0';
data[nv->nameEnd - data] = '\0';
data[nv->valueEnd - data] = '\0';
PARAM_LOGV("proc cmdline: name [%s], value [%s]", nv->name, nv->value);
// Get name without prefix
......@@ -185,7 +185,7 @@ static void GenerateSnByDefault(void)
INIT_LOCAL_API int LoadParamFromCmdLine(void)
{
cmdLineIteratorCtx ctx;
CmdLineIteratorCtx ctx;
ctx.gotSn = false;
ctx.cmdline = ReadFileData(BOOT_CMD_LINE);
......
......@@ -217,10 +217,10 @@ int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAI
seperator = strchr(src, ' ');
if (seperator == NULL) {
// Last nv
nv.value_end = src + strlen(src);
nv.valueEnd = src + strlen(src);
src = NULL;
} else {
nv.value_end = seperator;
nv.valueEnd = seperator;
src = seperator + 1;
}
......@@ -230,11 +230,11 @@ int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAI
// Invalid name value pair
continue;
}
if (seperator > nv.value_end) {
if (seperator > nv.valueEnd) {
// name without value, just ignore
continue;
}
nv.name_end = seperator;
nv.nameEnd = seperator;
nv.value = seperator + 1;
iterator(&nv, context);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册