Nuovations / connman

Clone / fork of upstream connman git at https://git.kernel.org/pub/scm/network/connman/connman.git.
GNU General Public License v2.0
1 stars 0 forks source link

Address Compiler Errors under GCC and clang/LLVM for Maintainer Mode Builds #11

Open gerickson opened 11 months ago

gerickson commented 11 months ago

Under maintainer mode builds (--enable-maintainer-mode), which is the default when using bootstrap-configure, connman has the following clang/LLVM and GCC errors (since maintainer mode enables -Werror):

clang/LLVM

src/iptables.csrc/iptables.c:805:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict >= entry_before->offset)
                            ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:808:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict > entry_before->offset)
                            ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:805:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict >= entry_before->offset)
                            ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:808:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict > entry_before->offset)
                            ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:805:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict >= entry_before->offset)
                            ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:808:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict > entry_before->offset)
                            ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
src/dnsproxy.c:439:10: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
        if (len < DNS_QUESTION_SIZE + 1)
            ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
src/dnsproxy.c:462:11: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
                if (len < sizeof(*rr))
                    ~~~ ^ ~~~~~~~~~~~
src/dnsproxy.c:523:15: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
        else if (err != len || dns_len != (len - offset))
                 ~~~ ^  ~~~
src/dnsproxy.c:1066:19: error: comparison of integers of different signs: 'long' and 'unsigned long' [-Werror,-Wsign-compare]
        if ((eptr - ptr) < DNS_QUESTION_SIZE)
             ~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~
src/iptables.c:805:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict >= entry_before->offset)
                            ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
src/iptables.c:808:19: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
                        if (t->verdict > entry_before->offset)
                            ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
src/dnsproxy.c:2524:26: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
                        } else if (bytes_recv < sizeof(reply_len))
                                   ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~

GCC

src/iptables.c: In function ‘update_targets_reference’:
src/iptables.c:805:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  805 |                         if (t->verdict >= entry_before->offset)
      |                                        ^~
src/iptables.c:808:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  808 |                         if (t->verdict > entry_before->offset)
      |                                        ^
  CC       src/tools_dnsproxy_standalone-detect.o
  CC       src/tools_dnsproxy_standalone-inet.o
src/iptables.c: In function ‘update_targets_reference’:
src/iptables.c:805:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  805 |                         if (t->verdict >= entry_before->offset)
      |                                        ^~
  CC       src/tools_dnsproxy_standalone-dhcp.o
unit/test-iptables.c:72:1: error: ‘static’ is not at beginning of declaration [-Werror=old-style-declaration]
   72 | int static xt_match_parse(int c, char **argv, int invert, unsigned int *flags,
      | ^~~
unit/test-iptables.c:78:1: error: ‘static’ is not at beginning of declaration [-Werror=old-style-declaration]
   78 | int static xt_target_parse(int c, char **argv, int invert, unsigned int *flags,
      | ^~~
  CC       src/tools_dnsproxy_standalone-dhcpv6.o
unit/test-iptables.c: In function ‘xtables_option_mfcall’:
unit/test-iptables.c:206:50: error: parameter ‘m’ set but not used [-Werror=unused-but-set-parameter]
  206 | void xtables_option_mfcall(struct xtables_match *m)
      |                            ~~~~~~~~~~~~~~~~~~~~~~^
unit/test-iptables.c: In function ‘xtables_option_tfcall’:
unit/test-iptables.c:218:51: error: parameter ‘t’ set but not used [-Werror=unused-but-set-parameter]
  218 | void xtables_option_tfcall(struct xtables_target *t)
      |                            ~~~~~~~~~~~~~~~~~~~~~~~^
unit/test-iptables.c: In function ‘xtables_option_mpcall’:
unit/test-iptables.c:231:47: error: parameter ‘m’ set but not used [-Werror=unused-but-set-parameter]
  231 |                         struct xtables_match *m, void *fw)
      |                         ~~~~~~~~~~~~~~~~~~~~~~^
unit/test-iptables.c: In function ‘xtables_option_tpcall’:
unit/test-iptables.c:244:48: error: parameter ‘t’ set but not used [-Werror=unused-but-set-parameter]
  244 |                         struct xtables_target *t, void *fw)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~^
  CC       src/tools_dnsproxy_standalone-rtnl.o
src/iptables.c:808:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  808 |                         if (t->verdict > entry_before->offset)
      |                                        ^
unit/test-iptables.c: In function ‘getsockopt’:
unit/test-iptables.c:310:58: error: parameter ‘optval’ set but not used [-Werror=unused-but-set-parameter]
  310 | int getsockopt(int sockfd, int level, int optname, void *optval,
      |                                                    ~~~~~~^~~~~~
  CC       src/tools_dnsproxy_standalone-proxy.o
  CC       src/tools_dnsproxy_standalone-utsname.o
src/iptables.c: In function ‘update_targets_reference’:
src/iptables.c:805:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  805 |                         if (t->verdict >= entry_before->offset)
      |                                        ^~
src/iptables.c:808:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  808 |                         if (t->verdict > entry_before->offset)
      |                                        ^
src/iptables.c: In function ‘iptables_append_rule’:
src/iptables.c:1345:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1345 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1347:9: note: here
 1347 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1348:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1348 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1350:9: note: here
 1350 |         default:
      |         ^~~~~~~
src/iptables.c: In function ‘prepare_rule_inclusion’:
src/iptables.c:1288:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1288 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1290:9: note: here
 1290 |         case AF_INET6:
      |         ^~~~
src/iptables.c: In function ‘iptables_insert_rule’:
src/iptables.c:1399:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1399 |                 if (new_entry->entry)
      |                    ^
  CC       src/tools_dnsproxy_standalone-6to4.o
src/iptables.c:1401:9: note: here
 1401 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1402:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1402 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1404:9: note: here
 1404 |         default:
      |         ^~~~~~~
src/iptables.c: In function ‘iptables_append_rule’:
src/iptables.c:1345:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1345 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1347:9: note: here
 1347 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1348:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1348 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1350:9: note: here
 1350 |         default:
      |         ^~~~~~~
src/iptables.c: In function ‘prepare_rule_inclusion’:
src/iptables.c:1288:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1288 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1290:9: note: here
 1290 |         case AF_INET6:
      |         ^~~~
src/iptables.c: In function ‘iptables_insert_rule’:
src/iptables.c:1399:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1399 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1401:9: note: here
 1401 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1402:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1402 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1404:9: note: here
 1404 |         default:
      |         ^~~~~~~
  CC       src/tools_dnsproxy_standalone-ippool.o
  CC       src/tools_dnsproxy_standalone-bridge.o
  CC       src/tools_dnsproxy_standalone-nat.o
src/iptables.c: In function ‘iptables_append_rule’:
src/iptables.c:1345:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1345 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1347:9: note: here
 1347 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1348:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1348 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1350:9: note: here
 1350 |         default:
      |         ^~~~~~~
src/iptables.c: In function ‘prepare_rule_inclusion’:
src/iptables.c:1288:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1288 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1290:9: note: here
 1290 |         case AF_INET6:
      |         ^~~~
src/iptables.c: In function ‘iptables_insert_rule’:
src/iptables.c:1399:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1399 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1401:9: note: here
 1401 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1402:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1402 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1404:9: note: here
 1404 |         default:
      |         ^~~~~~~
src/dnsproxy.c: In function ‘update_cached_ttl’:
src/iptables.c: In function ‘update_targets_reference’:
src/dnsproxy.c:439:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
  439 |         if (len < DNS_QUESTION_SIZE + 1)
      |                 ^
src/dnsproxy.c:462:25: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
  462 |                 if (len < sizeof(*rr))
      |                         ^
src/dnsproxy.c: In function ‘send_cached_response’:
src/dnsproxy.c:523:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
  523 |         else if (err != len || dns_len != (len - offset))
      |                      ^~
src/dnsproxy.c: In function ‘append_data’:
src/dnsproxy.c:659:29: error: operand of ‘?:’ changes signedness from ‘long int’ to ‘size_t’ {aka ‘long unsigned int’} due to unsignedness of other operand [-Werror=sign-compare]
  659 |                 len = dot ? dot - data : strlen(data);
      |                             ^~~~~~~~~~
src/dnsproxy.c: In function ‘parse_response’:
src/iptables.c:805:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  805 |                         if (t->verdict >= entry_before->offset)
      |                                        ^~
src/iptables.c:808:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
  808 |                         if (t->verdict > entry_before->offset)
      |                                        ^
src/dnsproxy.c:1066:26: error: comparison of integer expressions of different signedness: ‘long int’ and ‘long unsigned int’ [-Werror=sign-compare]
 1066 |         if ((eptr - ptr) < DNS_QUESTION_SIZE)
      |                          ^
src/dnsproxy.c: In function ‘dns_reply_fixup_domains’:
src/dnsproxy.c:2034:23: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
 2034 |         if (reply_len < header_len + 1)
      |                       ^
src/iptables.c: In function ‘final_check_xt_modules’:
src/iptables.c:3190:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3190 |         struct xtables_rule_match *rm;
      |                                    ^~
src/dnsproxy.c: In function ‘tcp_server_event’:
src/dnsproxy.c:2524:47: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
 2524 |                         } else if (bytes_recv < sizeof(reply_len))
      |                                               ^
src/iptables.c: In function ‘final_check_xt_modules’:
src/iptables.c:3190:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3190 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘final_check_xt_modules’:
src/iptables.c:3190:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3190 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘parse_xt_modules’:
src/iptables.c:3090:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3090 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘iptables_append_rule’:
src/iptables.c: In function ‘parse_xt_modules’:
src/iptables.c:1345:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1345 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1347:9: note: here
 1347 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1348:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1348 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1350:9: note: here
 1350 |         default:
      |         ^~~~~~~
src/iptables.c: In function ‘prepare_rule_inclusion’:
src/iptables.c:1288:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1288 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1290:9: note: here
 1290 |         case AF_INET6:
      |         ^~~~
src/iptables.c: In function ‘iptables_insert_rule’:
src/iptables.c:1399:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1399 |                 if (new_entry->entry)
      |                    ^
src/iptables.c:1401:9: note: here
 1401 |         case AF_INET6:
      |         ^~~~
src/iptables.c:1402:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
 1402 |                 if (new_entry->entry6)
      |                    ^
src/iptables.c:1404:9: note: here
 1404 |         default:
      |         ^~~~~~~
src/iptables.c:3090:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3090 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘parse_xt_modules’:
src/iptables.c:3090:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3090 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘prepare_target’:
src/iptables.c:2686:14: error: variable ‘is_builtin’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |              ^~~~~~~~~~
src/iptables.c:2686:26: error: variable ‘is_user_defined’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |                          ^~~~~~~~~~~~~~~
src/iptables.c:2687:16: error: variable ‘chain_head’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2687 |         GList *chain_head = NULL;
      |                ^~~~~~~~~~
src/iptables.c: In function ‘prepare_target’:
src/iptables.c:2686:14: error: variable ‘is_builtin’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |              ^~~~~~~~~~
src/iptables.c:2686:26: error: variable ‘is_user_defined’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |                          ^~~~~~~~~~~~~~~
src/iptables.c:2687:16: error: variable ‘chain_head’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2687 |         GList *chain_head = NULL;
      |                ^~~~~~~~~~
src/iptables.c: In function ‘prepare_target’:
src/iptables.c:2686:14: error: variable ‘is_builtin’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |              ^~~~~~~~~~
src/iptables.c:2686:26: error: variable ‘is_user_defined’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |                          ^~~~~~~~~~~~~~~
src/iptables.c:2687:16: error: variable ‘chain_head’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2687 |         GList *chain_head = NULL;
      |                ^~~~~~~~~~
src/iptables.c: In function ‘final_check_xt_modules’:
src/iptables.c:3190:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3190 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘parse_xt_modules’:
src/iptables.c:3090:36: error: variable ‘rm’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 3090 |         struct xtables_rule_match *rm;
      |                                    ^~
src/iptables.c: In function ‘prepare_target’:
src/iptables.c:2686:14: error: variable ‘is_builtin’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |              ^~~~~~~~~~
src/iptables.c:2686:26: error: variable ‘is_user_defined’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2686 |         bool is_builtin, is_user_defined;
      |                          ^~~~~~~~~~~~~~~
src/iptables.c:2687:16: error: variable ‘chain_head’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2687 |         GList *chain_head = NULL;
      |                ^~~~~~~~~~

Fix these such that continuous integration (CI) succeeds.

gerickson commented 11 months ago

@LaakkonenJussi, any thoughts on addressing the -Werror=clobbered errors?