emulator.*: remove unnecessary "DEFINE".
new_debug_ch.*: use GLIB functions.
osutil*: fix redundant stack usage.
Change-Id: I2f0d53342e2cb96ec136e89f3637e4d50dbabf03
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
const char *qemu_ether_ntoa(const MACAddr *mac);
#if defined(CONFIG_MARU) && defined(CONFIG_WIN32)
-#include "../tizen/src/maru_common.h"
+#include "../tizen/src/emulator_common.h"
int is_wow64(void);
bool get_java_path(char **java_path);
#include "emul_state.h"
#include "hw/pci/maru_brightness.h"
#include "skin/maruskin_server.h"
+#include "util/maru_err_table.h"
#include "debug_ch.h"
-#include "maru_err_table.h"
MULTI_DEBUG_CHANNEL(tizen, maru_shm);
#endif
#ifdef CONFIG_DARWIN
+#include <libgen.h>
#include "ns_event.h"
int thread_running = 1; /* Check if we need exit main */
#endif
static void print_system_info(void)
{
-#define DIV 1024
-
LOG_INFO("* Board name : %s\n", build_version);
LOG_INFO("* Package %s\n", pkginfo_version);
LOG_INFO("* Package %s\n", pkginfo_maintainer);
*
* Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
* MunKyu Im <munkyu.im@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
#include "qemu/option.h"
#include "sysemu/sysemu.h"
-#define MAXLEN 512
-#define MAXPACKETLEN 60
-//#define SHMKEY 26099
-
extern gchar bin_path[];
extern gchar log_path[];
#include "ecs/ecs.h"
#ifdef CONFIG_HAX
-#include "guest_debug.h"
-
#include "target-i386/hax-i386.h"
#endif
*
*/
-#include <stdio.h>
-
#include "qemu-common.h"
#include "emulator.h"
#include "util/new_debug_ch.h"
#include "util/osutil.h"
-static char debugchfile[512] = {0, };
+#define MAX_FILE_LEN 512
+static char debugchfile[MAX_FILE_LEN] = {0, };
static int fd = STDOUT_FILENO;
static const char * const debug_classes[] =
const char *name = p1;
const struct _debug_channel *chan = p2;
- return strcmp(name, chan->name);
+ return g_strcmp0(name, chan->name);
}
/* get the flags to use for a given channel, possibly setting them too in case of lazy init */
while (min <= max) {
pos = (min + max) / 2;
- res = strcmp(name, debug_options[pos].name);
+ res = g_strcmp0(name, debug_options[pos].name);
if (!res) {
debug_options[pos].flags = (debug_options[pos].flags & ~clear) | set;
return;
(nb_debug_options - pos) * sizeof(debug_options[0]));
}
- strcpy(debug_options[pos].name, name);
+ g_strlcpy(debug_options[pos].name, name, MAX_NAME_LEN);
debug_options[pos].flags = (default_flags & ~clear) | set;
nb_debug_options++;
}
char *opt, *next, *options;
unsigned int i;
- if (!(options = strdup(str))) {
+ if (!(options = g_strdup(str))) {
return;
}
}
if (0 == strlen(bin_path)) {
- strcpy(debugchfile, "DEBUGCH");
+ g_strlcpy(debugchfile, "DEBUGCH", MAX_FILE_LEN);
} else {
- strcat(debugchfile, bin_path);
- strcat(debugchfile, "DEBUGCH");
+ g_strlcat(debugchfile, bin_path, MAX_FILE_LEN);
+ g_strlcat(debugchfile, "DEBUGCH", MAX_FILE_LEN);
}
fp = fopen(debugchfile, "r");
}
if (debug != NULL) {
- if (!strcmp(debug, "help")) {
+ if (!g_strcmp0(debug, "help")) {
debug_usage();
}
parse_options(debug);
return -1;
}
- ret = snprintf(buf_msg, sizeof(buf_msg), "%s [%s:%s] ",
+ ret = g_snprintf(buf_msg, sizeof(buf_msg), "%s [%s:%s] ",
get_timeofday(), debug_classes[cls], channel->name);
va_start(valist, format);
- ret += vsnprintf(buf_msg + ret, sizeof(buf_msg) - ret, format, valist);
+ ret += g_vsnprintf(buf_msg + ret, sizeof(buf_msg) - ret, format, valist);
va_end(valist);
ret_write = qemu_write_full(fd, buf_msg, ret);
#include <sys/types.h>
+#define MAX_NAME_LEN 15
// #define NO_DEBUG
#ifdef __cplusplus
struct _debug_channel
{
unsigned char flags;
- char name[15];
+ char name[MAX_NAME_LEN];
};
#ifndef NO_DEBUG
-#define MSGSIZE_MAX 2048
#define __GET_DEBUGGING_SEVERE(dbch) ((dbch)->flags & (1 << __DBCL_SEVERE))
#define __GET_DEBUGGING_WARNING(dbch) ((dbch)->flags & (1 << __DBCL_WARNING))
#define __GET_DEBUGGING_INFO(dbch) ((dbch)->flags & (1 << __DBCL_INFO))
@brief Collection of utilities for darwin
*/
-#include "maru_common.h"
+#include "emulator_common.h"
#include "osutil.h"
#include "emulator.h"
+#include "emul_state.h"
#include "debug_ch.h"
#include "maru_err_table.h"
#include "sdb.h"
#endif
#include <string.h>
+#include <unistd.h>
#include <sys/shm.h>
#include <sys/sysctl.h>
#include <SystemConfiguration/SystemConfiguration.h>
char *shared_memory;
int base_port;
base_port = get_emul_vm_base_port();
- g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
+ g_shmid = shmget((key_t)base_port, getpagesize(), 0666|IPC_CREAT);
if (g_shmid == -1) {
ERR("shmget failed\n");
perror("osutil-darwin: ");
/* uname */
INFO("* Host machine uname :\n");
- char uname_cmd[MAXLEN] = "uname -a";
+ char const *const uname_cmd = "uname -a";
if(system(uname_cmd) < 0) {
INFO("system function command '%s' \
returns error !", uname_cmd);
/* java version */
INFO("* Java version :\n");
- char lspci_cmd[MAXLEN] = "java -version";
+ char const *const lspci_cmd = "java -version";
fflush(stdout);
if(system(lspci_cmd) < 0) {
static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
{
- char type[MAXLEN];
- char proxy[MAXLEN];
- char line[MAXLEN];
+ char type[DEFAULTBUFLEN];
+ char proxy[DEFAULTBUFLEN];
+ char line[DEFAULTBUFLEN];
FILE *fp_pacfile;
char *p = NULL;
CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxySettings,
kSCPropNetProxiesProxyAutoConfigURLString);
if (pacURL) {
- char url[MAXLEN] = {};
+ char url[DEFAULTBUFLEN] = {};
CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII);
INFO("pac address: %s\n", (char*)url);
download_url(url);
fp_pacfile = fopen(pac_tempfile, "r");
if(fp_pacfile != NULL) {
- while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
+ while(fgets(line, DEFAULTBUFLEN, fp_pacfile) != NULL) {
if( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
INFO("line found %s", line);
sscanf(line, "%*[^\"]\"%s %s", type, proxy);
proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPPort);
port = cfnumber_to_int(proxyPort);
// Save hostname & port
- snprintf(http_proxy, MAXLEN, "%s:%d", hostname, port);
+ snprintf(http_proxy, DEFAULTBUFLEN, "%s:%d", hostname, port);
free(hostname);
} else {
proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesHTTPSPort);
port = cfnumber_to_int(proxyPort);
// Save hostname & port
- snprintf(https_proxy, MAXLEN, "%s:%d", hostname, port);
+ snprintf(https_proxy, DEFAULTBUFLEN, "%s:%d", hostname, port);
free(hostname);
} else {
proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesFTPPort);
port = cfnumber_to_int(proxyPort);
// Save hostname & port
- snprintf(ftp_proxy, MAXLEN, "%s:%d", hostname, port);
+ snprintf(ftp_proxy, DEFAULTBUFLEN, "%s:%d", hostname, port);
free(hostname);
} else {
proxyPort = CFDictionaryGetValue(proxySettings, kSCPropNetProxiesSOCKSPort);
port = cfnumber_to_int(proxyPort);
// Save hostname & port
- snprintf(socks_proxy, MAXLEN, "%s:%d", hostname, port);
+ snprintf(socks_proxy, DEFAULTBUFLEN, "%s:%d", hostname, port);
free(hostname);
} else {
base_port = get_emul_vm_base_port();
- g_shmid = shmget((key_t)base_port, MAXLEN, 0666|IPC_CREAT);
+ g_shmid = shmget((key_t)base_port, getpagesize(), 0666|IPC_CREAT);
if (g_shmid == -1) {
ERR("shmget failed\n");
perror("osutil-linux: ");
/* get linux distribution information */
INFO("* Linux distribution infomation :\n");
- const gchar lsb_release_cmd[MAXLEN] = "lsb_release -d -r -c";
+ char const *const lsb_release_cmd = "lsb_release -d -r -c";
gchar *buffer = NULL;
gint buffer_size = strlen(lsb_release_cmd) + 1;
/* pci device description */
INFO("* Host PCI devices :\n");
- const gchar lspci_cmd[MAXLEN] = "lspci";
+ char const *const lspci_cmd = "lspci";
buffer_size = strlen(lspci_cmd) + 1;
buffer = g_malloc(buffer_size);
static void process_string(char *buf)
{
- char tmp_buf[MAXLEN];
+ char tmp_buf[DEFAULTBUFLEN];
/* remove single quotes of strings gotten by gsettings */
if (gproxytool == GSETTINGS) {
remove_string(buf, tmp_buf, "\'");
- memset(buf, 0, MAXLEN);
+ memset(buf, 0, DEFAULTBUFLEN);
strncpy(buf, tmp_buf, strlen(tmp_buf)-1);
}
}
static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
{
- char type[MAXLEN];
- char proxy[MAXLEN];
- char line[MAXLEN];
+ char type[DEFAULTBUFLEN];
+ char proxy[DEFAULTBUFLEN];
+ char line[DEFAULTBUFLEN];
FILE *fp_pacfile;
char *p = NULL;
FILE *output;
- char buf[MAXLEN];
+ char buf[DEFAULTBUFLEN];
output = popen(gproxycmds[GNOME_PROXY_AUTOCONFIG_URL][gproxytool], "r");
if (fscanf(output, "%s", buf) > 0) {
pclose(output);
fp_pacfile = fopen(pac_tempfile, "r");
if (fp_pacfile != NULL) {
- while (fgets(line, MAXLEN, fp_pacfile) != NULL) {
+ while (fgets(line, DEFAULTBUFLEN, fp_pacfile) != NULL) {
if ((strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
INFO("line found %s", line);
sscanf(line, "%*[^\"]\"%s %s", type, proxy);
static void get_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
{
- char buf[MAXLEN] = {0,};
+ char buf[DEFAULTBUFLEN] = {0,};
char buf_port[MAXPORTLEN] = {0,};
- char buf_proxy[MAXLEN] = {0,};
+ char buf_proxy[DEFAULTBUFLEN] = {0,};
char *buf_proxy_bak;
char *proxy;
FILE *output;
- int MAXPROXYLEN = MAXLEN + MAXPORTLEN;
+ int MAXPROXYLEN = DEFAULTBUFLEN + MAXPORTLEN;
output = popen(gproxycmds[GNOME_PROXY_HTTP_HOST][gproxytool], "r");
if(fscanf(output, "%s", buf) > 0) {
process_string(buf);
- snprintf(buf_proxy, MAXLEN, "%s", buf);
+ snprintf(buf_proxy, DEFAULTBUFLEN, "%s", buf);
}
pclose(output);
buf_proxy_bak = getenv("http_proxy");
INFO("http_proxy from env: %s\n", buf_proxy_bak);
if(buf_proxy_bak != NULL) {
- proxy = malloc(MAXLEN);
+ proxy = malloc(DEFAULTBUFLEN);
remove_string(buf_proxy_bak, proxy, HTTP_PREFIX);
strncpy(http_proxy, proxy, strlen(proxy)-1);
INFO("final http_proxy value: %s\n", http_proxy);
}
else {
snprintf(http_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf_port);
- memset(buf_proxy, 0, MAXLEN);
+ memset(buf_proxy, 0, DEFAULTBUFLEN);
INFO("http_proxy: %s\n", http_proxy);
}
pclose(output);
- memset(buf, 0, MAXLEN);
+ memset(buf, 0, DEFAULTBUFLEN);
output = popen(gproxycmds[GNOME_PROXY_HTTPS_HOST][gproxytool], "r");
if(fscanf(output, "%s", buf) > 0) {
process_string(buf);
- snprintf(buf_proxy, MAXLEN, "%s", buf);
+ snprintf(buf_proxy, DEFAULTBUFLEN, "%s", buf);
}
pclose(output);
snprintf(https_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
}
pclose(output);
- memset(buf, 0, MAXLEN);
- memset(buf_proxy, 0, MAXLEN);
+ memset(buf, 0, DEFAULTBUFLEN);
+ memset(buf_proxy, 0, DEFAULTBUFLEN);
INFO("https_proxy : %s\n", https_proxy);
output = popen(gproxycmds[GNOME_PROXY_FTP_HOST][gproxytool], "r");
if(fscanf(output, "%s", buf) > 0) {
process_string(buf);
- snprintf(buf_proxy, MAXLEN, "%s", buf);
+ snprintf(buf_proxy, DEFAULTBUFLEN, "%s", buf);
}
pclose(output);
snprintf(ftp_proxy, MAXPROXYLEN, "%s:%s", buf_proxy, buf);
}
pclose(output);
- memset(buf, 0, MAXLEN);
- memset(buf_proxy, 0, MAXLEN);
+ memset(buf, 0, DEFAULTBUFLEN);
+ memset(buf_proxy, 0, DEFAULTBUFLEN);
INFO("ftp_proxy : %s\n", ftp_proxy);
output = popen(gproxycmds[GNOME_PROXY_SOCKS_HOST][gproxytool], "r");
if(fscanf(output, "%s", buf) > 0) {
process_string(buf);
- snprintf(buf_proxy, MAXLEN, "%s", buf);
+ snprintf(buf_proxy, DEFAULTBUFLEN, "%s", buf);
}
pclose(output);
void get_host_proxy_os(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
{
- char buf[MAXLEN];
+ char buf[DEFAULTBUFLEN];
FILE *output;
int ret;
*/
#include <png.h>
-#include "maru_common.h"
+#include "emulator_common.h"
#include "osutil.h"
#include "emulator.h"
+#include "emul_state.h"
#include "debug_ch.h"
#include "maru_err_table.h"
#include "sdb.h"
static int get_auto_proxy(BYTE *url, char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
{
- char type[MAXLEN];
- char proxy[MAXLEN];
- char line[MAXLEN];
+ char type[DEFAULTBUFLEN];
+ char proxy[DEFAULTBUFLEN];
+ char line[DEFAULTBUFLEN];
FILE *fp_pacfile;
char *p = NULL;
fp_pacfile = fopen(pactempfile, "r");
if (fp_pacfile != NULL) {
- while(fgets(line, MAXLEN, fp_pacfile) != NULL) {
+ while(fgets(line, DEFAULTBUFLEN, fp_pacfile) != NULL) {
if ( (strstr(line, "return") != NULL) && (strstr(line, "if") == NULL)) {
INFO("line found %s", line);
sscanf(line, "%*[^\"]\"%s %s", type, proxy);
}
INFO("proxy value: %s\n", (char *)proxyserver);
- real_proxy = malloc(MAXLEN);
+ real_proxy = malloc(DEFAULTBUFLEN);
if (real_proxy == NULL) {
ERR("Failed to allocate a buffer\n");
free(proxyserver);
#define DIRECT "DIRECT"
#define PROXY "PROXY"
#define MAXPORTLEN 6
+#define DEFAULTBUFLEN 512
#define GNOME_PROXY_MODE 0
#define GNOME_PROXY_AUTOCONFIG_URL 1