summaryrefslogtreecommitdiff
path: root/libplatformconfig
diff options
context:
space:
mode:
authorshubham <shubgupt@codeaurora.org>2018-08-01 23:16:46 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2018-08-03 04:01:00 -0700
commitbb9c206ab9a8b4fe24e500f626e3810c69ce773d (patch)
tree93c0c5a4dc9af5c70c61f2f1b7fb177c464d8afb /libplatformconfig
parent9afc6c3d07dcd9daf74d2250a3874bf83f04bc2a (diff)
downloadmedia-bb9c206ab9a8b4fe24e500f626e3810c69ce773d.tar.gz
libplatformconfig: define a separate print macro
libplatformconfig uses the print macro defined that uses debug level which may go out of scope and cause heap-use-after-free Change-Id: Iee3fe156ceaaea8bfc86beb8220476f2ba85bb73
Diffstat (limited to 'libplatformconfig')
-rw-r--r--libplatformconfig/ConfigParser.cpp15
-rw-r--r--libplatformconfig/ConfigParser.h4
-rw-r--r--libplatformconfig/PlatformConfig.cpp7
3 files changed, 14 insertions, 12 deletions
diff --git a/libplatformconfig/ConfigParser.cpp b/libplatformconfig/ConfigParser.cpp
index ef07d7c5..785c9533 100644
--- a/libplatformconfig/ConfigParser.cpp
+++ b/libplatformconfig/ConfigParser.cpp
@@ -32,7 +32,6 @@
#include <errno.h>
#include <utils/Log.h>
#include <sys/mman.h>
-#include "vidc_debug.h"
#include "PlatformConfig.h"
#include "ConfigParser.h"
@@ -42,14 +41,14 @@ namespace Platform {
void ConfigParser::processProperty(const XML_Char **attr, ConfigMap &configMap) {
if (strcmp(attr[0], "name") != 0) {
- DEBUG_PRINT_HIGH("%s: Element 'name' not found!", __func__);
+ VIDC_PLAT_LOGH("%s: Element 'name' not found!", __func__);
return;
}
std::string propName(attr[1]);
if (strcmp(attr[2], "value") != 0) {
- DEBUG_PRINT_HIGH("%s: Element 'value' not found for %s!", __func__, propName.c_str());
+ VIDC_PLAT_LOGH("%s: Element 'value' not found for %s!", __func__, propName.c_str());
return;
}
@@ -78,7 +77,7 @@ int ConfigParser::initAndParse(std::string configFile, ConfigMap &configMap) {
FILE *file;
file = fopen(configFile.c_str(), "r");
if (!file) {
- DEBUG_PRINT_HIGH("%s: Error: %d (%s). Using defaults!",
+ VIDC_PLAT_LOGH("%s: Error: %d (%s). Using defaults!",
__func__, errno, strerror(errno));
return err;
}
@@ -86,7 +85,7 @@ int ConfigParser::initAndParse(std::string configFile, ConfigMap &configMap) {
// Create Parser
parser = XML_ParserCreate(NULL);
if (!parser) {
- DEBUG_PRINT_HIGH("%s: Failed to create XML parser!", __func__);
+ VIDC_PLAT_LOGH("%s: Failed to create XML parser!", __func__);
err = -ENODEV;
goto fileError;
}
@@ -101,21 +100,21 @@ int ConfigParser::initAndParse(std::string configFile, ConfigMap &configMap) {
while (1) {
buf = XML_GetBuffer(parser, BUF_SIZE);
if (buf == NULL) {
- DEBUG_PRINT_HIGH("%s: XML_GetBuffer failed", __func__);
+ VIDC_PLAT_LOGH("%s: XML_GetBuffer failed", __func__);
err = -ENOMEM;
goto parserError;
}
bytesRead = fread(buf, 1, BUF_SIZE, file);
if (bytesRead < 0) {
- DEBUG_PRINT_HIGH("%s: fread failed, bytes read = %d", __func__, bytesRead);
+ VIDC_PLAT_LOGH("%s: fread failed, bytes read = %d", __func__, bytesRead);
err = bytesRead;
goto parserError;
}
if (XML_ParseBuffer(parser, bytesRead,
bytesRead == 0) == XML_STATUS_ERROR) {
- DEBUG_PRINT_HIGH("%s: XML_ParseBuffer failed, for %s",
+ VIDC_PLAT_LOGH("%s: XML_ParseBuffer failed, for %s",
__func__, configFile.c_str());
err = -EINVAL;
goto parserError;
diff --git a/libplatformconfig/ConfigParser.h b/libplatformconfig/ConfigParser.h
index 1170b7ec..7aadc8f2 100644
--- a/libplatformconfig/ConfigParser.h
+++ b/libplatformconfig/ConfigParser.h
@@ -46,6 +46,10 @@
extern "C" {
#endif
+#define VIDC_PLAT_LOGH(fmt, args...) ({ \
+ ALOGD(fmt,##args); \
+ })
+
namespace Platform {
class ConfigParser {
diff --git a/libplatformconfig/PlatformConfig.cpp b/libplatformconfig/PlatformConfig.cpp
index df52fef6..35237e8f 100644
--- a/libplatformconfig/PlatformConfig.cpp
+++ b/libplatformconfig/PlatformConfig.cpp
@@ -32,7 +32,6 @@
#include <errno.h>
#include <utils/Log.h>
#include <sys/mman.h>
-#include "vidc_debug.h"
#include "PlatformConfig.h"
#include "ConfigParser.h"
@@ -47,7 +46,7 @@ Config::Config() {
}
Config* Config::getInstance() {
- DEBUG_PRINT_LOW("%s: Enter", __func__);
+ VIDC_PLAT_LOGH("%s: Enter", __func__);
if (!mInstance) {
mInstance = new Config();
}
@@ -62,12 +61,12 @@ ConfigError_t Config::getInt32(Config_t config, int32_t *value,
return FAIL;
}
if (conf->mConfigMap.find(configStrMap[config].name) == conf->mConfigMap.end()) {
- DEBUG_PRINT_HIGH("%s: Returning default", __func__);
+ VIDC_PLAT_LOGH("%s: Returning default", __func__);
*value = defaultValue;
return FAIL;
}
*value = (int32_t) atoi(conf->mConfigMap[configStrMap[config].name].c_str());
- DEBUG_PRINT_LOW("%s Config name: %s value: %d",
+ VIDC_PLAT_LOGH("%s Config name: %s value: %d",
__func__, configStrMap[config].name, *value);
return OK;
}