osmo-msc/openbsc/include
Jacob Erlbeck 48bb3a37da 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
2014-09-02 09:53:18 +02:00
..
openbsc gbproxy: Remove nonnull attributes 2014-09-02 09:53:18 +02:00
Makefile.am use new external libosmogb (part of libosmocore.git) 2012-06-17 23:34:34 +08:00
compat_af_isdn.h move openbsc into its own subdirectory 2009-06-10 05:40:52 +08:00
mISDNif.h move openbsc into its own subdirectory 2009-06-10 05:40:52 +08:00