diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-03-26 21:05:43 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-26 21:26:01 +0800 |
commit | faadfe2b93db0976952b13a7870074ac8979bcd9 (patch) | |
tree | 047dd39a3e755e4f992ee8a56278f270ffae6b24 | |
parent | d788f6688c5ef80a115fd13be4cf40ee16a85389 (diff) |
debug: remove unneeded 'number' member of 'struct debug_info_cat'
As the debug subsystem number is used as index into the debug_info_cat
array, there is no need to store the number explicitly inside the
structure again.
-rw-r--r-- | include/osmocore/debug.h | 1 | ||||
-rw-r--r-- | src/debug.c | 15 |
2 files changed, 5 insertions, 11 deletions
diff --git a/include/osmocore/debug.h b/include/osmocore/debug.h index a1658314..0caec283 100644 --- a/include/osmocore/debug.h +++ b/include/osmocore/debug.h @@ -48,7 +48,6 @@ struct debug_info_cat { const char *name; const char *color; const char *description; - int number; uint8_t loglevel; uint8_t enabled; }; diff --git a/src/debug.c b/src/debug.c index d10861f8..19fc3058 100644 --- a/src/debug.c +++ b/src/debug.c @@ -59,7 +59,7 @@ int debug_parse_category(const char *category) for (i = 0; i < debug_info->num_cat; ++i) { if (!strcasecmp(debug_info->cat[i].name+1, category)) - return debug_info->cat[i].number; + return i; } return -EINVAL; @@ -91,14 +91,13 @@ void debug_parse_category_mask(struct debug_target* target, const char *_mask) if (strncasecmp(debug_info->cat[i].name, category_token, length) == 0) { - int number = debug_info->cat[i].number; int level = 0; if (colon) level = atoi(colon+1); - target->categories[number].enabled = 1; - target->categories[number].loglevel = level; + target->categories[i].enabled = 1; + target->categories[i].loglevel = level; } } } while ((category_token = strtok(NULL, ":"))); @@ -108,12 +107,8 @@ void debug_parse_category_mask(struct debug_target* target, const char *_mask) static const char* color(int subsys) { - int i = 0; - - for (i = 0; i < debug_info->num_cat; ++i) { - if (debug_info->cat[i].number == subsys) - return debug_info->cat[i].color; - } + if (subsys < debug_info->num_cat) + return debug_info->cat[subsys].color; return NULL; } |