X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=common%2Fcommon.c;h=68f537ba0187c08f0f5bfc89fdf83df6babe8d20;hb=6d224992f91f8bb689b43cb745b9ca55007495bf;hp=cf31aecc13f91505209d8202774bbfa423eca7af;hpb=85cd02cf3c1ded45ef8664ae3be7728ba1f05af6;p=babeltrace.git diff --git a/common/common.c b/common/common.c index cf31aecc..68f537ba 100644 --- a/common/common.c +++ b/common/common.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -194,7 +194,7 @@ int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs) const char *end; size_t init_dirs_len; - assert(dirs); + BT_ASSERT(dirs); init_dirs_len = dirs->len; if (!paths) { @@ -577,7 +577,7 @@ bool bt_common_string_is_printable(const char *input) { const char *ch; bool printable = true; - assert(input); + BT_ASSERT(input); for (ch = input; *ch != '\0'; ch++) { if (!isprint(*ch) && *ch != '\n' && *ch != '\r' && @@ -631,7 +631,7 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( const char *at = url; size_t end_pos; - assert(url); + BT_ASSERT(url); memset(&parts, 0, sizeof(parts)); parts.port = -1; @@ -800,7 +800,7 @@ void bt_common_normalize_star_glob_pattern(char *pattern) char *np; bool got_star = false; - assert(pattern); + BT_ASSERT(pattern); for (p = pattern, np = pattern; *p != '\0'; p++) { switch (*p) { @@ -822,7 +822,7 @@ void bt_common_normalize_star_glob_pattern(char *pattern) goto end; } - /* Fall through default case. */ + /* fall-through */ default: got_star = false; break; @@ -1008,7 +1008,7 @@ retry: * ^ ^ SUCCESS */ while ((c - candidate) < candidate_len && *c != '\0') { - assert(*c); + BT_ASSERT(*c); if (at_end_of_pattern(p, pattern, pattern_len)) { goto end_of_pattern; @@ -1042,6 +1042,7 @@ retry: * Fall through the default case which compares * the escaped character now. */ + /* fall-through */ default: if (at_end_of_pattern(p, pattern, pattern_len) || *c != *p) { @@ -1097,7 +1098,7 @@ void append_path_parts(const char *path, GPtrArray *parts) if (ch - last > 0) { GString *part = g_string_new(NULL); - assert(part); + BT_ASSERT(part); g_string_append_len(part, last, ch - last); g_ptr_array_add(parts, part); } @@ -1126,7 +1127,7 @@ GString *bt_common_normalize_path(const char *path, const char *wd) char *tmp; GString *norm_path = NULL; - assert(path); + BT_ASSERT(path); tmp = _fullpath(NULL, path, PATH_MAX); if (!tmp) { @@ -1158,7 +1159,7 @@ GString *bt_common_normalize_path(const char *path, const char *wd) GString *norm_path; GPtrArray *parts = NULL; - assert(path); + BT_ASSERT(path); norm_path = g_string_new(G_DIR_SEPARATOR_S); if (!norm_path) { goto error; @@ -1260,7 +1261,7 @@ size_t bt_common_get_page_size(void) strncpy(_tmp_fmt, *out_fmt_ch, _tmp_fmt_size); \ _tmp_fmt[_tmp_fmt_size] = '\0'; \ _count = snprintf(*buf_ch, _size, _tmp_fmt, __VA_ARGS__); \ - assert(_count >= 0); \ + BT_ASSERT(_count >= 0); \ *buf_ch += MIN(_count, _size); \ } while (0) @@ -1334,28 +1335,28 @@ static inline void handle_conversion_specifier_std(char *buf, char **buf_ch, } /* format (PRI*64) */ - if (strncmp(fmt_ch, PRId64, sizeof(PRId64)) == 0) { - fmt_ch += sizeof(PRId64); + if (strncmp(fmt_ch, PRId64, sizeof(PRId64) - 1) == 0) { + fmt_ch += sizeof(PRId64) - 1; BUF_STD_APPEND_SINGLE_ARG(int64_t); goto update_rw_fmt; - } else if (strncmp(fmt_ch, PRIu64, sizeof(PRIu64)) == 0) { - fmt_ch += sizeof(PRIu64); + } else if (strncmp(fmt_ch, PRIu64, sizeof(PRIu64) - 1) == 0) { + fmt_ch += sizeof(PRIu64) - 1; BUF_STD_APPEND_SINGLE_ARG(uint64_t); goto update_rw_fmt; - } else if (strncmp(fmt_ch, PRIx64, sizeof(PRIx64)) == 0) { - fmt_ch += sizeof(PRIx64); + } else if (strncmp(fmt_ch, PRIx64, sizeof(PRIx64) - 1) == 0) { + fmt_ch += sizeof(PRIx64) - 1; BUF_STD_APPEND_SINGLE_ARG(uint64_t); goto update_rw_fmt; - } else if (strncmp(fmt_ch, PRIX64, sizeof(PRIX64)) == 0) { - fmt_ch += sizeof(PRIX64); + } else if (strncmp(fmt_ch, PRIX64, sizeof(PRIX64) - 1) == 0) { + fmt_ch += sizeof(PRIX64) - 1; BUF_STD_APPEND_SINGLE_ARG(uint64_t); goto update_rw_fmt; - } else if (strncmp(fmt_ch, PRIo64, sizeof(PRIo64)) == 0) { - fmt_ch += sizeof(PRIo64); + } else if (strncmp(fmt_ch, PRIo64, sizeof(PRIo64) - 1) == 0) { + fmt_ch += sizeof(PRIo64) - 1; BUF_STD_APPEND_SINGLE_ARG(uint64_t); goto update_rw_fmt; - } else if (strncmp(fmt_ch, PRIi64, sizeof(PRIi64)) == 0) { - fmt_ch += sizeof(PRIi64); + } else if (strncmp(fmt_ch, PRIi64, sizeof(PRIi64) - 1) == 0) { + fmt_ch += sizeof(PRIi64) - 1; BUF_STD_APPEND_SINGLE_ARG(int64_t); goto update_rw_fmt; } @@ -1519,14 +1520,13 @@ void bt_common_custom_vsnprintf(char *buf, size_t buf_size, const char *fmt_ch = fmt; char *buf_ch = buf; - assert(buf); - assert(fmt); - assert(*args); + BT_ASSERT(buf); + BT_ASSERT(fmt); while (*fmt_ch != '\0') { switch (*fmt_ch) { case '%': - assert(fmt_ch[1] != '\0'); + BT_ASSERT(fmt_ch[1] != '\0'); if (fmt_ch[1] == intro) { handle_specifier(priv_data, &buf_ch,