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

reduce build warning #167

Open
kiraware opened this issue Oct 15, 2023 · 0 comments
Open

reduce build warning #167

kiraware opened this issue Oct 15, 2023 · 0 comments

Comments

@kiraware
Copy link

kiraware commented Oct 15, 2023

libnet has some warning during build. You can check it through github action workflow. Here are summary of all (maybe) the warning i've got from my PR

libnet_advanced.c(120): warning C4244: 'return': conversion from 'const ssize_t' to 'int', possible loss of data
libnet_advanced.c(152): warning C4244: 'return': conversion from 'const ssize_t' to 'int', possible loss of data


libnet_build_dhcp.c: In function ‘libnet_build_dhcpv4’:
libnet_build_dhcp.c:81:16: warning: declaration of ‘n’ shadows a previous local [-Wshadow]
   81 |         size_t n = sizeof (dhcp_hdr.dhcp_chaddr);
      |                ^
libnet_build_dhcp.c:49:20: note: shadowed declaration is here
   49 |     const uint32_t n = LIBNET_DHCPV4_H + payload_s;
      |                    ^


libnet_build_icmp.c(599): warning C4244: '=': conversion from 'uint32_t' to 'uint8_t', possible loss of data


libnet_build_ip.c(78): warning C4244: '+=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
libnet_build_ip.c(188): warning C4244: '=': conversion from 'uint32_t' to 'uint16_t', possible loss of data
libnet_build_ip.c(294): warning C4244: '+=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
libnet_build_ip.c(399): warning C4244: '=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
libnet_build_ip.c(400): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data
libnet_build_ip.c(451): warning C4244: '=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
D:\a\libnet\libnet\src\libnet_build_ip.c(194) : warning C4702: unreachable code


libnet_build_ospf.c(71): warning C4244: 'function': conversion from 'const uint32_t' to 'u_short', possible loss of data
libnet_build_ospf.c(356): warning C4244: 'function': conversion from 'const uint32_t' to 'u_short', possible loss of data


libnet_build_tcp.c(76): warning C4244: '+=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
libnet_build_tcp.c(110): warning C4244: '+=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_build_tcp.c(127): warning C4244: 'function': conversion from 'const int' to 'u_short', possible loss of data
libnet_build_tcp.c(273): warning C4244: '=': conversion from 'uint32_t' to 'uint8_t', possible loss of data
libnet_build_tcp.c(276): warning C4244: '+=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_build_tcp.c(280): warning C4244: '-=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_build_tcp.c(292): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data
libnet_build_tcp.c(296): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data


libnet_build_udld.c: In function ‘libnet_build_udld_hdr’:
libnet_build_udld.c:164:11: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
  164 |     if (n == -1)
      |           ^~
libnet_build_udld.c: In function ‘libnet_build_udld_device_id’:
libnet_build_udld.c:197:60: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  197 |         sprintf(l->err_buf, "%s(): value inconsistency\n", __FUNCTION__);
      |                                                            ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_port_id’:
libnet_build_udld.c:214:60: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  214 |         sprintf(l->err_buf, "%s(): value inconsistency\n", __FUNCTION__);
      |                                                            ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_echo’:
libnet_build_udld.c:231:60: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  231 |         sprintf(l->err_buf, "%s(): value inconsistency\n", __FUNCTION__);
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -I../include -I./../include -Wall -Wextra -Wshadow -Wunused -Wpedantic -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -D_DEFAULT_SOURCE=1 -c libnet_build_tcp.c  -fPIC -DPIC -o .libs/libnet_build_tcp.o
      |                                                            ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_message_interval’:
libnet_build_udld.c:250:71: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  250 |         sprintf(l->err_buf, "%s(): value pointer cannot be a NULL\n", __FUNCTION__);
      |                                                                       ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_timeout_interval’:
libnet_build_udld.c:269:71: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  269 |         sprintf(l->err_buf, "%s(): value pointer cannot be a NULL\n", __FUNCTION__);
      |                                                                       ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_device_name’:
libnet_build_udld.c:287:60: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  287 |         sprintf(l->err_buf, "%s(): value inconsistency\n", __FUNCTION__);
      |                                                            ^~~~~~~~~~~~
libnet_build_udld.c: In function ‘libnet_build_udld_sequence_number’:
libnet_build_udld.c:306:71: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  306 |         sprintf(l->err_buf, "%s(): value pointer cannot be a NULL\n", __FUNCTION__);
      |                                                                       ^~~~~~~~~~~~


libnet_build_lldp.c: In function ‘libnet_build_lldp_ttl’:
libnet_build_lldp.c:146:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  146 |     if (ttl > UINT16_MAX)
      |             ^


libnet_checksum.c(286): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data
libnet_checksum.c(316): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data
libnet_checksum.c(337): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data
libnet_checksum.c(356): warning C4244: 'function': conversion from 'int' to 'u_short', possible loss of data


libnet_crc.c(95): warning C4245: '=': conversion from 'int' to 'uint32_t', signed/unsigned mismatch


libnet_dll.c(35): warning C4100: 'lpReserved': unreferenced formal parameter
libnet_dll.c(35): warning C4100: 'hinst': unreferenced formal parameter


D:\a\libnet\libnet\src\libnet_if_addr.c(621) : warning C4701: potentially uninitialized local variable 'rc' used


libnet_init.c(64): warning C4245: '=': conversion from 'int' to 'SOCKET', signed/unsigned mismatch
libnet_init.c(184): warning C4133: 'function': incompatible types - from 'int *' to 'const char *'
D:\a\libnet\libnet\src\libnet_init.c(143) : warning C4706: assignment within conditional expression


libnet_internal.c(77): warning C4477: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'const SOCKET'
libnet_internal.c(77): note: consider using '%lld' in the format string
libnet_internal.c(77): note: consider using '%Id' in the format string
libnet_internal.c(77): note: consider using '%I64d' in the format string


libnet_pblock.c(81): warning C4244: '+=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_pblock.c(88): warning C4244: '-=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_pblock.c(289): warning C4244: '=': conversion from 'uint32_t' to 'uint16_t', possible loss of data


libnet_link_bpf.c:251:11: warning: comparison of integers of different signs: 'const int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
    if (c != size)
        ~ ^  ~~~~
1 warning generated.


libnet_link_win32.c(205): warning C4245: 'initializing': conversion from 'int' to 'DWORD', signed/unsigned mismatch
libnet_link_win32.c(300): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_link_win32.c(275): warning C4100: 'l': unreferenced formal parameter


libnet_port_list.c(93): warning C4244: '=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_port_list.c(136): warning C4244: '=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_port_list.c(139): warning C4244: '=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_port_list.c(159): warning C4244: '=': conversion from 'int' to 'uint16_t', possible loss of data
libnet_port_list.c(180): warning C4244: '=': conversion from 'int' to 'uint16_t', possible loss of data
D:\a\libnet\libnet\src\libnet_port_list.c(115) : warning C4706: assignment within conditional expression


libnet_raw.c: In function ‘libnet_finish_setup_socket’:
libnet_raw.c:80:14: warning: unused variable ‘len’ [-Wunused-variable]
   80 |     unsigned len;
      |              ^~~


#if (_WIN32)
 ^
libnet_resolve.c:132:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
#endif
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I../include -I../include -I./../include -Wall -Wextra -Wshadow -Wunused -Wpedantic -D_DEFAULT_SOURCE=1 -c libnet_resolve.c  -fno-common -DPIC -o libnet_resolve.o >/dev/null 2>&1
 ^
2 warnings generated.


libnet_resolve.c(37): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(35): warning C4100: 'af': unreferenced formal parameter
libnet_resolve.c(63): warning C4996: 'gethostbyaddr': Use getnameinfo() or GetNameInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(94): warning C4996: 'gethostbyaddr': Use getnameinfo() or GetNameInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(135): warning C4245: 'return': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
libnet_resolve.c(155): warning C4245: 'return': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
libnet_resolve.c(177): warning C4245: 'return': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
libnet_resolve.c(120): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(122): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(210): warning C4996: 'gethostbyaddr': Use getnameinfo() or GetNameInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
libnet_resolve.c(236): warning C4100: 'host_name': unreferenced formal parameter


libnet_write.c(55): warning C4245: '=': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
libnet_write.c(118): warning C4100: 'ptag': unreferenced formal parameter
libnet_write.c(118): warning C4100: 'l': unreferenced formal parameter
libnet_write.c(147): warning C4100: 'ptag': unreferenced formal parameter
libnet_write.c(145): warning C4100: 'src': unreferenced formal parameter


warning: Tag 'HTML_TIMESTAMP' at line 155 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'FORMULA_TRANSPARENT' at line 186 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'LATEX_SOURCE_CODE' at line 217 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'LATEX_TIMESTAMP' at line 219 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'RTF_SOURCE_CODE' at line 229 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'DOCBOOK_PROGRAMLISTING' at line 247 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'CLASS_DIAGRAMS' at line 282 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'DOT_FONTNAME' at line 287 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'DOT_FONTSIZE' at line 288 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'DOT_TRANSPARENT' at line 313 of file '../doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"

As you can see some of them maybe easy to fix and some is not. I would like to do PR to fix (hopefully all of this warning). But, before i do that, i need some advice especially regarding conversion from type x to type y. Because fixing type conversion may change the already defined struct. Another problem is migrate from deprecated function because this will break things, but if it already deprecated after 20 years i think migrate from that is a must. After all if i could fix it I'll fix it, but if i couldn't I'll leave it.

Tagging maintainer @troglobit

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

No branches or pull requests

1 participant