diff options
author | Tapas Dey <tdey@codeaurora.org> | 2019-06-21 13:41:51 +0530 |
---|---|---|
committer | Tapas Dey <tdey@codeaurora.org> | 2019-06-26 17:31:33 +0530 |
commit | 394860507fa2157dd58dcd24a3a115ca27b3d95f (patch) | |
tree | 8395779c8fbca7e70eea4fc3056f600348a6e0dc /halimpl/utils/phNxpConfig.cpp | |
parent | 322d11c168aeb5c3a6383def0012ec753eeeab20 (diff) | |
parent | df909ce2cea9dce71c508c9f4a8dd91172701fba (diff) |
Merge branch 'caf/nxp-libnfc-nci/github-libnfc-nci/br_android_ncihalx_row_q' into nfc.vendor.lnx.1.1
* caf/nxp-libnfc-nci/github-libnfc-nci/br_android_ncihalx_row_q: (72 commits)
Update README.md
Fixed coverity warnings
Power State mask value aligned with NCI2.0 & Jni.
Fixed coverity warnings
Copyright year update
Remove Dynamic Dual UICC feature in PN8xT.
Fixed coverity warnings
Fixed coverity warnings
{Q_DP2}: Do not set property persist.factoryota.reboot
{Q-DP1}: FactoryOTA: Disable factory OTA mode
{Q-DP1}: Phase tirm offset sign bit update
Removing WiredSE terminal name update in config file.
Stand alone compilation of NFC system and vendor modules
Fixed coverity warnings
Fixed coverity warnings
Configuration file macro name and values alignment.
Update config parameters for MultiSE
Fixed coverity warnings
Fix UICC initialization is failing when OMAPI session is open
Fixed coverity warnings
...
Change-Id: I643e85abbbf9e726001d8deec0c533de92f8a24e
Diffstat (limited to 'halimpl/utils/phNxpConfig.cpp')
-rw-r--r-- | halimpl/utils/phNxpConfig.cpp | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/halimpl/utils/phNxpConfig.cpp b/halimpl/utils/phNxpConfig.cpp index fdb4048..e16914e 100644 --- a/halimpl/utils/phNxpConfig.cpp +++ b/halimpl/utils/phNxpConfig.cpp @@ -22,7 +22,7 @@ * * The original Work has been changed by NXP Semiconductors. * - * Copyright (C) 2015-2018 NXP Semiconductors + * Copyright (C) 2015-2019 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ const char alternative_config_path[] = ""; #endif #if 1 -const char* transport_config_paths[] = {"/odm/etc/", "/vendor/etc/", "/etc/"}; +const char* transport_config_paths[] = {"/odm/etc/", "/vendor/etc/"}; const char transit_config_path[] = "/data/vendor/nfc/libnfc-nxpTransit.conf"; #else const char* transport_config_paths[] = {"res/"}; @@ -152,22 +152,28 @@ namespace { size_t readConfigFile(const char* fileName, uint8_t** p_data) { FILE* fd = fopen(fileName, "rb"); + uint8_t *buffer = NULL; + size_t read = 0; if (fd == nullptr) return 0; fseek(fd, 0L, SEEK_END); const size_t file_size = ftell(fd); rewind(fd); - uint8_t* buffer = new uint8_t[file_size]; - size_t read = fread(buffer, file_size, 1, fd); + if (file_size > 0) { + buffer = new uint8_t[file_size]; + read = fread(buffer, file_size, 1, fd); + } else { + ALOGE("%s Invalid file size file_size = %zu\n", __func__, file_size); + } fclose(fd); if (read == 1) { *p_data = buffer; return file_size; } - - delete[] buffer; + if (buffer) + delete[] buffer; return 0; } @@ -177,8 +183,6 @@ using namespace ::std; namespace nxp { -void readOptionalConfig(const char* optional); -void findConfigFilePathFromTransportConfigPaths(const string& configName, string& filePath); class CNfcParam : public string { public: @@ -199,7 +203,6 @@ class CNfcConfig : public vector<const CNfcParam*> { public: virtual ~CNfcConfig(); static CNfcConfig& GetInstance(); - friend void readOptionalConfig(const char* optional); bool isModified(); bool isModified(const char* pName); void resetModified(); @@ -578,7 +581,7 @@ inline int getDigitValue(char c, int base) { *******************************************************************************/ void findConfigFilePathFromTransportConfigPaths(const string& configName, string& filePath) { - for (int i = 0; i < transport_config_path_size - 1; i++) { + for (int i = 0; i < transport_config_path_size; i++) { filePath.assign(transport_config_paths[i]); filePath += configName; struct stat file_stat; @@ -586,8 +589,8 @@ void findConfigFilePathFromTransportConfigPaths(const string& configName, return; } } - filePath.assign(transport_config_paths[transport_config_path_size - 1]); - filePath += configName; + // Config file didnt exist in any of the transport config_paths. + filePath.assign(""); } /******************************************************************************* @@ -710,8 +713,7 @@ bool CNfcConfig::readConfig(const char* name, bool bResetContent) { break; } // fall through to numValue to handle numValue - [[fallthrough]]; - + [[fallthrough]]; case NUM_VALUE: if (isDigit(c, base)) { numValue *= base; @@ -1176,7 +1178,9 @@ bool CNfcConfig::isModified() { } uint32_t stored_crc32 = 0; - fread(&stored_crc32, sizeof(uint32_t), 1, fd); + if (fread(&stored_crc32, sizeof(uint32_t), 1, fd) != 1) + ALOGE("%s Failed to Read file", __func__); + fclose(fd); return stored_crc32 != config_crc32_; @@ -1197,7 +1201,9 @@ bool CNfcConfig::isModified(const char* pName) { } uint32_t stored_crc32 = 0; - fread(&stored_crc32, sizeof(uint32_t), 1, fd); + if (fread(&stored_crc32, sizeof(uint32_t), 1, fd) != 1) + ALOGE("%s Failed to Read file", __func__); + fclose(fd); if(isRfFile) @@ -1288,30 +1294,6 @@ CNfcParam::CNfcParam(const char* name, const string& value) CNfcParam::CNfcParam(const char* name, unsigned long value) : string(name), m_numValue(value) {} -/******************************************************************************* -** -** Function: readOptionalConfig() -** -** Description: read Config settings from an optional conf file -** -** Returns: none -** -*******************************************************************************/ -void readOptionalConfig(const char* extra) { - string strPath; - string configName(extra_config_base); - configName += extra; - configName += extra_config_ext; - - if (alternative_config_path[0] != '\0') { - strPath.assign(alternative_config_path); - strPath += configName; - } else { - findConfigFilePathFromTransportConfigPaths(configName, strPath); - } - - CNfcConfig::GetInstance().readConfig(strPath.c_str(), false); -} } // namespace nxp /******************************************************************************* @@ -1323,8 +1305,7 @@ void readOptionalConfig(const char* extra) { ** Returns: True if found, otherwise False. ** *******************************************************************************/ -extern int GetNxpStrValue(const char* name, char* pValue, - unsigned long len) { +extern int GetNxpStrValue(const char* name, char* pValue, unsigned long len) { nxp::CNfcConfig& rConfig = nxp::CNfcConfig::GetInstance(); return rConfig.getValue(name, pValue, len); @@ -1347,8 +1328,8 @@ extern int GetNxpStrValue(const char* name, char* pValue, ** false[0] ** *******************************************************************************/ -extern int GetNxpByteArrayValue(const char* name, char* pValue, - long bufflen, long* len) { +extern int GetNxpByteArrayValue(const char* name, char* pValue, long bufflen, + long* len) { nxp::CNfcConfig& rConfig = nxp::CNfcConfig::GetInstance(); return rConfig.getValue(name, pValue, bufflen, len); |