From: Pablo Neira Ayuso pablo@gnumonks.org
This patchset fixes the namespace pollution spotted by Harald:
* bcd2char, char2bcd -> osmo_bcd2char, osmo_char2bcd * crc16 -> osmo_crc16 * generate_backtrace -> osmo_generate_backtrace * plugin_load_all -> osmo_plugin_load_all * msg_entry_parse -> osmo_config_list
This patchset is a follow up, it comes after:
[PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try
You can find the whole branch at pablo/namespace.
Please, merge it. Thanks!
Pablo Neira Ayuso (4): crc: use namespace prefix osmo_* backtrace: use namespace prefix osmo_* plugin: use namespace prefix osmo_* msgfile: use namespace prefix osmo_* and use more descriptive names
include/osmocom/core/backtrace.h | 2 +- include/osmocom/core/crc16.h | 8 ++++---- include/osmocom/core/msgfile.h | 8 ++++---- include/osmocom/core/plugin.h | 2 +- src/backtrace.c | 2 +- src/crc16.c | 6 +++--- src/gsm/gprs_cipher_core.c | 2 +- src/msgfile.c | 22 ++++++++++++---------- src/panic.c | 2 +- src/plugin.c | 4 ++-- tests/msgfile/msgfile_test.c | 8 ++++---- 11 files changed, 34 insertions(+), 32 deletions(-)
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/crc16_table/osmo_crc16_table/g s/crc16/osmo_crc16/g s/crc16_byte/osmo_crc16_byte/g --- include/osmocom/core/crc16.h | 8 ++++---- src/crc16.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/osmocom/core/crc16.h b/include/osmocom/core/crc16.h index 7a51249..0e52417 100644 --- a/include/osmocom/core/crc16.h +++ b/include/osmocom/core/crc16.h @@ -22,13 +22,13 @@
#include <sys/types.h>
-extern uint16_t const crc16_table[256]; +extern uint16_t const osmo_crc16_table[256];
-extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len); +extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len);
-static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data) +static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data) { - return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; + return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff]; }
#endif /* __CRC16_H */ diff --git a/src/crc16.c b/src/crc16.c index 3a0d0dd..2741cf5 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -11,7 +11,7 @@ #include <osmocom/core/crc16.h>
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ -uint16_t const crc16_table[256] = { +uint16_t const osmo_crc16_table[256] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, @@ -54,9 +54,9 @@ uint16_t const crc16_table[256] = { * * Returns the updated CRC value. */ -uint16_t crc16(uint16_t crc, uint8_t const *buffer, size_t len) +uint16_t osmo_crc16(uint16_t crc, uint8_t const *buffer, size_t len) { while (len--) - crc = crc16_byte(crc, *buffer++); + crc = osmo_crc16_byte(crc, *buffer++); return crc; }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/backtrace/osmo_backtrace/g --- include/osmocom/core/backtrace.h | 2 +- src/backtrace.c | 2 +- src/panic.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h index bbbb2c2..5a8a816 100644 --- a/include/osmocom/core/backtrace.h +++ b/include/osmocom/core/backtrace.h @@ -1,6 +1,6 @@ #ifndef _OSMO_BACKTRACE_H_ #define _OSMO_BACKTRACE_H_
-void generate_backtrace(); +void osmo_generate_backtrace();
#endif diff --git a/src/backtrace.c b/src/backtrace.c index ecd6b9c..8281fad 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -29,7 +29,7 @@
#ifdef HAVE_EXECINFO_H #include <execinfo.h> -void generate_backtrace() +void osmo_generate_backtrace() { int i, nptrs; void *buffer[100]; diff --git a/src/panic.c b/src/panic.c index 588a5fe..d445226 100644 --- a/src/panic.c +++ b/src/panic.c @@ -38,7 +38,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0; static void osmo_panic_default(const char *fmt, va_list args) { vfprintf(stderr, fmt, args); - generate_backtrace(); + osmo_generate_backtrace(); abort(); }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/plugin_load_all/osmo_plugin_load_all/g --- include/osmocom/core/plugin.h | 2 +- src/gsm/gprs_cipher_core.c | 2 +- src/plugin.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/osmocom/core/plugin.h b/include/osmocom/core/plugin.h index 98f9b56..6c0eccc 100644 --- a/include/osmocom/core/plugin.h +++ b/include/osmocom/core/plugin.h @@ -1,6 +1,6 @@ #ifndef _OSMO_PLUGIN_H #define _OSMO_PLUGIN_H
-int plugin_load_all(const char *directory); +int osmo_plugin_load_all(const char *directory);
#endif diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c index 0ff85e2..7884be0 100644 --- a/src/gsm/gprs_cipher_core.c +++ b/src/gsm/gprs_cipher_core.c @@ -53,7 +53,7 @@ int gprs_cipher_register(struct gprs_cipher_impl *ciph) int gprs_cipher_load(const char *path) { /* load all plugins available from path */ - return plugin_load_all(path); + return osmo_plugin_load_all(path); }
/* function to be called by core code */ diff --git a/src/plugin.c b/src/plugin.c index 4d9fd31..998bca3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,7 +32,7 @@
#include <osmocom/core/plugin.h>
-int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { unsigned int num = 0; char fname[PATH_MAX]; @@ -55,7 +55,7 @@ int plugin_load_all(const char *directory) return num; } #else -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { return 0; }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/msg_entry/osmo_config_entry/g s/msg_entries/osmo_config_list/g s/msg_entry_parse/osmo_config_list_parse/g
minor glitch included in this patch while I was at it:
-#include "linuxlist.h" +#include <osmocom/core/linuxlist.h> --- include/osmocom/core/msgfile.h | 8 ++++---- src/msgfile.c | 22 ++++++++++++---------- tests/msgfile/msgfile_test.c | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/include/osmocom/core/msgfile.h b/include/osmocom/core/msgfile.h index 92caa9f..c5e67a4 100644 --- a/include/osmocom/core/msgfile.h +++ b/include/osmocom/core/msgfile.h @@ -22,12 +22,12 @@ #ifndef MSG_FILE_H #define MSG_FILE_H
-#include "linuxlist.h" +#include <osmocom/core/linuxlist.h>
/** * One message in the list. */ -struct msg_entry { +struct osmo_config_entry { struct llist_head list;
/* number for everyone to use */ @@ -40,10 +40,10 @@ struct msg_entry { char *text; };
-struct msg_entries { +struct osmo_config_list { struct llist_head entry; };
-struct msg_entries *msg_entry_parse(void *ctx, const char *filename); +struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename);
#endif diff --git a/src/msgfile.c b/src/msgfile.c index c13df51..d2b180d 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -29,11 +29,13 @@ #include <unistd.h> #include <string.h>
-static struct msg_entry *alloc_entry(struct msg_entries *entries, - const char *mcc, const char *mnc, - const char *option, const char *text) +static struct osmo_config_entry * +alloc_entry(struct osmo_config_list *entries, + const char *mcc, const char *mnc, + const char *option, const char *text) { - struct msg_entry *entry = talloc_zero(entries, struct msg_entry); + struct osmo_config_entry *entry = + talloc_zero(entries, struct osmo_config_entry); if (!entry) return NULL;
@@ -46,11 +48,11 @@ static struct msg_entry *alloc_entry(struct msg_entries *entries, return entry; }
-static struct msg_entries *alloc_entries(void *ctx) +static struct osmo_config_list *alloc_entries(void *ctx) { - struct msg_entries *entries; + struct osmo_config_list *entries;
- entries = talloc_zero(ctx, struct msg_entries); + entries = talloc_zero(ctx, struct osmo_config_list); if (!entries) return NULL;
@@ -61,7 +63,7 @@ static struct msg_entries *alloc_entries(void *ctx) /* * split a line like 'foo:Text'. */ -static void handle_line(struct msg_entries *entries, char *line) +static void handle_line(struct osmo_config_list *entries, char *line) { int i; const int len = strlen(line); @@ -91,9 +93,9 @@ static void handle_line(struct msg_entries *entries, char *line) /* nothing found */ }
-struct msg_entries *msg_entry_parse(void *ctx, const char *filename) +struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename) { - struct msg_entries *entries; + struct osmo_config_list *entries; size_t n; char *line; FILE *file; diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index 4637cea..ed7aa97 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -23,9 +23,9 @@
#include <stdio.h>
-static void dump_entries(struct msg_entries *entries) +static void dump_entries(struct osmo_config_list *entries) { - struct msg_entry *entry; + struct osmo_config_entry *entry;
if (!entries) { fprintf(stderr, "Failed to parse the file\n"); @@ -40,10 +40,10 @@ static void dump_entries(struct msg_entries *entries)
int main(int argc, char **argv) { - struct msg_entries *entries; + struct osmo_config_list *entries;
/* todo use msgfile_test.c.in and replace the path */ - entries = msg_entry_parse(NULL, "msgconfig.cfg"); + entries = osmo_config_list_parse(NULL, "msgconfig.cfg"); dump_entries(entries);
return 0;
On 07/05/11 13:22, pablo@gnumonks.org wrote:
From: Pablo Neira Ayuso pablo@gnumonks.org
This patchset fixes the namespace pollution spotted by Harald:
- bcd2char, char2bcd -> osmo_bcd2char, osmo_char2bcd
^^^^ Sorry, it seems I forgot to include this patch. Find this attached.
Thanks pablo,
I've applied your changes to libosmocore, tagged it as 0.3.0 and applied the changes to openbsc.
I'm now manually fixing up libosmo-sccp, osmo-tetra, cemmlgr-ng and other projects that all refer to libosmocore. I would appreciate if you could take care of osmcoom-bb.
Regards, Harald
On 08/05/11 09:51, Harald Welte wrote:
Thanks pablo,
I've applied your changes to libosmocore, tagged it as 0.3.0 and applied the changes to openbsc.
Thanks Harald.
I'm now manually fixing up libosmo-sccp, osmo-tetra, cemmlgr-ng and other projects that all refer to libosmocore. I would appreciate if you could take care of osmcoom-bb.
I will take care of that, of course.