Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Both true and false are now reserved words in a modern ANSI C #3587

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

lemenkov
Copy link
Contributor

Summary
Both true and false are now reserved words in a modern ANSI C. This prevents the following compile error:

Compiling statistics.c
gcc -fPIC -DPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fgnu89-inline -DMOD_NAME='statistics' -DPKG_MALLOC  -DSHM_MMAP  -DUSE_MCAST  -DDISABLE_NAGLE  -DSTATISTICS  -DHAVE_RESOLV_RES  -DF_MALLOC  -DQ_MALLOC  -DHP_MALLOC  -DDBG_MALLOC  -DHAVE_STDATOMIC -DHAVE_GENERICS  -DNAME='"opensips"' -DVERSION='"3.5.4"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 15"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/etc/opensips/"'  -DVERSIONTYPE='"git"' -DTHISREVISION='"5ebf81d1d"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT -c stats_funcs.c -o stats_funcs.o
gcc -fPIC -DPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fgnu89-inline -DMOD_NAME='statistics' -DPKG_MALLOC  -DSHM_MMAP  -DUSE_MCAST  -DDISABLE_NAGLE  -DSTATISTICS  -DHAVE_RESOLV_RES  -DF_MALLOC  -DQ_MALLOC  -DHP_MALLOC  -DDBG_MALLOC  -DHAVE_STDATOMIC -DHAVE_GENERICS  -DNAME='"opensips"' -DVERSION='"3.5.4"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 15"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/etc/opensips/"'  -DVERSIONTYPE='"git"' -DTHISREVISION='"5ebf81d1d"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT -c statistics.c -o statistics.o
statistics.c:101:31: error: expected identifier or ‘(’ before ‘true’
  101 |                 unsigned long true;
      |                               ^~~~
statistics.c:102:31: error: expected identifier or ‘(’ before ‘false’
  102 |                 unsigned long false;
      |                               ^~~~~
statistics.c:103:9: warning: no semicolon at end of struct or union
  103 |         } perc;
      |         ^
statistics.c: In function ‘reset_stat_series_slot’:
statistics.c:922:40: error: expected identifier before ‘true’
  922 |                         ss->cache.perc.true -= slot->perc.true;
      |                                        ^~~~
statistics.c:923:40: error: expected identifier before ‘false’
  923 |                         ss->cache.perc.false -= slot->perc.false;
      |                                        ^~~~~
statistics.c: In function ‘get_stat_series’:
statistics.c:987:48: error: expected identifier before ‘true’
  987 |                         total = ss->cache.perc.true + ss->cache.perc.false;
      |                                                ^~~~
statistics.c:989:54: error: expected identifier before ‘true’
  989 |                                 ret = ss->cache.perc.true * ss->profile->factor / total;
      |                                                      ^~~~
statistics.c: In function ‘update_stat_series’:
statistics.c:1075:41: error: expected identifier before ‘true’
 1075 |                                 s->perc.true += value;
      |                                         ^~~~
statistics.c:1076:48: error: expected identifier before ‘true’
 1076 |                                 ss->cache.perc.true += value;
      |                                                ^~~~
statistics.c:1078:41: error: expected identifier before ‘false’
 1078 |                                 s->perc.false -= value;
      |                                         ^~~~~
statistics.c:1079:48: error: expected identifier before ‘false’
 1079 |                                 ss->cache.perc.false -= value;
      |                                                ^~~~~
make[1]: Leaving directory '/builddir/build/BUILD/opensips-3.5.4-build/opensips-3.5.4/modules/statistics'
make[1]: *** [../../Makefile.rules:27: statistics.o] Error 1
make: *** [Makefile:198: modules] Error 2

This prevents the following compile error:

```
Compiling statistics.c
gcc -fPIC -DPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fgnu89-inline -DMOD_NAME='statistics' -DPKG_MALLOC  -DSHM_MMAP  -DUSE_MCAST  -DDISABLE_NAGLE  -DSTATISTICS  -DHAVE_RESOLV_RES  -DF_MALLOC  -DQ_MALLOC  -DHP_MALLOC  -DDBG_MALLOC  -DHAVE_STDATOMIC -DHAVE_GENERICS  -DNAME='"opensips"' -DVERSION='"3.5.4"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 15"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/etc/opensips/"'  -DVERSIONTYPE='"git"' -DTHISREVISION='"5ebf81d1d"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT -c stats_funcs.c -o stats_funcs.o
gcc -fPIC -DPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fgnu89-inline -DMOD_NAME='statistics' -DPKG_MALLOC  -DSHM_MMAP  -DUSE_MCAST  -DDISABLE_NAGLE  -DSTATISTICS  -DHAVE_RESOLV_RES  -DF_MALLOC  -DQ_MALLOC  -DHP_MALLOC  -DDBG_MALLOC  -DHAVE_STDATOMIC -DHAVE_GENERICS  -DNAME='"opensips"' -DVERSION='"3.5.4"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 15"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/etc/opensips/"'  -DVERSIONTYPE='"git"' -DTHISREVISION='"5ebf81d1d"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT -c statistics.c -o statistics.o
statistics.c:101:31: error: expected identifier or ‘(’ before ‘true’
  101 |                 unsigned long true;
      |                               ^~~~
statistics.c:102:31: error: expected identifier or ‘(’ before ‘false’
  102 |                 unsigned long false;
      |                               ^~~~~
statistics.c:103:9: warning: no semicolon at end of struct or union
  103 |         } perc;
      |         ^
statistics.c: In function ‘reset_stat_series_slot’:
statistics.c:922:40: error: expected identifier before ‘true’
  922 |                         ss->cache.perc.true -= slot->perc.true;
      |                                        ^~~~
statistics.c:923:40: error: expected identifier before ‘false’
  923 |                         ss->cache.perc.false -= slot->perc.false;
      |                                        ^~~~~
statistics.c: In function ‘get_stat_series’:
statistics.c:987:48: error: expected identifier before ‘true’
  987 |                         total = ss->cache.perc.true + ss->cache.perc.false;
      |                                                ^~~~
statistics.c:989:54: error: expected identifier before ‘true’
  989 |                                 ret = ss->cache.perc.true * ss->profile->factor / total;
      |                                                      ^~~~
statistics.c: In function ‘update_stat_series’:
statistics.c:1075:41: error: expected identifier before ‘true’
 1075 |                                 s->perc.true += value;
      |                                         ^~~~
statistics.c:1076:48: error: expected identifier before ‘true’
 1076 |                                 ss->cache.perc.true += value;
      |                                                ^~~~
statistics.c:1078:41: error: expected identifier before ‘false’
 1078 |                                 s->perc.false -= value;
      |                                         ^~~~~
statistics.c:1079:48: error: expected identifier before ‘false’
 1079 |                                 ss->cache.perc.false -= value;
      |                                                ^~~~~
make[1]: Leaving directory '/builddir/build/BUILD/opensips-3.5.4-build/opensips-3.5.4/modules/statistics'
make[1]: *** [../../Makefile.rules:27: statistics.o] Error 1
make: *** [Makefile:198: modules] Error 2
```

Signed-off-by: Peter Lemenkov <[email protected]>
@razvancrainea razvancrainea merged commit 495fe32 into OpenSIPS:master Feb 20, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants