Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- src/mtp_pcap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/mtp_pcap.c b/src/mtp_pcap.c index 052813f..9b6de81 100644 --- a/src/mtp_pcap.c +++ b/src/mtp_pcap.c @@ -51,7 +51,7 @@ struct pcaprec_hdr {
int mtp_pcap_write_header(int fd) { - static struct pcap_hdr hdr = { + static const struct pcap_hdr hdr = { .magic_number = 0xa1b2c3d4, .version_major = 2, .version_minor = 4,
This might not be the correct approach, but right now the context is always NULL, so remove the variable and push it as a constant instead.
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- src/m2ua_msg.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/src/m2ua_msg.c b/src/m2ua_msg.c index c04586f..af59376 100644 --- a/src/m2ua_msg.c +++ b/src/m2ua_msg.c @@ -26,14 +26,13 @@
#include <string.h>
-static void *tall_m2ua; static int DM2UA = -1;
struct m2ua_msg *m2ua_msg_alloc(void) { struct m2ua_msg *msg;
- msg = talloc_zero(tall_m2ua, struct m2ua_msg); + msg = talloc_zero(NULL, struct m2ua_msg); if (!msg) { LOGP(DM2UA, LOGL_ERROR, "Failed to allocate.\n"); return NULL;
On Wed, Jul 04, 2012 at 02:38:04PM -0700, Diego Elio Pettenò wrote:
This might not be the correct approach, but right now the context is always NULL, so remove the variable and push it as a constant instead.
Hi,
-static void *tall_m2ua;
if the four/eight byte per instance bother too much right now, then please use a define for now.
holger
Il 05/07/2012 12:56, Holger Hans Peter Freyther ha scritto:
if the four/eight byte per instance bother too much right now, then please use a define for now.
It's not for the bytes themselves (since it's uninitialised it's mapped to the zero page, which means that it doesn't really use up space). It's more about having code that seems to do one thing but is actually doing another..
On Thu, Jul 05, 2012 at 01:00:50PM +0200, Diego Elio Pettenò wrote:
It's not for the bytes themselves (since it's uninitialised it's mapped to the zero page, which means that it doesn't really use up space). It's more about having code that seems to do one thing but is actually doing another..
True, I will try to get my act together and initialize the talloc context.
This avoids recursing multiple times for no reason.
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- configure.ac | 3 --- include/Makefile.am | 8 +++++++- include/m2ua/Makefile.am | 2 -- include/mtp/Makefile.am | 2 -- include/sccp/Makefile.am | 2 -- 5 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 include/m2ua/Makefile.am delete mode 100644 include/mtp/Makefile.am delete mode 100644 include/sccp/Makefile.am
diff --git a/configure.ac b/configure.ac index 98a6b1f..ae35518 100644 --- a/configure.ac +++ b/configure.ac @@ -31,9 +31,6 @@ AC_SUBST(SYMBOL_VISIBILITY) AC_OUTPUT( libosmo-sccp.pc libosmo-mtp.pc - include/sccp/Makefile - include/mtp/Makefile - include/m2ua/Makefile include/Makefile src/Makefile tests/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 882d1e2..580d3a5 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,7 @@ -SUBDIRS = sccp mtp m2ua +pkgincludedir = $(includedir)/osmocom +nobase_pkginclude_HEADERS = m2ua/m2ua_msg.h \ + m2ua/m2ua_types.h \ + mtp/mtp_level3.h \ + mtp/mtp_pcap.h \ + sccp/sccp.h \ + sccp/sccp_types.h diff --git a/include/m2ua/Makefile.am b/include/m2ua/Makefile.am deleted file mode 100644 index d740a6c..0000000 --- a/include/m2ua/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -m2ua_HEADERS = m2ua_types.h m2ua_msg.h -m2uadir = $(includedir)/osmocom/m2ua diff --git a/include/mtp/Makefile.am b/include/mtp/Makefile.am deleted file mode 100644 index dbd0e79..0000000 --- a/include/mtp/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -mtp_HEADERS = mtp_level3.h mtp_pcap.h -mtpdir = $(includedir)/osmocom/mtp diff --git a/include/sccp/Makefile.am b/include/sccp/Makefile.am deleted file mode 100644 index c64db26..0000000 --- a/include/sccp/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -sccp_HEADERS = sccp_types.h sccp.h -sccpdir = $(includedir)/osmocom/sccp
Also disable building of gzip-compressed tarballs.
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- Makefile.am | 2 -- configure.ac | 2 +- 2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 51d65f8..5311609 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,3 @@ -AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 - INCLUDES = $(all_includes) -I$(top_srcdir)/include SUBDIRS = include src tests
diff --git a/configure.ac b/configure.ac index ae35518..4de05f2 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_INIT([libosmo-sccp], m4_esyscmd([./git-version-gen .tarball-version]), [openbsc@lists.osmocom.org])
-AM_INIT_AUTOMAKE([dist-bzip2]) +AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.6]) AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages
This makes the tests handling similar to the new one on libosmocore. Please note that mtp/mtp_parse_test does not have to be declared explicitly since it requires no library to be linked and the source filename matches the target's name.
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- .gitignore | 1 + configure.ac | 3 -- tests/Makefile.am | 54 +++++++++++++++++++++++++++++------------------ tests/m2ua/Makefile.am | 8 ------- tests/mtp/Makefile.am | 6 ----- tests/sccp/Makefile.am | 10 -------- 6 files changed, 34 insertions(+), 48 deletions(-) delete mode 100644 tests/m2ua/Makefile.am delete mode 100644 tests/mtp/Makefile.am delete mode 100644 tests/sccp/Makefile.am
diff --git a/.gitignore b/.gitignore index 65fb1ef..7cd3da2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.a .deps +.dirstamp Makefile Makefile.in bscconfig.h diff --git a/configure.ac b/configure.ac index 4de05f2..9fb5f5b 100644 --- a/configure.ac +++ b/configure.ac @@ -34,8 +34,5 @@ AC_OUTPUT( include/Makefile src/Makefile tests/Makefile - tests/sccp/Makefile - tests/mtp/Makefile - tests/m2ua/Makefile Makefile)
diff --git a/tests/Makefile.am b/tests/Makefile.am index d005e7b..276d306 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,40 +1,52 @@ -SUBDIRS = sccp mtp m2ua +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
# The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ - echo '# Signature of the current package.' && \ - echo 'm4_define([AT_PACKAGE_NAME],' && \ - echo ' [$(PACKAGE_NAME)])' && \ - echo 'm4_define([AT_PACKAGE_TARNAME],' && \ - echo ' [$(PACKAGE_TARNAME)])' && \ - echo 'm4_define([AT_PACKAGE_VERSION],' && \ - echo ' [$(PACKAGE_VERSION)])' && \ - echo 'm4_define([AT_PACKAGE_STRING],' && \ - echo ' [$(PACKAGE_STRING)])' && \ - echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ - echo ' [$(PACKAGE_BUGREPORT)])'; \ - echo 'm4_define([AT_PACKAGE_URL],' && \ - echo ' [$(PACKAGE_URL)])'; \ - } >'$(srcdir)/package.m4' - -EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ + m2ua/m2ua_test.ok mtp/mtp_parse_test.ok \ + sccp/sccp_test.ok + TESTSUITE = $(srcdir)/testsuite - + check-local: atconfig $(TESTSUITE) $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) - + installcheck-local: atconfig $(TESTSUITE) $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ $(TESTSUITEFLAGS) - + clean-local: test ! -f '$(TESTSUITE)' || \ $(SHELL) '$(TESTSUITE)' --clean $(RM) -f atconfig - + AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te AUTOTEST = $(AUTOM4TE) --language=autotest $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at mv $@.tmp $@ + +check_PROGRAMS = m2ua/m2ua_test mtp/mtp_parse_test sccp/sccp_test + +m2ua_m2ua_test_SOURCES = m2ua/m2ua_test.c +m2ua_m2ua_test_LDADD = $(top_builddir)/src/libm2ua.a $(LIBOSMOCORE_LIBS) + +sccp_sccp_test_SOURCES = sccp/sccp_test.c $(top_srcdir)/src/sccp.c +sccp_sccp_test_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/tests/m2ua/Makefile.am b/tests/m2ua/Makefile.am deleted file mode 100644 index 0eb8302..0000000 --- a/tests/m2ua/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall -AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) - -EXTRA_DIST = m2ua_test.ok - -noinst_PROGRAMS = m2ua_test -m2ua_test_SOURCES = m2ua_test.c -m2ua_test_LDADD = $(top_builddir)/src/libm2ua.a $(LIBOSMOCORE_LIBS) diff --git a/tests/mtp/Makefile.am b/tests/mtp/Makefile.am deleted file mode 100644 index 9e9292c..0000000 --- a/tests/mtp/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall -noinst_PROGRAMS = mtp_parse_test - -EXTRA_DIST = mtp_parse_test.ok - -mtp_parse_test_SOURCES = mtp_parse_test.c diff --git a/tests/sccp/Makefile.am b/tests/sccp/Makefile.am deleted file mode 100644 index 90790a3..0000000 --- a/tests/sccp/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) - -EXTRA_DIST = sccp_test.ok - -noinst_PROGRAMS = sccp_test - -sccp_test_SOURCES = sccp_test.c $(top_srcdir)/src/sccp.c -sccp_test_LDADD = $(LIBOSMOCORE_LIBS) -
This allows to use the function with constant arrays in the tests, the content is never modified so this is not introducing any unexpected behaviour.
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- include/m2ua/m2ua_msg.h | 2 +- src/m2ua_msg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/m2ua/m2ua_msg.h b/include/m2ua/m2ua_msg.h index e878edd..3a9da06 100644 --- a/include/m2ua/m2ua_msg.h +++ b/include/m2ua/m2ua_msg.h @@ -50,7 +50,7 @@ int m2ua_msg_add_data(struct m2ua_msg *msg, uint16_t tag, uint16_t len, uint8_t
struct m2ua_msg_part *m2ua_msg_find_tag(struct m2ua_msg *msg, uint16_t tag);
-struct m2ua_msg *m2ua_from_msg(uint16_t len, uint8_t *data); +struct m2ua_msg *m2ua_from_msg(uint16_t len, const uint8_t *data); struct msgb *m2ua_to_msg(struct m2ua_msg *msg);
void m2ua_set_log_area(int log_area); diff --git a/src/m2ua_msg.c b/src/m2ua_msg.c index af59376..4ca83a0 100644 --- a/src/m2ua_msg.c +++ b/src/m2ua_msg.c @@ -83,7 +83,7 @@ struct m2ua_msg_part *m2ua_msg_find_tag(struct m2ua_msg *m2ua, uint16_t tag) return NULL; }
-struct m2ua_msg *m2ua_from_msg(uint16_t len, uint8_t *data) +struct m2ua_msg *m2ua_from_msg(uint16_t len, const uint8_t *data) { struct m2ua_parameter_hdr *par; struct m2ua_common_hdr *hdr;
Signed-off-by: Diego Elio Pettenò flameeyes@flameeyes.eu --- tests/m2ua/m2ua_test.c | 10 +++++----- tests/sccp/sccp_test.c | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tests/m2ua/m2ua_test.c b/tests/m2ua/m2ua_test.c index d629ad5..b47bf5a 100644 --- a/tests/m2ua/m2ua_test.c +++ b/tests/m2ua/m2ua_test.c @@ -30,12 +30,12 @@ abort(); \ } while(0);
-static uint8_t asp_up[] = { +static const uint8_t asp_up[] = { 0x01, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x11, 0x00, 0x08, 0xac, 0x10, 0x01, 0x51, };
-static uint8_t data[] = { +static const uint8_t data[] = { 0x01, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1a, 0x81, 0x5c, 0x00, 0x07, @@ -49,12 +49,12 @@ static void test_asp_up(void) struct m2ua_msg_part *part; struct m2ua_msg *m2u = m2ua_from_msg(ARRAY_SIZE(asp_up), asp_up); struct msgb *msg = m2ua_to_msg(m2u); - const uint8_t res[] = { 0xac, 0x10, 0x01, 0x51 }; + static const uint8_t res[] = { 0xac, 0x10, 0x01, 0x51 };
printf("Testing ASP UP parsing.\n");
if (msg->len != ARRAY_SIZE(asp_up)) { - printf("Got %d wanted %d\n", msg->len, ARRAY_SIZE(asp_up)); + printf("Got %d wanted %zu\n", msg->len, ARRAY_SIZE(asp_up)); FAIL("Wrong size"); }
@@ -84,7 +84,7 @@ static void test_data(void) printf("Testing parsing of data.\n");
if (msg->len != ARRAY_SIZE(data)) { - printf("Got %d wanted %d\n", msg->len, ARRAY_SIZE(data)); + printf("Got %d wanted %zu\n", msg->len, ARRAY_SIZE(data)); FAIL("Wrong size"); }
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c index 7cff5d0..ea1b99b 100644 --- a/tests/sccp/sccp_test.c +++ b/tests/sccp/sccp_test.c @@ -991,7 +991,8 @@ static const struct log_info_cat default_categories[] = { }, };
-static int null_flt(void) +static int null_flt(const struct log_context *ctx, + struct log_target *tgt) { return 1; }