IssueNo: #I4X6YR : fix code specification

Description:fix code specification
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:BugFix
Binary Source:No
Signed-off-by: wangtiantian <wangtiantian19@huawei.com>
This commit is contained in:
wangtiantian 2022-03-10 11:56:00 +08:00
parent fe57d032a2
commit 26f399fda4
16 changed files with 29 additions and 57 deletions

View File

@ -44,7 +44,7 @@ bool ModuleUsageRecord::ReadFromParcel(Parcel &parcel)
ModuleUsageRecord *ModuleUsageRecord::Unmarshalling(Parcel &parcel)
{
ModuleUsageRecord *record = new ModuleUsageRecord();
if (!record->ReadFromParcel(parcel)) {
if (record && !record->ReadFromParcel(parcel)) {
APP_LOGW("read ModuleUsageRecord from parcel failed");
delete record;
record = nullptr;

View File

@ -24,8 +24,8 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define SINGLE_FEAT_LENGTH (32 * 8)
#define SINGLE_SYSCAP_LENGTH (SINGLE_FEAT_LENGTH + 17) // 17, size of prefix "SystemCapability."
const int32_t SINGLE_FEAT_LENGTH = 32 * 8;
const int32_t SINGLE_SYSCAP_LENGTH = SINGLE_FEAT_LENGTH + 17; // 17, size of prefix "SystemCapability."
/**
* @brief parse rpcid.sc, get the syscap info.

View File

@ -24,12 +24,9 @@
namespace OHOS {
namespace AppExecFwk {
struct CentralDirEntry;
struct ZipEntry;
using ZipPos = ZPOS64_T;
using CentralDirEntry = struct CentralDirEntry;
using LocalHeader = struct LocalHeader;
using EndDir = struct EndDir;
using DataDesc = struct DataDesc;
using ZipEntry = struct ZipEntry;
using ZipEntryMap = std::map<std::string, ZipEntry>;
using BytePtr = Byte *;

View File

@ -132,7 +132,7 @@ std::string BundleExceptionHandler::GetBundleAndDataDir(const InnerBundleInfo &i
basePath.append(Constants::PATH_SEPARATOR);
}
struct dirent *entry = NULL;
struct dirent *entry = nullptr;
while ((entry = readdir(dir)) != nullptr) {
const std::string innerPath = basePath + entry->d_name;
if (innerPath.find(info.GetBundleName()) != std::string::npos) {

View File

@ -469,7 +469,7 @@ bool BundleMgrHostImpl::TraverseCacheDirectory(const std::string& rootDir, std::
if (dir == nullptr) {
return false;
}
while ((ptr = readdir(dir)) != NULL) {
while ((ptr = readdir(dir)) != nullptr) {
if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) {
continue;
}

View File

@ -182,7 +182,7 @@ bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath,
if (bundlePath.back() != Constants::FILE_SEPARATOR_CHAR) {
bundlePath.append(Constants::PATH_SEPARATOR);
}
struct dirent *entry = NULL;
struct dirent *entry = nullptr;
while ((entry = readdir(dir)) != nullptr) {
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
continue;
@ -289,7 +289,7 @@ void BundleUtil::MakeHmdfsConfig(const std::string &bundleName, int32_t bundleId
realBundleDir += (Constants::PATH_SEPERATE + Constants::BUNDLE_ID_FILE);
int bundleIdFd = open(realBundleDir.c_str(), O_WRONLY | O_WRONLY | O_TRUNC);
int32_t bundleIdFd = open(realBundleDir.c_str(), O_WRONLY | O_TRUNC);
if (bundleIdFd > 0) {
std::string bundleIdStr = std::to_string(bundleId);
if (write(bundleIdFd, bundleIdStr.c_str(), bundleIdStr.size()) < 0) {

View File

@ -372,7 +372,7 @@ void InstalldOperator::TraverseCacheDirectory(const std::string &currentPath, st
filePath.push_back(Constants::FILE_SEPARATOR_CHAR);
}
struct dirent *ptr = nullptr;
while ((ptr = readdir(dir)) != NULL) {
while ((ptr = readdir(dir)) != nullptr) {
if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) {
continue;
}

View File

@ -130,7 +130,7 @@ int32_t CommonTool::GetPid(const std::string &processName)
}
for (std::string echoContent : echoContents) {
unsigned long index = echoContent.find(processName);
auto index = echoContent.find(processName);
if (index != std::string::npos) {
int32_t pid = 0;
std::vector<std::string> strsRet;

View File

@ -28,7 +28,7 @@ namespace OHOS {
int ret = dataMessageParcel.WriteBuffer(data, size);
if (ret) {
ElementName* elname = ElementName::Unmarshalling(dataMessageParcel);
if (elname != NULL) {
if (elname != nullptr) {
delete elname;
}
}

View File

@ -31,7 +31,14 @@ using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace AAFwk {
namespace LIBZIP {
#define NO_ERROR 0
namespace {
constexpr int32_t NO_ERROR = 0;
constexpr size_t ARGS_TWO = 2;
constexpr size_t ARGS_MAX_COUNT = 10;
constexpr int32_t PARAM0 = 0;
constexpr int32_t PARAM1 = 1;
constexpr int32_t PARAM3 = 3;
}
#define COMPRESS_LEVE_CHECK(level, ret) \
if (!(level == COMPRESS_LEVEL_NO_COMPRESSION || level == COMPRESS_LEVEL_DEFAULT_COMPRESSION || \

View File

@ -25,33 +25,6 @@
namespace OHOS {
namespace AAFwk {
namespace LIBZIP {
#define NATIVE_C_BUFFER_SIZE 1024 /* Converted to C-style string buffer size */
#define ARGS_MAX_COUNT 10
#define ARGS_ASYNC_COUNT 1
#define ARGS_ONE 1
#define ARGS_TWO 2
#define ARGS_THREE 3
#define ARGS_FOUR 4
#define ARGS_FIVE 5
#define ARGS_SIX 6
#define ARGS_SEVEN 7
#define ARGS_EIGHT 8
#define ARGS_NINE 9
#define ARGS_TEN 10
#define PARAM0 0
#define PARAM1 1
#define PARAM2 2
#define PARAM3 3
#define PARAM4 4
#define PARAM5 5
#define PARAM6 6
#define PARAM7 7
#define PARAM8 8
#define PARAM9 9
#define PARAM10 10
#define NAPI_CALL_BASE_BOOL(theCall, retVal) \
do { \
if ((theCall) == false) { \

View File

@ -21,9 +21,6 @@
namespace OHOS {
namespace AAFwk {
namespace LIBZIP {
#define F_OK 0
namespace {
const std::string SEPARATOR = "/";
}

View File

@ -56,8 +56,8 @@ struct tm GetTmDataFromTickts(int64_t sec)
// a file stream.
void *FdOpenFileFunc(void *opaque, const char *filename, int mode)
{
FILE *file = NULL;
const char *mode_fopen = NULL;
FILE *file = nullptr;
const char *mode_fopen = nullptr;
uint32_t modeInner = static_cast<uint32_t>(mode);
if ((modeInner & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
@ -66,7 +66,7 @@ void *FdOpenFileFunc(void *opaque, const char *filename, int mode)
else if (modeInner & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb";
if ((filename != NULL) && (mode_fopen != NULL)) {
if ((filename != nullptr) && (mode_fopen != nullptr)) {
int fd = dup(*static_cast<int *>(opaque));
if (fd != -1)
file = fdopen(fd, mode_fopen);
@ -271,7 +271,7 @@ unzFile PrepareMemoryForUnzipping(const std::string &data)
zipFile OpenForZipping(const std::string &fileNameUtf8, int appendFlag)
{
zlib_filefunc_def *zipFuncPtrs = NULL;
zlib_filefunc_def *zipFuncPtrs = nullptr;
return zipOpen2(fileNameUtf8.c_str(),
appendFlag,
NULL,

View File

@ -194,7 +194,7 @@ bool ZipReader::ExtractCurrentEntry(WriterDelegate *delegate, uint64_t numBytesT
if (!delegate->PrepareOutput()) {
return false;
}
std::unique_ptr<char[]> buf(new char[kZipBufSize]);
auto buf = std::make_unique<char[]>(kZipBufSize);
uint64_t remainingCapacity = numBytesToExtract;
bool entirefileextracted = false;
@ -250,7 +250,7 @@ bool ZipReader::OpenInternal()
void ZipReader::Reset()
{
zipFile_ = NULL;
zipFile_ = nullptr;
numEntries_ = 0;
reachedEnd_ = false;
currentEntryInfo_.reset();

View File

@ -14,8 +14,6 @@
*/
#include "zip_utils.h"
#include <memory>
#include <pthread.h>
#include <regex>
#include "parallel_task_dispatcher.h"
@ -85,13 +83,13 @@ bool IsPathAbsolute(const std::string &path)
bool IsASCIIChar(const char *pszStr)
{
if (pszStr == NULL) {
if (pszStr == nullptr) {
return false;
}
// Judge whether the first character in the string is ASCII character (0 127), and ASCII character occupies one
// byte
return ((unsigned char)pszStr[0] & 0x80) == 0x80 ? false : true;
return (static_cast<unsigned char>(pszStr[0]) & 0x80) == 0x80 ? false : true;
}
bool FilePathCheckValid(const std::string &str)
{

View File

@ -131,7 +131,7 @@ std::unique_ptr<ZipWriter> ZipWriter::CreateWithFd(PlatformFile zipFilefd, const
APP_LOGI("%{public}s called, Couldn't create ZIP file for FD", __func__);
return nullptr;
}
return std::unique_ptr<ZipWriter>(new ZipWriter(zip_file, rootDir));
return std::unique_ptr<ZipWriter>(new (std::nothrow) ZipWriter(zip_file, rootDir));
}
// static