[ZBX-6435] Compiler warnings with GCC 4.7.2 and 4.8.0 Created: 2013 Mar 25  Updated: 2017 May 30  Resolved: 2013 Apr 11

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 2.0.5, 2.1.0
Fix Version/s: 2.1.0

Type: Incident report Priority: Trivial
Reporter: Volker Fröhlich Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: gcc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

EL 6 x86_64



 Description   

I can currently see two warnings when compiling Zabbix. I included the 4.8 and the 4.7.2 warning messages:

4.8:

odbc.c: In function 'odbc_DBselect':
odbc.c:244:3: warning: passing argument 6 of 'SQLBindCol' from incompatible pointer type [enabled by default]
SQLBindCol(pdbh->hstmt, i + 1, SQL_C_CHAR, pdbh->row_data[i], MAX_STRING_LEN, &pdbh->data_len[i]);
^
In file included from ../../../include/zbxodbc.h:24:0,
from odbc.c:22:
/usr/include/sql.h:586:24: note: expected 'SQLLEN *' but argument is of type 'SQLINTEGER *'
SQLRETURN SQL_API SQLBindCol(SQLHSTMT StatementHandle,

4.7:

odbc.c: In function 'odbc_DBselect':
odbc.c:244:3: warning: passing argument 6 of 'SQLBindCol' from incompatible pointer type [enabled by default]
In file included from ../../../include/zbxodbc.h:24:0,
from odbc.c:22:
/usr/include/sql.h:586:24: note: expected 'SQLLEN *' but argument is of type 'SQLINTEGER *'

4.8:

fatal.c:23:0: warning: "_GNU_SOURCE" redefined [enabled by default]

  1. define _GNU_SOURCE /* required for getting at program counter */
    ^
    <command-line>:0:0: note: this is the location of the previous definition

4.7:

fatal.c:23:0: warning: "_GNU_SOURCE" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition



 Comments   
Comment by Volker Fröhlich [ 2013 Mar 25 ]

4.8.0 on PPC further reveals:

fatal.c: In function 'print_fatal_info':
fatal.c:206:14: warning: unused variable 'uctx' [-Wunused-variable]
ucontext_t *uctx = (ucontext_t *)context;
^
fatal.c: At top level:
fatal.c:65:20: warning: 'get_register_name' defined but not used [-Wunused-function]
static const char *get_register_name(int reg)
^

The odbc.c warning is only there for 64 bit builds, I found.

Comment by Andris Mednis [ 2013 Apr 09 ]

Thanks, Volker, for reporting this!
The warning from odbc.c turned out to be a real error on 64-bit platform.
Can you test the solution from development branch svn://svn.zabbix.com/branches/dev/ZBX-6435 (trunk based)?
(PPC platform is also interesting)

Comment by Andris Mednis [ 2013 Apr 09 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-6435 (trunk)

Comment by Volker Fröhlich [ 2013 Apr 11 ]

All gcc 4.8, Intel and PPC 32 and 64 bit architectures show two warnings for ZBX-6435:

lld_item.c: In function 'DBlld_update_items':
lld_item.c:609:2372: warning: 'item' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (0 != strcmp(item->key_proto, key_proto))
^
lld_item.c:540:18: note: 'item' was declared here
zbx_lld_item_t *item;
^

...

checks_ipmi.c:836:3: warning: enumeration value 'IPMI_CHANGED' not handled in switch [-Wswitch]
switch (op)
^

Comment by Andris Mednis [ 2013 Apr 11 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-6435 (trunk) rev. 34952

Comment by Andris Zeila [ 2013 Apr 19 ]

Successfully tested.

Comment by Andris Mednis [ 2013 Apr 19 ]

Fixed in version pre-2.1.0 rev. 35130

Comment by Volker Fröhlich [ 2013 Jul 05 ]

For the record: The latter two are still present in the Alpha release. Contrary to what I said above, the warning is also there with gcc 4.7.2.

lld_item.c: In function 'DBlld_update_items':
lld_item.c:609:23: warning: 'item' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (0 != strcmp(item->key_proto, key_proto))
^

lld_item.c:540:18: note: 'item' was declared here
zbx_lld_item_t *item;
^
checks_ipmi.c: In function 'sensor_change':
checks_ipmi.c:836:3: warning: enumeration value 'IPMI_CHANGED' not handled in switch [-Wswitch]
switch (op)
^

Comment by Volker Fröhlich [ 2013 Jul 06 ]

No, forget that last comment, I was using the old tarball I made from SVN then.

Comment by Volker Fröhlich [ 2013 Jul 06 ]

4.7.2 and 4.8:

valuecache.c: In function 'zbx_vc_get_value_range':
valuecache.c:3379: warning: 'item' may be used uninitialized in this function
valuecache.c:3311: note: 'item' was declared here
mv -f .deps/libzbxdbcache_a-valuecache.Tpo .deps/libzbxdbcache_a-valuecache.Po
dbcache.c: In function 'DCmass_add_history':
dbcache.c:1809: warning: 'pvalue' may be used uninitialized in this function

EL6's gcc additionally warns about:

comms.c: In function 'zbx_tcp_check_security':
comms.c:1173: warning: dereferencing pointer 'name.87' does break strict-aliasing rules
comms.c:1173: note: initialized from here

modules.c: In function 'load_modules':
modules.c:123: warning: dereferencing type-punned pointer will break strict-aliasing rules
modules.c:139: warning: dereferencing type-punned pointer will break strict-aliasing rules
modules.c:156: warning: dereferencing type-punned pointer will break strict-aliasing rules
modules.c:165: warning: dereferencing type-punned pointer will break strict-aliasing rules
modules.c: In function 'unload_modules':
modules.c:237: warning: dereferencing type-punned pointer will break strict-aliasing rules
modules.c:237: warning: dereferencing pointer 'func_uninit.50' does break strict-aliasing rules
modules.c:237: note: initialized from here
modules.c: In function 'load_modules':
modules.c:123: warning: dereferencing pointer 'func_version.37' does break strict-aliasing rules
modules.c:123: note: initialized from here
modules.c:139: warning: dereferencing pointer 'func_init.40' does break strict-aliasing rules
modules.c:139: note: initialized from here
modules.c:156: warning: dereferencing pointer 'func_timeout.42' does break strict-aliasing rules
modules.c:156: note: initialized from here
modules.c:165: warning: dereferencing pointer 'func_list.44' does break strict-aliasing rules
modules.c:165: note: initialized from here

Comment by Volker Fröhlich [ 2013 Jul 07 ]

Complaints from EL5's gcc:

memalloc.c: In function '__zbx_mem_malloc':
memalloc.c:666: warning: comparison is always false due to limited range of data type
memalloc.c: In function '__zbx_mem_realloc':
memalloc.c:700: warning: comparison is always false due to limited range of data type

evalfunc.c: In function 'add_value_suffix_uptime':
evalfunc.c:1910: warning: implicit declaration of function 'round'
evalfunc.c:1910: warning: incompatible implicit declaration of built-in function 'round'
evalfunc.c: In function 'add_value_suffix_s':
evalfunc.c:1968: warning: incompatible implicit declaration of built-in function 'round'

httpmacro.c: In function 'httpmacro_append_pair':
httpmacro.c:168: warning: dereferencing type-punned pointer will break strict-aliasing rules

nodesync.c: In function 'node_sync':
nodesync.c:62: warning: 'rec' may be used uninitialized in this function

Comment by Andris Zeila [ 2013 Jul 08 ]

Thanks, fixed value cache related warnings (valuecache.c, dbcache.c) in ZBXNEXT-322 development branch

Generated at Thu Jun 26 06:29:33 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.