diff options
author | Zhang zhengguang <zhengguang.zhang@intel.com> | 2014-07-17 10:37:39 +0800 |
---|---|---|
committer | Zhang zhengguang <zhengguang.zhang@intel.com> | 2014-07-17 10:37:39 +0800 |
commit | 1b9d0a62f59bb48c8deb2f0b98d9acdffdd9abe7 (patch) | |
tree | 6e991827d28537f7f40f20786c2354fd04a9fdad /src/log.c | |
parent | fbe905ab58ecc31fe64c410c5f580cadc30e7f04 (diff) | |
download | connman-1b9d0a62f59bb48c8deb2f0b98d9acdffdd9abe7.tar.gz connman-1b9d0a62f59bb48c8deb2f0b98d9acdffdd9abe7.tar.bz2 connman-1b9d0a62f59bb48c8deb2f0b98d9acdffdd9abe7.zip |
Imported Upstream version 1.24upstream/1.24
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -2,7 +2,7 @@ * * Connection Manager * - * Copyright (C) 2007-2012 Intel Corporation. All rights reserved. + * Copyright (C) 2007-2013 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -119,7 +119,7 @@ static void print_backtrace(unsigned int offset) int pathlen; pid_t pid; - if (program_exec == NULL) + if (!program_exec) return; pathlen = strlen(program_path); @@ -179,7 +179,7 @@ static void print_backtrace(unsigned int offset) if (written < 0) break; - len = read(infd[0], buf, sizeof(buf)); + len = read(infd[0], buf, sizeof(buf) - 1); if (len < 0) break; @@ -243,23 +243,23 @@ extern struct connman_debug_desc __stop___debug[]; static gchar **enabled = NULL; -static connman_bool_t is_enabled(struct connman_debug_desc *desc) +static bool is_enabled(struct connman_debug_desc *desc) { int i; - if (enabled == NULL) - return FALSE; + if (!enabled) + return false; - for (i = 0; enabled[i] != NULL; i++) { - if (desc->name != NULL && g_pattern_match_simple(enabled[i], - desc->name) == TRUE) - return TRUE; - if (desc->file != NULL && g_pattern_match_simple(enabled[i], - desc->file) == TRUE) - return TRUE; + for (i = 0; enabled[i]; i++) { + if (desc->name && g_pattern_match_simple(enabled[i], + desc->name)) + return true; + if (desc->file && g_pattern_match_simple(enabled[i], + desc->file)) + return true; } - return FALSE; + return false; } void __connman_log_enable(struct connman_debug_desc *start, @@ -268,7 +268,7 @@ void __connman_log_enable(struct connman_debug_desc *start, struct connman_debug_desc *desc; const char *name = NULL, *file = NULL; - if (start == NULL || stop == NULL) + if (!start || !stop) return; for (desc = start; desc < stop; desc++) { @@ -278,21 +278,21 @@ void __connman_log_enable(struct connman_debug_desc *start, continue; } - if (file != NULL || name != NULL) { + if (file || name) { if (g_strcmp0(desc->file, file) == 0) { - if (desc->name == NULL) + if (!desc->name) desc->name = name; } else file = NULL; } - if (is_enabled(desc) == TRUE) + if (is_enabled(desc)) desc->flags |= CONNMAN_DEBUG_FLAG_PRINT; } } int __connman_log_init(const char *program, const char *debug, - connman_bool_t detach, connman_bool_t backtrace, + gboolean detach, gboolean backtrace, const char *program_name, const char *program_version) { static char path[PATH_MAX]; @@ -301,15 +301,15 @@ int __connman_log_init(const char *program, const char *debug, program_exec = program; program_path = getcwd(path, sizeof(path)); - if (debug != NULL) + if (debug) enabled = g_strsplit_set(debug, ":, ", 0); __connman_log_enable(__start___debug, __stop___debug); - if (detach == FALSE) + if (!detach) option |= LOG_PERROR; - if (backtrace == TRUE) + if (backtrace) signal_setup(signal_handler); openlog(basename(program), option, LOG_DAEMON); @@ -319,13 +319,13 @@ int __connman_log_init(const char *program, const char *debug, return 0; } -void __connman_log_cleanup(connman_bool_t backtrace) +void __connman_log_cleanup(gboolean backtrace) { syslog(LOG_INFO, "Exit"); closelog(); - if (backtrace == TRUE) + if (backtrace) signal_setup(SIG_DFL); g_strfreev(enabled); |