!629 fix: clean code scan issue

Merge pull request !629 from yuanbo/master
This commit is contained in:
openharmony_ci
2022-02-15 03:40:12 +00:00
committed by Gitee
9 changed files with 43 additions and 42 deletions
+3 -3
View File
@@ -28,9 +28,9 @@ typedef uint32_t devid_t;
#define DEVNODEID_MASK ((1 << DEVNODEID_BITS) - 1)
#define DEVICEID_MASK ((1 << DEVICEID_BITS) - 1)
#define HOSTID(devid) (devid >> (DEVICEID_BITS + DEVNODEID_BITS))
#define DEVICEID(devid) ((devid >> DEVNODEID_BITS) & DEVICEID_MASK)
#define DEVNODEID(devid) (devid & DEVNODEID_MASK)
#define HOSTID(devid) ((uint32_t)devid >> (DEVICEID_BITS + DEVNODEID_BITS))
#define DEVICEID(devid) (((uint32_t)devid >> DEVNODEID_BITS) & DEVICEID_MASK)
#define DEVNODEID(devid) ((uint32_t)devid & DEVNODEID_MASK)
#define MK_DEVID(hostId, deviceId, devnodeId) \
(hostId << (DEVICEID_BITS + DEVNODEID_BITS) | deviceId << DEVNODEID_BITS | devnodeId)
+3 -2
View File
@@ -66,8 +66,9 @@ static int DevmgrServiceStartHostProcess(struct DevHostServiceClnt *hostClnt, bo
return HDF_SUCCESS;
}
while (hostClnt->hostService == NULL && waitCount-- > 0) {
while (hostClnt->hostService == NULL && waitCount > 0) {
OsalMSleep(WAIT_HOST_SLEEP_TIME);
waitCount--;
}
if (waitCount <= 0) {
@@ -268,7 +269,7 @@ static int DevmgrServiceStartDeviceHost(struct DevmgrService *devmgr, struct Hdf
static int DevmgrServiceStartDeviceHosts(struct DevmgrService *inst)
{
uint32_t ret;
int ret;
struct HdfSList hostList;
struct HdfSListIterator it;
struct HdfHostInfo *hostAttr = NULL;
+2 -2
View File
@@ -70,7 +70,7 @@ bool ByteCodeGen::Initialize()
bool ByteCodeGen::ByteCodeConvert()
{
return ast_->WalkBackward([this](std::shared_ptr<AstObject> &object, uint32_t depth) {
return ast_->WalkBackward([this](std::shared_ptr<AstObject> &object, int32_t depth) {
if (object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() == NODE_TEMPLATE) {
object->Separate();
return NOERR;
@@ -186,7 +186,7 @@ bool ByteCodeGen::ByteCodeWrite(bool dummy)
bool ByteCodeGen::ByteCodeWriteWalk()
{
return ast_->WalkForward([this](std::shared_ptr<AstObject> &current, uint32_t depth) {
return ast_->WalkForward([this](std::shared_ptr<AstObject> &current, int32_t depth) {
current->SetHash(writeSize_);
auto opcode = current->OpCode();
Write(opcode);
+4 -4
View File
@@ -49,7 +49,7 @@ bool Decompile::VerifyDecompileFile()
Logger().Error() << "read header failed";
return false;
}
Logger().Debug() << "read Header: magic is: " << header.magicNumber << " version major: " << header.versionMajor <<
Logger().Debug() << "read Header: magic is: " << header.magicNumber << " version major: " << header.versionMajor <<
" version minor: " << header.versionMinor << " checksum: " << header.checkSum << " totalSize: " << header.totalSize;
if (header.magicNumber != HCB_MAGIC_NUM) {
Logger().Error() << "magic number is: " << header.magicNumber << ", check failed!";
@@ -149,8 +149,8 @@ std::shared_ptr<AstObject> Decompile::RebuildNode()
node->SetSize(nodeSize);
node->SetHash(nodeHash);
Logger().Debug() << "node name is: " << node->Name() << ", size is: " << nodeSize << ", hash is: " << nodeHash;
uint32_t pos = file_.tellg();
uint32_t nodeEnd = pos + nodeSize;
int32_t pos = file_.tellg();
int32_t nodeEnd = pos + nodeSize;
while (pos < nodeEnd) {
uint32_t childOpCode;
if (!GetNextByteCode(childOpCode)) {
@@ -312,7 +312,7 @@ bool Decompile::DoDecompile()
if(!InitDecompileFile()) {
return false;
}
if (!VerifyDecompileFile()) {
Logger().Error() << "Verify decompile file failed!";
return false;
+1 -1
View File
@@ -270,7 +270,7 @@ bool Lexer::LexFromNumber(Token &token)
ConsumeChar();
value.push_back(c);
}
v = strtoll(value.data(), nullptr, 8);
v = (uint64_t)strtoll(value.data(), nullptr, 8);
break;
}
switch (c) {
+7 -7
View File
@@ -96,7 +96,7 @@ bool MacroGen::Initialize()
bool MacroGen::TemplateNodeSeparate()
{
return ast_->WalkBackward([this](std::shared_ptr<AstObject> &object, uint32_t depth) {
return ast_->WalkBackward([this](std::shared_ptr<AstObject> &object, int32_t depth) {
if (object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() == NODE_TEMPLATE) {
object->Separate();
return NOERR;
@@ -105,7 +105,7 @@ bool MacroGen::TemplateNodeSeparate()
});
}
std::string MacroGen::GenFullName(uint32_t depth, const std::shared_ptr<AstObject> &node, const std::string &sep)
std::string MacroGen::GenFullName(int32_t depth, const std::shared_ptr<AstObject> &node, const std::string &sep)
{
std::string name;
for (int i = 0; i < depth; i++) {
@@ -151,7 +151,7 @@ bool MacroGen::GenArray(const std::string &arrName, uint32_t &arrSize, uint32_t
return true;
}
bool MacroGen::GenNodeForeach(uint32_t depth, const std::shared_ptr<AstObject> &node)
bool MacroGen::GenNodeForeach(int32_t depth, const std::shared_ptr<AstObject> &node)
{
std::list<std::string> subList;
auto child = node->Child();
@@ -200,7 +200,7 @@ bool MacroGen::GenNodeForeach(uint32_t depth, const std::shared_ptr<AstObject> &
return true;
}
std::string MacroGen::GenRefObjName(uint32_t depth, const std::shared_ptr<AstObject> &object)
std::string MacroGen::GenRefObjName(int32_t depth, const std::shared_ptr<AstObject> &object)
{
std::string name(object->StringValue());
if (name.find(".") == std::string::npos) {
@@ -217,7 +217,7 @@ std::string MacroGen::GenRefObjName(uint32_t depth, const std::shared_ptr<AstObj
bool MacroGen::NodeWalk()
{
return ast_->WalkForward([this](std::shared_ptr<AstObject> &current, uint32_t depth) {
return ast_->WalkForward([this](std::shared_ptr<AstObject> &current, int32_t depth) {
auto type = current->Type();
static uint32_t arraySize = 0;
@@ -225,13 +225,13 @@ bool MacroGen::NodeWalk()
<< "] depth:" << depth \
<< " arraySize:" << std::dec << arraySize << '\n';
SetTypeData(type, current, arraySize, depth);
return NOERR;
});
}
void MacroGen::SetTypeData(uint32_t type, const std::shared_ptr<AstObject> &current,
uint32_t &arraySize, uint32_t depth)
uint32_t &arraySize, int32_t depth)
{
static std::string nodeName;
static std::string arrayName;
+4 -4
View File
@@ -28,13 +28,13 @@ private:
bool TemplateNodeSeparate();
std::string GenFullName(uint32_t depth, const std::shared_ptr<AstObject> &node, const std::string &sep);
std::string GenFullName(int32_t depth, const std::shared_ptr<AstObject> &node, const std::string &sep);
bool GenNodeForeach(uint32_t depth, const std::shared_ptr<AstObject> &node);
bool GenNodeForeach(int32_t depth, const std::shared_ptr<AstObject> &node);
bool NodeWalk();
void SetTypeData(uint32_t type, const std::shared_ptr<AstObject> &current, uint32_t &arraySize, uint32_t depth);
void SetTypeData(uint32_t type, const std::shared_ptr<AstObject> &current, uint32_t &arraySize, int32_t depth);
void SetTypeDataUinit64(const std::string &arrayName, uint32_t &arraySize, uint32_t arrayType,
const std::shared_ptr<AstObject> &current);
@@ -47,7 +47,7 @@ private:
bool GenArray(const std::string &name, uint32_t &arrSize, uint32_t type, const std::shared_ptr<AstObject> &node);
std::string GenRefObjName(uint32_t depth, const std::shared_ptr<AstObject> &object);
std::string GenRefObjName(int32_t depth, const std::shared_ptr<AstObject> &object);
std::ofstream ofs_;
std::string outFileName_;
+12 -12
View File
@@ -83,7 +83,7 @@ bool TextGen::HeaderOutput()
bool TextGen::HeaderOutputTraversal()
{
auto ret = ast_->WalkBackward([this](const std::shared_ptr<AstObject> &current, uint32_t) -> uint32_t {
auto ret = ast_->WalkBackward([this](const std::shared_ptr<AstObject> &current, int32_t) -> uint32_t {
if (!current->IsNode()) {
return NOERR;
}
@@ -339,11 +339,11 @@ const std::string &TextGen::TypeToStr(uint32_t type)
bool TextGen::OutputImplGlobalVariables()
{
auto forwardWalkFunc = [this](const std::shared_ptr<AstObject>& current, uint32_t depth) -> uint32_t {
auto forwardWalkFunc = [this](const std::shared_ptr<AstObject>& current, int32_t depth) -> uint32_t {
return ImplementGenTraversal(current, depth);
};
auto backwardWalkFunc = [this](const std::shared_ptr<AstObject>& current, uint32_t depth) -> uint32_t {
auto backwardWalkFunc = [this](const std::shared_ptr<AstObject>& current, int32_t depth) -> uint32_t {
return ImplementCloseBraceGen(current, depth);
};
@@ -365,7 +365,7 @@ const std::string &TextGen::Indent(uint32_t times)
return indentMap.at(times);
}
uint32_t TextGen::ImplementCloseBraceGen(const std::shared_ptr<AstObject> &object, uint32_t depth)
uint32_t TextGen::ImplementCloseBraceGen(const std::shared_ptr<AstObject> &object, int32_t depth)
{
if (!object->IsNode() || ConfigNode::CastFrom(object)->GetNodeType() == NODE_INHERIT) {
return NOERR;
@@ -378,7 +378,7 @@ uint32_t TextGen::ImplementCloseBraceGen(const std::shared_ptr<AstObject> &objec
return ofs_.good() ? NOERR : EOUTPUT;
}
uint32_t TextGen::ImplementGenTraversal(const std::shared_ptr<AstObject> &object, uint32_t depth)
uint32_t TextGen::ImplementGenTraversal(const std::shared_ptr<AstObject> &object, int32_t depth)
{
if (!object->IsNode() && !object->IsTerm()) {
return NOERR;
@@ -411,7 +411,7 @@ bool TextGen::IsInSubClassNode(const std::shared_ptr<AstObject> &object)
return false;
}
uint32_t TextGen::ObjectImplementGen(const std::shared_ptr<AstObject> &object, uint32_t depth)
uint32_t TextGen::ObjectImplementGen(const std::shared_ptr<AstObject> &object, int32_t depth)
{
switch (object->Type()) {
case PARSEROP_CONFNODE: {
@@ -434,7 +434,7 @@ uint32_t TextGen::ObjectImplementGen(const std::shared_ptr<AstObject> &object, u
return ofs_.good() ? NOERR : EOUTPUT;
}
bool TextGen::TemplateObjectImplGen(const std::shared_ptr<AstObject> &object, uint32_t depth)
bool TextGen::TemplateObjectImplGen(const std::shared_ptr<AstObject> &object, int32_t depth)
{
auto node = ConfigNode::CastFrom(object);
if (node->GetNodeType() != NODE_TEMPLATE) {
@@ -487,7 +487,7 @@ void TextGen::SymbolAdd(const std::string &name, const std::shared_ptr<AstObject
symMap.insert(std::make_pair(std::string(name), std::make_shared<Symbol>(object, 1)));
}
uint32_t TextGen::PrintTermImplement(const std::shared_ptr<AstObject> &object, uint32_t depth)
uint32_t TextGen::PrintTermImplement(const std::shared_ptr<AstObject> &object, int32_t depth)
{
auto term = ConfigTerm::CastFrom(object);
auto value = object->Child();
@@ -536,7 +536,7 @@ bool TextGen::PrintBaseTypeValue(const std::shared_ptr<AstObject> &object)
return ofs_.good();
}
uint32_t TextGen::PrintArrayImplement(const std::shared_ptr<AstObject> &object, uint32_t depth)
uint32_t TextGen::PrintArrayImplement(const std::shared_ptr<AstObject> &object, int32_t depth)
{
if (IsInSubClassNode(object)) {
return PrintArrayImplInSubClass(object, depth) ? NOERR : EOUTPUT;
@@ -554,7 +554,7 @@ uint32_t TextGen::PrintArrayImplement(const std::shared_ptr<AstObject> &object,
return ofs_.good() ? NOERR : EOUTPUT;
}
bool TextGen::PrintArrayImplInSubClass(const std::shared_ptr<AstObject> &object, uint32_t depth)
bool TextGen::PrintArrayImplInSubClass(const std::shared_ptr<AstObject> &object, int32_t depth)
{
auto array = ConfigArray::CastFrom(object->Child());
auto arrayName = GenArrayName(object);
@@ -611,7 +611,7 @@ bool TextGen::OutputTemplateImpl()
return false;
}
return ast_->WalkBackward([this](const std::shared_ptr<AstObject> &object, uint32_t) -> uint32_t {
return ast_->WalkBackward([this](const std::shared_ptr<AstObject> &object, int32_t) -> uint32_t {
if (!object->IsNode() ||
(object->IsNode() && ConfigNode::CastFrom(object)->GetNodeType() != NODE_TEMPLATE)) {
return NOERR;
@@ -640,7 +640,7 @@ bool TextGen::OutputTemplateImpl()
bool TextGen::OutputTemplateVariablesDeclare()
{
return ast_->WalkBackward([this](const std::shared_ptr<AstObject> &object, uint32_t) -> uint32_t {
return ast_->WalkBackward([this](const std::shared_ptr<AstObject> &object, int32_t) -> uint32_t {
if (object->IsTerm() && object->Child()->IsArray()) {
return ArrayVariablesDeclareGen(object);
} else if (!object->IsNode() ||
+7 -7
View File
@@ -61,17 +61,17 @@ private:
bool OutputImplGlobalVariables();
uint32_t ImplementGenTraversal(const std::shared_ptr<AstObject> &object, uint32_t depth);
uint32_t ImplementGenTraversal(const std::shared_ptr<AstObject> &object, int32_t depth);
uint32_t ImplementCloseBraceGen(const std::shared_ptr<AstObject> &object, uint32_t depth);
uint32_t ImplementCloseBraceGen(const std::shared_ptr<AstObject> &object, int32_t depth);
static const std::string & Indent(uint32_t times = 1);
static bool IsInSubClassNode(const std::shared_ptr<AstObject> &object);
uint32_t ObjectImplementGen(const std::shared_ptr<AstObject> &object, uint32_t depth);
uint32_t ObjectImplementGen(const std::shared_ptr<AstObject> &object, int32_t depth);
bool TemplateObjectImplGen(const std::shared_ptr<AstObject> &object, uint32_t depth);
bool TemplateObjectImplGen(const std::shared_ptr<AstObject> &object, int32_t depth);
std::string GenTemplateVariableName(const std::shared_ptr<AstObject> &object);
@@ -94,13 +94,13 @@ private:
std::string rootVariableName_;
std::map<std::string, std::shared_ptr<Symbol>> symMap;
uint32_t PrintTermImplement(const std::shared_ptr<AstObject> &object, uint32_t depth);
uint32_t PrintTermImplement(const std::shared_ptr<AstObject> &object, int32_t depth);
bool PrintBaseTypeValue(const std::shared_ptr<AstObject>& object);
uint32_t PrintArrayImplement(const std::shared_ptr<AstObject> &object, uint32_t depth);
uint32_t PrintArrayImplement(const std::shared_ptr<AstObject> &object, int32_t depth);
bool PrintArrayImplInSubClass(const std::shared_ptr<AstObject> &object, uint32_t depth);
bool PrintArrayImplInSubClass(const std::shared_ptr<AstObject> &object, int32_t depth);
bool HcsPrintArrayContent(const std::shared_ptr<AstObject>& object, uint32_t indent);