aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/gprs_gb_parse.h
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-01 11:55:11 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-02 09:53:18 +0200
commit48bb3a37da6d0c9257b5cbb7bd2c6816b4ec5ab0 (patch)
tree68f9c16df4248cc544855bed4644c0065a2e7c64 /openbsc/include/openbsc/gprs_gb_parse.h
parente3283ec3eb8d74423694ff5d54838ca6205f6991 (diff)
gbproxy: Remove nonnull attributes
The compiler also uses this attribute for code elimination. If the nonnull attribute has been given erroneously for an parameter, that is later been checked against NULL, this check is removed silently by the gcc if optimization is enabled. This can lead to hard-to-find segmentation violation faults. To be on the safe side, this patch removes all uses of the nonnull attribute in openbsc. Compiler: - gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1): no warning, segfault - clang 3.4 (3.4-1ubuntu3): no warning, no segfault, asm ok Example: /* foo.c */ int f(int* p) __attribute((nonnull)); int f(int *p) { if (!p) return 0; return *p; } /* main.c */ int f(int* p) __attribute((nonnull)); int g () { return f(arg); } int main() { return g(NULL); } When these files are compiled into an executable, no warnungs are issued but it will fail with a segfault when -O2 is used (unless LTO is active). Compiler output (gcc -O2): int f(int *p) { 0: 8b 44 24 04 mov 0x4(%esp),%eax 4: 8b 00 mov (%eax),%eax 6: c3 ret } Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/include/openbsc/gprs_gb_parse.h')
-rw-r--r--openbsc/include/openbsc/gprs_gb_parse.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/gprs_gb_parse.h b/openbsc/include/openbsc/gprs_gb_parse.h
index e5ef4ef43..0aa364765 100644
--- a/openbsc/include/openbsc/gprs_gb_parse.h
+++ b/openbsc/include/openbsc/gprs_gb_parse.h
@@ -40,13 +40,13 @@ struct gprs_gb_parse_context {
};
int gprs_gb_parse_dtap(uint8_t *data, size_t data_len,
- struct gprs_gb_parse_context *parse_ctx) __attribute__((nonnull));
+ struct gprs_gb_parse_context *parse_ctx);
int gprs_gb_parse_llc(uint8_t *llc, size_t llc_len,
- struct gprs_gb_parse_context *parse_ctx) __attribute__((nonnull));
+ struct gprs_gb_parse_context *parse_ctx);
int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len,
- struct gprs_gb_parse_context *parse_ctx) __attribute__((nonnull));
+ struct gprs_gb_parse_context *parse_ctx);
void gprs_gb_log_parse_context(struct gprs_gb_parse_context *parse_ctx,
- const char *default_msg_name) __attribute__((nonnull(1)));
+ const char *default_msg_name);