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

C preprocessor directives should not be used in macro arguments

XMLWordPrintable

      In file src/zabbix_server/escalator/escalator.c there is a function execute_commands() with code:

              result = DBselect(
                              "select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port"
                                      ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command"
      #ifdef HAVE_OPENIPMI
                                      ",h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password"
      #endif
                              " from opcommand o,opcommand_grp og,hosts_groups hg,hosts h"
                              " where o.operationid=og.operationid"
                                      " and og.groupid=hg.groupid"
                                      " and hg.hostid=h.hostid"
                                      " and o.operationid=" ZBX_FS_UI64
                                      " and h.status=%d"
                              " union "
                              "select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port"
                                      ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command"
      #ifdef HAVE_OPENIPMI
                                      ",h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password"
      #endif
                              " from opcommand o,opcommand_hst oh,hosts h"
                              " where o.operationid=oh.operationid"
                                      " and oh.hostid=h.hostid"
                                      " and o.operationid=" ZBX_FS_UI64
                                      " and h.status=%d"
                              " union "
                              "select distinct 0,null,o.type,o.scriptid,o.execute_on,o.port"
                                      ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command"
      #ifdef HAVE_OPENIPMI
                                      ",0,2,null,null"
      #endif
                              " from opcommand o,opcommand_hst oh"
                              " where o.operationid=oh.operationid"
                                      " and o.operationid=" ZBX_FS_UI64
                                      " and oh.hostid is null",
                              operationid, HOST_STATUS_MONITORED,
                              operationid, HOST_STATUS_MONITORED,
                              operationid);
      

      DBselect() is defined as macro.
      Compiler (GCC 5.1.1) issues warnings:

      escalator.c: In function ‘execute_commands’:
      escalator.c:469:1: warning: embedding a directive within macro arguments is not portable
       #ifdef HAVE_OPENIPMI
      escalator.c:471:1: warning: embedding a directive within macro arguments is not portable
       #endif
      escalator.c:481:1: warning: embedding a directive within macro arguments is not portable
       #ifdef HAVE_OPENIPMI
      escalator.c:483:1: warning: embedding a directive within macro arguments is not portable
       #endif
      escalator.c:492:1: warning: embedding a directive within macro arguments is not portable
       #ifdef HAVE_OPENIPMI
      escalator.c:494:1: warning: embedding a directive within macro arguments is not portable
       #endif
      

            Unassigned Unassigned
            andris Andris Mednis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: