Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-11696

Fix -Wmissing-field-initializers compilation warnings

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Cannot Reproduce
    • Icon: Trivial Trivial
    • None
    • 3.4.0alpha1
    • Installation (I)

      Continuation of ZBX-11105. Currently -Wmissing-field-initializers is the most numerous warning type when compiling trunk with -Wall -Wextra flags.

      Configure command:

      CFLAGS='-Wall -Wextra -g -O2' ./configure --enable-server --enable-proxy --enable-agent --with-postgresql
      

      Warnings:

      net.c: In function ‘find_tcp_port_by_state_nl’:
      net.c:92:56: warning: missing initializer for field ‘msg_control’ of ‘struct msghdr’ [-Wmissing-field-initializers]
        struct msghdr  s_msg = { (void *)&s_sa, sizeof(struct sockaddr_nl), s_io, 1 };
                                                              ^
      In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:38:0,
                       from /usr/include/netinet/in.h:23,
                       from /usr/include/netdb.h:27,
                       from ../../../../include/sysinc.h:192,
                       from ../../../../include/common.h:23,
                       from net.c:20:
      /usr/include/x86_64-linux-gnu/bits/socket.h:236:11: note: ‘msg_control’ declared here
           void *msg_control;  /* Ancillary data (eg BSD filedesc passing). */
                 ^
      net.c:98:56: warning: missing initializer for field ‘msg_control’ of ‘struct msghdr’ [-Wmissing-field-initializers]
        struct msghdr  r_msg = { (void *)&r_sa, sizeof(struct sockaddr_nl), r_io, 1 };
                                                              ^
      In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:38:0,
                       from /usr/include/netinet/in.h:23,
                       from /usr/include/netdb.h:27,
                       from ../../../../include/sysinc.h:192,
                       from ../../../../include/common.h:23,
                       from net.c:20:
      /usr/include/x86_64-linux-gnu/bits/socket.h:236:11: note: ‘msg_control’ declared here
           void *msg_control;  /* Ancillary data (eg BSD filedesc passing). */
                 ^
      
      dbupgrade.c: In function ‘DBcreate_dbversion_table’:
      dbupgrade.c:597:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade.c:22:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_2010.c: In function ‘DBpatch_2010158’:
      dbupgrade_2010.c:1314:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade_2010.c:21:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_2010.c: In function ‘DBpatch_2010164’:
      dbupgrade_2010.c:1363:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade_2010.c:21:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_2010.c: In function ‘DBpatch_2010167’:
      dbupgrade_2010.c:1395:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade_2010.c:21:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_2010.c: In function ‘DBpatch_2010172’:
      dbupgrade_2010.c:1438:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade_2010.c:21:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_2030.c: In function ‘DBpatch_2030021’:
      dbupgrade_2030.c:226:4: warning: missing initializer for field ‘uniq’ of ‘ZBX_TABLE {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
          };
          ^
      In file included from ../../../include/db.h:26:0,
                       from dbupgrade_2030.c:21:
      ../../../include/dbschema.h:66:14: note: ‘uniq’ declared here
        const char *uniq;
                    ^
      dbupgrade_3010.c: In function ‘DBpatch_3010026_expression_remove_values_impl’:
      
      valuecache.c: In function ‘vc_release_space’:
      valuecache.c:955:4: warning: missing initializer for field ‘weight’ of ‘zbx_vc_item_weight_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
          zbx_vc_item_weight_t weight = {item};
          ^
      valuecache.c:227:10: note: ‘weight’ declared here
        double  weight;
                ^
      valuecache.c: In function ‘zbx_vc_get_value_range’:
      valuecache.c:2957:4: warning: missing initializer for field ‘state’ of ‘zbx_vc_item_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
          zbx_vc_item_t   new_item = {itemid, value_type};
          ^
      valuecache.c:137:16: note: ‘state’ declared here
        unsigned char state;
                      ^
      valuecache.c: In function ‘zbx_vc_get_value’:
      valuecache.c:3080:4: warning: missing initializer for field ‘state’ of ‘zbx_vc_item_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
          zbx_vc_item_t   new_item = {itemid, value_type};
          ^
      valuecache.c:137:16: note: ‘state’ declared here
        unsigned char state;
                      ^
      dbcache.c: In function ‘DCget_deltaitem’:
      dbcache.c:1096:3: warning: missing initializer for field ‘timestamp’ of ‘zbx_item_history_value_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
         zbx_item_history_value_t value = {item->itemid};
         ^
      In file included from dbcache.c:25:0:
      ../../../include/dbcache.h:389:18: note: ‘timestamp’ declared here
        zbx_timespec_t  timestamp;
                        ^
      
      itservices.c: In function ‘its_itservice_create’:
      itservices.c:164:2: warning: missing initializer for field ‘parents’ of ‘zbx_itservice_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        zbx_itservice_t  itservice = {serviceid, triggerid, status, status, algorithm}, *pitservice;
        ^
      itservices.c:57:19: note: ‘parents’ declared here
        zbx_vector_ptr_t parents;
                         ^
      itservices.c:176:4: warning: missing initializer for field ‘itservices’ of ‘zbx_itservice_index_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
          zbx_itservice_index_t index = {triggerid};
          ^
      itservices.c:67:19: note: ‘itservices’ declared here
        zbx_vector_ptr_t itservices;
                         ^
      
      housekeeper.c:144:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"history", "history", &cfg.hk.history_mode, &cfg.hk.history_global, &cfg.hk.history},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:145:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"history_str", "history", &cfg.hk.history_mode, &cfg.hk.history_global, &cfg.hk.history},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:146:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"history_log", "history", &cfg.hk.history_mode, &cfg.hk.history_global, &cfg.hk.history},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:147:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"history_uint", "history", &cfg.hk.history_mode, &cfg.hk.history_global, &cfg.hk.history},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:148:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"history_text", "history", &cfg.hk.history_mode, &cfg.hk.history_global, &cfg.hk.history},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:149:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"trends", "trends", &cfg.hk.trends_mode, &cfg.hk.trends_global, &cfg.hk.trends},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      housekeeper.c:150:2: warning: missing initializer for field ‘item_cache’ of ‘zbx_hk_history_rule_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
        {"trends_uint","trends", &cfg.hk.trends_mode, &cfg.hk.trends_global, &cfg.hk.trends},
        ^
      housekeeper.c:135:17: note: ‘item_cache’ declared here
        zbx_hashset_t  item_cache;
                       ^
      
      trapper.c: In function ‘recv_getqueue’:
      trapper.c:411:6: warning: missing initializer for field ‘delay5’ of ‘zbx_queue_stats_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
            zbx_queue_stats_t data = {id};
            ^
      trapper.c:222:7: note: ‘delay5’ declared here
        int  delay5;
             ^
      trapper.c:436:6: warning: missing initializer for field ‘delay5’ of ‘zbx_queue_stats_t {aka struct <anonymous>}’ [-Wmissing-field-initializers]
            zbx_queue_stats_t data = {id};
            ^
      trapper.c:222:7: note: ‘delay5’ declared here
        int  delay5;
             ^
      

      Warning description from GCC manual provides a nice way to fix it (available since C99):

                struct s { int f, g, h; };
                struct s x = { .f = 3, .g = 4 };
      

            Unassigned Unassigned
            glebs.ivanovskis Glebs Ivanovskis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: