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

Compiler Warnings #703

Open
michaelortmann opened this Issue Oct 14, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@michaelortmann
Member

michaelortmann commented Oct 14, 2018

There were/are many compiler warnings, esp. with new versions of gcc, that i openen this issue to coordinate analysis and work to each of them. Some of them are already fixed by (pending) PRs.

The following findings are with current (moving) git version of eggdrop.

2. gcc 8.2.1, default cflags

gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  \
'-DCCFLAGS="gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS "' \
'-DLDFLAGS="gcc"' \
'-DSTRIPFLAGS="touch"' -c ./main.c
./main.c: In function ‘main’:
./main.c:1075:43: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 32 [-Wformat-truncation=]
   egg_snprintf(ver, sizeof ver, "eggdrop v%s", egg_version);
                                           ^~   ~~~~~~~~~~~
In file included from ./compat/compat.h:27,
                 from ./main.h:102,
                 from ./main.c:48:
./compat/snprintf.h:58:24: note: ‘snprintf’ output between 10 and 1033 bytes into a destination of size 41
 #  define egg_snprintf snprintf
./main.c:1075:3: note: in expansion of macro ‘egg_snprintf’
   egg_snprintf(ver, sizeof ver, "eggdrop v%s", egg_version);
   ^~~~~~~~~~~~
./main.c:1077:26: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 72 [-Wformat-truncation=]
                "Eggdrop v%s (C) 1997 Robey Pointer (C) 2010-2018 Eggheads",
                          ^~
                egg_version);
                ~~~~~~~~~~~
In file included from ./compat/compat.h:27,
                 from ./main.h:102,
                 from ./main.c:48:
./compat/snprintf.h:58:24: note: ‘snprintf’ output between 56 and 1079 bytes into a destination of size 81
 #  define egg_snprintf snprintf
./main.c:1076:3: note: in expansion of macro ‘egg_snprintf’
   egg_snprintf(version, sizeof version,
   ^~~~~~~~~~~~

This will be fixed by #765 (For sane settings in version.h)

3. gcc 8.2.1, NOT default cflags

gcc -fsanitize=undefined -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c userrec.c
userrec.c: In function ‘write_userfile’:
userrec.c:545:3: warning: null destination pointer [-Wformat-overflow=]
   sprintf(new_userfile, "%s~new", userfile);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This will be fixed by #704

10. Minix 3.3.0 i386 clang 3.4 default cflags

Linking eggdrop (debug build).

clang -g -O2 -pipe -Wall -I.. -I.. -I/usr/pkg/include -DHAVE_CONFIG_H -I/usr/pkg/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS -o ../eggdrop bg.o botcmd.o botmsg.o botnet.o chanprog.o cmds.o dcc.o  dccutil.o dns.o flags.o language.o match.o main.o mem.o misc.o misc_file.o  modules.o net.o rfc1459.o tcl.o tcldcc.o tclhash.o tclmisc.o tcluser.o  tls.o userent.o userrec.o users.o  -L/usr/pkg/lib  -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -ltcl86  -lz  -lm -lssl -lcrypto md5/md5c.o compat/*.o `cat mod/mod.xlibs`
clang: warning: argument unused during compilation: '-g'
clang: warning: argument unused during compilation: '-g3'

Successful compile: eggdrop

Harmless, but we may find a way to silence this warning.
However, as i dont see this with newer clang versions, it will probably go away over time.

11. 64-bit NetBSD 6.1.5 gcc 4.5.3 Tcl 8.6.8 OpenSSL 1.0.1i CFLAGS default

Tested eggdrop version: git commit 713cedf Oct 17 2018

gcc -fPIC -g -O2 -pipe -Wall -I. -I../../.. -I../../..  -I../../../src/mod  -DHAVE_CONFIG_H -I/usr/pkg/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -DMAKING_MODS -c .././uptime.mod/uptime.c && mv -f uptime.o ../
.././uptime.mod/uptime.c: In function 'send_uptime':
.././uptime.mod/uptime.c:226:3: warning: overflow in implicit constant conversion

This will be fixed by #548

13. FreeBSD 6.4-RELEASE gcc 3.4.6 Tcl 8.4.19 default cflags

gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/local/include/tcl8.4 -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c tcl.c
tcl.c:423: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/local/include/tcl8.4 -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c userent.c
userent.c: In function `del_entry_type':
userent.c:1395: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -fPIC -g -O2 -pipe -Wall -I. -I../../.. -I../../..  -I../../../src/mod  -DHAVE_CONFIG_H -I/usr/local/include/tcl8.4 -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -DMAKING_MODS -c .././server.mod/server.c && mv -f server.o ../
.././server.mod/server.c: In function `next_server':
.././server.mod/server.c:1076: warning: dereferencing type-punned pointer will break strict-aliasing rules
.././server.mod/server.c: At top level:
.././server.mod/server.c:1402: warning: dereferencing type-punned pointer will break strict-aliasing rules
.././server.mod/server.c:1409: warning: dereferencing type-punned pointer will break strict-aliasing rules

15. 64-bit FreeBSD 12.0-BETA2 gcc 7.3.0 and 32-bit sparc sun4v SunOS 5.11 gcc 7.3.0

gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/local/include/tcl8.6 -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c misc.c
misc.c: In function 'help_subst':
misc.c:909:40: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 161 [-Wformat-truncation=]
         egg_snprintf(sub, sizeof sub, "%s %s", uname_info.sysname,
                                        ^~      ~~~~~~~~~~
In file included from compat/compat.h:27:0,
                 from main.h:102,
                 from misc.c:29:
compat/snprintf.h:58:24: note: 'snprintf' output between 2 and 512 bytes into a destination of size 161
 #  define egg_snprintf snprintf
misc.c:909:9: note: in expansion of macro 'egg_snprintf'
         egg_snprintf(sub, sizeof sub, "%s %s", uname_info.sysname,
         ^~~~~~~~~~~~

16. 32-bit sparc sun4v SunOS 5.11 SunC 5.15

cc -g -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c modules.c
"modules.c", line 1069: warning: operands have incompatible pointer types: op "=="
"modules.c", line 1124: warning: assignment type mismatch:
        pointer to function(int, pointer to char, int) returning void "=" pointer to function() returning void
"modules.c", line 1132: warning: assignment type mismatch:
        pointer to function(pointer to struct userrec {pointer to struct userrec {..} next, array[33] of char handle, unsigned long flags, unsigned long flags_udef, pointer to struct chanuserrec {..} chanrec, pointer to struct user_entry {..} entries}, pointer to char) returning int "=" pointer to function() returning int

17. 32-bit sparc sun4v SunOS 5.11 SunC 5.15 OpenSSL 1.0.2o

cc -g -I.. -I..  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c tls.c
"tls.c", line 772: warning: argument #2 is incompatible with prototype:
        prototype: pointer to function(pointer to const struct ssl_st {int version, int type, pointer to const struct ssl_method_st {..} method, pointer to struct bio_st {..} rbio, pointer to struct bio_st {..} wbio, pointer to struct bio_st {..} bbio, int rwstate, int in_handshake, pointer to function(..) returning int handshake_func, int server, int new_session, int quiet_shutdown, int shutdown, int state, int rstate, pointer to struct buf_mem_st {..} init_buf, pointer to void init_msg, int init_num, int init_off, pointer to unsigned char packet, unsigned int packet_length, pointer to struct ssl2_state_st {..} s2, pointer to struct ssl3_state_st {..} s3, pointer to struct dtls1_state_st {..} d1, int read_ahead, pointer to function(..) returning void msg_callback, pointer to void msg_callback_arg, int hit, pointer to struct X509_VERIFY_PARAM_st {..} param, pointer to struct stack_st_SSL_CIPHER {..} cipher_list, pointer to struct stack_st_SSL_CIPHER {..} cipher_list_by_id, int mac_flags, pointer to struct evp_cipher_ctx_st {..} enc_read_ctx, pointer to struct env_md_ctx_st {..} read_hash, pointer to struct comp_ctx_st {..} expand, pointer to struct evp_cipher_ctx_st {..} enc_write_ctx, pointer to struct env_md_ctx_st {..} write_hash, pointer to struct comp_ctx_st {..} compress, pointer to struct cert_st {..} cert, unsigned int sid_ctx_length, array[32] of unsigned char sid_ctx, pointer to struct ssl_session_st {..} session, pointer to function(..) returning int generate_session_id, int verify_mode, pointer to function(..) returning int verify_callback, pointer to function(..) returning void info_callback, int error, int error_code, pointer to function(..) returning unsigned int psk_client_callback, pointer to function(..) returning unsigned int psk_server_callback, pointer to struct ssl_ctx_st {..} ctx, int debug, long verify_result, struct crypto_ex_data_st {..} ex_data, pointer to struct stack_st_X509_NAME {..} client_CA, int references, unsigned long options, unsigned long mode, long max_cert_list, int first_packet, int client_version, unsigned int max_send_fragment, pointer to function(..) returning void tlsext_debug_cb, pointer to void tlsext_debug_arg, pointer to char tlsext_hostname, int servername_done, int tlsext_status_type, int tlsext_status_expected, pointer to struct stack_st_OCSP_RESPID {..} tlsext_ocsp_ids, pointer to struct stack_st_X509_EXTENSION {..} tlsext_ocsp_exts, pointer to unsigned char tlsext_ocsp_resp, int tlsext_ocsp_resplen, int tlsext_ticket_expected, unsigned int tlsext_ecpointformatlist_length, pointer to unsigned char tlsext_ecpointformatlist, unsigned int tlsext_ellipticcurvelist_length, pointer to unsigned char tlsext_ellipticcurvelist, pointer to void tlsext_opaque_prf_input, unsigned int tlsext_opaque_prf_input_len, pointer to struct tls_session_ticket_ext_st {..} tlsext_session_ticket, pointer to function(..) returning int tls_session_ticket_ext_cb, pointer to void tls_session_ticket_ext_cb_arg, pointer to function(..) returning int tls_session_secret_cb, pointer to void tls_session_secret_cb_arg, pointer to struct ssl_ctx_st {..} initial_ctx, pointer to unsigned char next_proto_negotiated, unsigned char next_proto_negotiated_len, pointer to struct stack_st_SRTP_PROTECTION_PROFILE {..} srtp_profiles, pointer to struct srtp_protection_profile_st {..} srtp_profile, unsigned int tlsext_heartbeat, unsigned int tlsext_hb_pending, unsigned int tlsext_hb_seq, int renegotiate, struct srp_ctx_st {..} srp_ctx, pointer to unsigned char alpn_client_proto_list, unsigned int alpn_client_proto_list_len}, int, int) returning void : "/usr/include/openssl/ssl.h", line 2462
        argument : pointer to void

18. 32-bit sparc sun4v SunOS 5.11 SunC 5.15

/opt/developerstudio12.6/bin/cc -KPIC -g -I. -I../../.. -I../../.. -I../../../src/mod  -DHAVE_CONFIG_H -I/usr/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS   -DMAKING_MODS -c .././dns.mod/dns.c && mv -f dns.o ../
".././dns.mod/coredns.c", line 192: warning: initializer does not fit or is out of range: 0xdeadbeef

Now for the good part.
The following systems throw ZERO compiler warnings with default CFLAGS:

  Following tests with eggdrop version 1ed54f2177ab8c18c12f2c20e26a2afbb2f63c53 (20181211):
64-bit Arch Linux 4.19.8 glibc 2.28 clang 7.0.0 Tcl 8.6.9 OpenSSL 1.1.1a
64-bit FreeBSD 12.0-RELEASE clang 6.0.1 OpenSSL 1.1.1a Tcl 8.6.8
64-bit FreeBSD 11.2-RELEASE-p5 clang 6.0.0 Tcl 8.6.8 OpenSSL 1.0.2o
64-bit OpenBSD 6.4 gcc 4.2.1 Tcl 8.6.8 LibreSSL 2.8.2 (*1)
64-bit NetBSD 8.0 gcc 5.5.0 Tcl 8.5.19 OpenSSL 1.0.2k
32-bit CYGWIN_NT-6.1 windows7 2.11.1 gcc 7.3.0 Tcl 8.6.8 OpenSSL 1.0.2p
  Following tests with eggdrop version ee03769e2f0e35f8cf3b29a400d673f4172302f7 (20181106):
64-bit Debian 9.6 Linux 4.9.0 gcc 6.3.0 Tcl 8.6.6 OpenSSL 1.1.0f
64-bit FreeBSD 9.3-RELEASE-p49 gcc 4.2.1 Tcl 8.6.6 OpenSSL 0.9.8zh
64-bit OpenBSD 4.7 gcc 3.3.5 Tcl 8.5.8 OpenSSL 0.9.8k (*1)
64-bit Arch Linux tcc 0.9.27 Tcl 8.6.8 OpenSSL 1.1.1 (*6)
  Following tests with eggdrop version 55c83c6772d904752bf1f20e41e85b86ac883342 (20181025):
32-bit OpenWrt 18.06.1 Linux 4.14.63 gcc 5.4.0 Tcl 8.6.8 w/o OpenSSL (*5)
32-bit OpenIndiana Hipster 2018.10 SunOS 5.11 gcc 6.4.0 Tcl 8.6.7 OpenSSL 1.0.2p (*4)
  Following tests with eggdrop version b5c65dc3d10e14dd040ff1e2f3f29a7e7ccb5cdf (20181024):
32-bit Debian 8.11.0 gcc 4.9.2 Tcl 8.6.2 OpenSSL 1.0.1t
64-bit FreeBSD 10.4-RELEASE-p13 clang 3.4.1 Tcl 8.6.8 OpenSSL 1.0.1u
64-bit NetBSD 7.1.2 gcc 4.8.5 Tcl 8.5.19 OpenSSL 1.0.1u
64-bit NetBSD 7.0.2 gcc 4.8.4 Tcl 8.5.19 OpenSSL 1.0.1u
64-bit OpenBSD 6.4 clang 6.0.0 Tcl 8.6.8 LibreSSL 2.8.2 (*1)
64-bit OpenBSD 6.3 gcc 4.2.1 Tcl 8.6.8 LibreSSL 2.7.2 (*1)
64-bit OpenBSD 6.3 clang 5.0.1 Tcl 8.6.8 LibreSSL 2.7.2 (*1)
32-bit OpenBSD 5.4 gcc 4.2.1 Tcl 8.6.0 OpenSSL 1.0.1c (*1)
64-bit DragonFly 5.2.2-RELEASE gcc 5.4.1 Tcl 8.6.8 LibreSSL 2.7.4 (*2)
64-bit TrueOS 18.06 FreeBSD 12.0-CURRENT clang 6.0.0 Tcl 8.6.8 LibreSSL 2.7.4
64-bit HardenedBSD 1100056.6 FreeBSD 11-STABLE clang 6.0.1 Tcl 8.7a1 OpenSSL 1.0.2p
64-bit Haiku shredder 1 hrev52295+96 x86_64 gcc 7.3.0 Tcl 8.6.8 OpenSSL 1.0.2p (*3)

(*1) OpenBSD warns about general stuff that doesn't count here:

botcmd.o: In function `remote_tell_who':
/home/michael/usr/src/eggdrop/src/botcmd.c:411: warning: sprintf() is often misused, please use snprintf()
/home/michael/usr/src/eggdrop/src/botcmd.c:331: warning: strcat() is almost always misused, please use strlcat()
/home/michael/usr/src/eggdrop/src/botcmd.c:352: warning: strcpy() is almost always misused, please use strlcpy()
dccutil.o: In function `makepass':
/home/michael/usr/src/eggdrop/src/dccutil.c:507: warning: random() may return deterministic values, is that what you want?

(*2) OpenSSL/LibreSSL not detected by default. Fix:
./configure --with-sslinc=/usr/local/include --with-ssllib=/usr/local/lib

(*3) Tcl not installed, so use a self compiled one, Fix:

./configure --with-tcl=/boot/michael/opt/tcl-8.6.8/lib/tclConfig.sh
LIBRARY_PATH=$LIBRARY_PATH:/boot/michael/opt/tcl-8.6.8/lib make

(*4) The compilation is fine, but there are other annoyances:
4.1.

$ make
make: Fatal error in reader: Makefile, line 21: Badly formed macro assignment

4.2.

$ gmake
gmake: readlink: Command not found

4.3.

$ gmake install
mkdir: /eggdrop: [Permission denied]
[...]

4.3 is addressed with #735

(*5) w/ user compiled tcl

$ ./configure --with-tcl=/home/michael/opt/tcl-8.6.8/lib/tclConfig.sh
$ LD_LIBRARY_PATH=/home/michael/opt/tcl-8.6.8/lib make

(*6) compiles fine, but modular compile coredumps, so make static must be used with tcc, see #751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment