It was printf() because it should work before dlog daemon start up.
However, it can be written to dlog even without dlog daemon. Therefore
replace printf() with dlog function. And by this, it becomes
unnecessary for tool hal-compatibility-checker that redirecting outputs.
Thus removed related options and operations.
Change-Id: I0e3a81f666b22b6f9ae909c81f7d62ea7431cc47
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
void *data;
if (!table || !cb) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
static int hashtable_hal_insert(GHashTable *hal_table, halcc_hal *hal)
{
if (!hal_table || !hal || !hal->name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
if (g_hash_table_lookup_extended(hal_table, hal->name, NULL, NULL)) {
- printf("Failed to insert hal, duplicate: hal name=%s", hal->name);
+ _E("Failed to insert hal, duplicate: hal name=%s", hal->name);
return -EALREADY;
}
static halcc_hal* hashtable_hal_lookup(GHashTable *hal_table, const char *name)
{
if (!hal_table || !name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return NULL;
}
static void hashtable_hal_remove(GHashTable *hal_table, const char *name)
{
if (!hal_table || !name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
halcc_interface key;
if (!interface_table || !name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return NULL;
}
halcc_interface key;
if (!interface_table || !name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
halcc_manifest *m;
if (!manifest) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
m = calloc(1, sizeof(halcc_manifest));
if (!m) {
- printf("Failed to allocate halcc_manifest\n");
+ _E("Failed to allocate halcc_manifest\n");
return -ENOMEM;
}
void halcc_manifest_free(halcc_manifest *manifest)
{
if (!manifest) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
int halcc_manifest_set_platform_version(halcc_manifest *manifest, int major, int minor)
{
if (!manifest) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
if (major < 0 || minor < 0) {
- printf("Invalid parameter of version, major=%d, minor=%d\n", major, minor);
+ _E("Invalid parameter of version, major=%d, minor=%d\n", major, minor);
return -EINVAL;
}
int halcc_manifest_get_platform_version(halcc_manifest *manifest, int *major, int *minor)
{
if (!manifest || !major || !minor) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
int halcc_manifest_add_hal(halcc_manifest *manifest, halcc_hal *hal)
{
if (!manifest || !hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
assert(manifest->hals);
if (!hal->name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
halcc_hal *h;
if (!manifest || !hal_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
void halcc_manifest_remove_hal(halcc_manifest *manifest, const char *hal_name)
{
if (!manifest || !hal_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
halcc_iter_cb cb, void *user_data)
{
if (!manifest || !manifest->hals || !cb) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
halcc_hal *h;
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
h = calloc(1, sizeof(halcc_hal));
if (!h) {
- printf("Failed to allocate halcc_hal\n");
+ _E("Failed to allocate halcc_hal\n");
return -ENOMEM;
}
void halcc_hal_free(halcc_hal *hal)
{
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
char *n;
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
n = strndup(hal_name, HALCC_NAME_MAX);
if (!n) {
- printf("Failed to allocate hal_name\n");
+ _E("Failed to allocate hal_name\n");
return -ENOMEM;
}
int halcc_hal_get_name(halcc_hal *hal, const char **hal_name)
{
if (!hal || !hal_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
int i;
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
int halcc_hal_set_transport(halcc_hal *hal, halcc_transport_e transport)
{
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
int halcc_hal_get_transport(halcc_hal *hal, halcc_transport_e *transport)
{
if (!hal || !transport) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
int halcc_hal_add_interface(halcc_hal *hal, halcc_interface *interface)
{
if (!hal || !interface) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
const char *interface_name, const char *instance_id)
{
if (!hal || !interface_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
void halcc_hal_foreach_interface(halcc_hal *hal, halcc_iter_cb cb, void *user_data)
{
if (!hal || !hal->interfaces || !cb) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
bool halcc_hal_is_compatible_with_version(halcc_hal *hal, int major, int minor)
{
if (!hal) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return false;
}
halcc_interface *iface;
if (!interface) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
iface = calloc(1, sizeof(halcc_interface));
if (!iface) {
- printf("Failed to allocate halcc_interface\n");
+ _E("Failed to allocate halcc_interface\n");
return -ENOMEM;
}
void halcc_interface_free(halcc_interface *interface)
{
if (!interface) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return;
}
char *n;
if (!interface || !interface_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
n = strndup(interface_name, HALCC_NAME_MAX);
if (!n) {
- printf("Failed to allocate interface_name\n");
+ _E("Failed to allocate interface_name\n");
return -ENOMEM;
}
int halcc_interface_get_name(halcc_interface *interface, const char **interface_name)
{
if (!interface || !interface_name) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
char *id = NULL;
if (!interface || !instance_id) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
id = strndup(instance_id, HALCC_NAME_MAX);
if (!id) {
- printf("Failed to allocate instance_id\n");
+ _E("Failed to allocate instance_id\n");
return -ENOMEM;
}
int halcc_interface_get_instance_id(halcc_interface *interface, const char **instance_id)
{
if (!interface || !instance_id) {
- printf("Invalid parameter\n");
+ _E("Invalid parameter\n");
return -EINVAL;
}
#include <libxml/parser.h>
#include <libxml/tree.h>
-
+#include "common.h"
#include "hal-api-compatibility-checker-object.h"
#include "hal-api-compatibility-checker-parser.h"
assert(interface);
if (!xmlStrEqual(node->name, "interface")) {
- printf("Invalid interface node, %s\n", node->name);
+ _E("Invalid interface node, %s\n", node->name);
return -EINVAL;
}
}
if (!hal_name) {
- printf("Invalid hal node, name is unspecified\n");
+ _E("Invalid hal node, name is unspecified\n");
return -EINVAL;
}
if (ret != 0) {
ret = halcc_hal_new(&hal);
if (ret != 0) {
- printf("Failed to halcc_hal_new(), ret=%d\n", ret);
+ _E("Failed to halcc_hal_new(), ret=%d\n", ret);
return ret;
}
ret = halcc_manifest_add_hal(manifest, hal);
if (ret != 0) {
- printf("Failed to halcc_manifest_add_hal(), ret=%d\n", ret);
+ _E("Failed to halcc_manifest_add_hal(), ret=%d\n", ret);
halcc_hal_free(hal);
hal = NULL;
return ret;
scanned = sscanf(version, "%d.%d", &major, &minor);
if (scanned != 2) {
- printf("Invalid version format %s\n", version);
+ _E("Invalid version format %s\n", version);
continue;
}
ret = halcc_hal_add_version(hal, major, minor);
if (ret != 0)
- printf("Failed to halcc_hal_add_version(), ret=%d\n", ret);
+ _E("Failed to halcc_hal_add_version(), ret=%d\n", ret);
} else if (xmlStrEqual(child->name, "transport")) {
__xmlchar__ xmlChar *transport = xmlNodeGetContent(child);
ret = -EINVAL;
if (ret != 0)
- printf("Failed to halcc_hal_set_transport(), %s, ret=%d\n", transport, ret);
+ _E("Failed to halcc_hal_set_transport(), %s, ret=%d\n", transport, ret);
} else if (xmlStrEqual(child->name, "interface")) {
halcc_interface *iface;
ret = halcc_interface_new(&iface);
if (ret != 0) {
- printf("Failed to halcc_interface_new(), ret=%d\n", ret);
+ _E("Failed to halcc_interface_new(), ret=%d\n", ret);
continue;
}
ret = parse_interface(child, iface);
if (ret != 0) {
- printf("Failed to parse_interface(), ret=%d\n", ret);
+ _E("Failed to parse_interface(), ret=%d\n", ret);
halcc_interface_free(iface);
continue;
}
// version
prop = xmlGetProp(node, "platform-version");
if (!prop) {
- printf("Failed to xmlGetProp() \"platform-version\"\n");
+ _E("Failed to xmlGetProp() \"platform-version\"\n");
return -EINVAL;
}
xmlFree(prop);
if (ret != 2) {
- printf("Failed to scan platform-version, ret=%d\n", ret);
+ _E("Failed to scan platform-version, ret=%d\n", ret);
return -EINVAL;
}
ret = halcc_manifest_set_platform_version(manifest, major, minor);
if (ret != 0) {
- printf("Failed to halcc_manifest_set_version(), ret=%d\n", ret);
+ _E("Failed to halcc_manifest_set_version(), ret=%d\n", ret);
return -EINVAL;
}
root = xmlDocGetRootElement(doc);
if (!root) {
- printf("Failed to get root element\n");
+ _E("Failed to get root element\n");
return -EINVAL;
}
if (!xmlStrEqual(root->name, "hal-api")) {
- printf("Invalid root node, %s\n", root->name);
+ _E("Invalid root node, %s\n", root->name);
return -EINVAL;
}
int ret = 0;
if (!manifest) {
- printf("Invalid manifest\n");
+ _E("Invalid manifest\n");
return -EINVAL;
}
doc = xmlReadFd(fd, NULL, NULL, 0);
if (!doc) {
- printf("Failed to read doc %d\n", fd);
+ _E("Failed to read doc %d\n", fd);
return -ENOENT;
}
int ret = 0;
if (!filepath || !manifest) {
- printf("Invalid filepath or manifest\n");
+ _E("Invalid filepath or manifest\n");
return -EINVAL;
}
doc = xmlReadFile(filepath, NULL, XML_PARSE_NOWARNING);
if (!doc) {
- printf("Failed to read doc %s\n", filepath);
+ _E("Failed to read doc %s\n", filepath);
return -ENOENT;
}
fd = openat(dfd, entry->d_name, O_RDONLY);
if (fd < 0) {
- printf("Failed to openat(), %m\n");
+ _E("Failed to openat(), %m\n");
continue;
}
ret = halcc_parse_fd(fd, manifest);
if (ret < 0) {
- printf("Failed to parse xml, ret=%d\n", ret);
+ _E("Failed to parse xml, ret=%d\n", ret);
close(fd);
continue;
}
int ret = 0;
if (!string || !manifest) {
- printf("Invalid string or manifest\n");
+ _E("Invalid string or manifest\n");
return -EINVAL;
}
doc = xmlReadMemory(string, len, NULL, NULL, 0);
if (!doc) {
- printf("Failed to read xml string\n");
+ _E("Failed to read xml string\n");
return -ENOENT;
}
#include <string.h>
#include <dlog/dlog.h>
-#include <dlog/dlog-redirect-stdout.h>
#include <hal-common.h>
#define DEFAULT_PLATFORM_MANIFEST_DIR "/etc/hal"
OPT_START = 0,
OPT_HELP = OPT_START,
OPT_SKIP_IF_RESULT_EXIST,
- OPT_REDIRECT_ALL,
- OPT_REDIRECT_STDOUT,
- OPT_REDIRECT_STDERR,
OPT_RESET,
OPT_END,
};
[OPT_SKIP_IF_RESULT_EXIST]
= { "skip-if-result-exist", optional_argument, NULL, 0 },
- [OPT_REDIRECT_ALL]
- = { "redirect-all", required_argument, NULL, 0 },
-
- [OPT_REDIRECT_STDOUT]
- = { "redirect-stdout", required_argument, NULL, 0 },
-
- [OPT_REDIRECT_STDERR]
- = { "redirect-stderr", required_argument, NULL, 0 },
-
[OPT_RESET]
= { "reset", no_argument, NULL, 0 },
return false;
}
-static int redirect_output(const char *file, int stdfd)
-{
- int fd = -1;
- int newfd;
-
- assert(file);
-
- /* recognize special symbol "dlog" */
- if (strncmp(file, "dlog", sizeof("dlog")) == 0)
- return dlog_connect_fd(2 /* LOG_ID_SYSTEM */,
- stdfd,
- LOG_TAG_HAL_COMPATIBILITY_CHECKER,
- stdfd == STDERR_FILENO ? 6 /* DLOG_ERROR */ : 4 /* DLOG_INFO */);
-
- fd = open(file, O_WRONLY | O_APPEND | O_CREAT, 0644);
-
- if (fd == -1) {
- printf("hal-compatibility-checker: Failed to redirect output: %m\n");
- return -1;
- }
-
- newfd = dup2(fd, stdfd);
- close(fd);
-
- return newfd;
-}
-
static void show_help(void)
{
printf(
"\t\tskip compatibility check if there exists a result of compatibility.\n"
"\t\tif DIRECTORY is given, locate a result based on the given DIRECTORY.\n"
"\n"
- "\t--redirect-all=FILE|dlog\n"
- "\t\tredirect stdout/stderr to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
- "\n"
- "\t--redirect-stdout=FILE|dlog\n"
- "\t\tredirect stdout to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
- "\n"
- "\t--redirect-stderr=FILE|dlog\n"
- "\t\tredirect stderr to FILE or dlog with tag "LOG_TAG_HAL_COMPATIBILITY_CHECKER".\n"
- "\n"
"\t--reset\n"
"\t\tremove the existing result file.\n"
);
bool reset_file = false;
const char *skip_if_result_exist_dir = NULL;
const char *platform_manifest_dir = NULL;
- const char *outfile = NULL;
- const char *errfile = NULL;
for (;;) {
opt = getopt_long(argc, argv, "h", long_option, &index);
skip_if_result_exist = true;
skip_if_result_exist_dir = optarg;
break;
- case OPT_REDIRECT_ALL:
- outfile = optarg;
- errfile = optarg;
- break;
- case OPT_REDIRECT_STDOUT:
- outfile = optarg;
- break;
- case OPT_REDIRECT_STDERR:
- errfile = optarg;
- break;
case OPT_RESET:
reset_file = true;
break;
return 0;
}
- if (outfile)
- redirect_output(outfile, STDOUT_FILENO);
-
- if (errfile)
- redirect_output(errfile, STDERR_FILENO);
-
if (skip_if_result_exist && result_exist(skip_if_result_exist_dir)) {
printf("hal-compatibility-checker: skip checking\n");
return 0;