[ZBX-16207] Avoidable compiler warning in proxy.c Created: 2019 Jun 03  Updated: 2019 Jul 22  Resolved: 2019 Jul 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 4.2.4rc1, 4.4.0alpha1
Fix Version/s: 4.2.5rc1, 4.4.0alpha1, 4.4 (plan)

Type: Problem report Priority: Trivial
Reporter: Glebs Ivanovskis Assignee: Viktors Tjarve
Resolution: Fixed Votes: 0
Labels: codequality, networkdiscovery, pach
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File proxy.patch    
Team: Team A
Sprint: Sprint 53 (Jun 2019), Sprint 54 (Jul 2019)
Story Points: 0.125

 Description   

Steps to reproduce:

  1. Compile Zabbix server/proxy from sources.

Result:

Making all in zbxdbhigh
proxy.c: In function ‘process_discovery_data_contents’:
proxy.c:3442:8: warning: ‘services_num’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int   services_num, ret = FAIL, i;
        ^~~~~~~~~~~~

Expected:
No warnings that can be easily fixed. See proxy.patch.



 Comments   
Comment by Vladislavs Sokurenko [ 2019 Jun 11 ]

I don't see such warning on gcc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)

Comment by Glebs Ivanovskis [ 2019 Jun 11 ]

Which compiler flags do you use?

Comment by Vladislavs Sokurenko [ 2019 Jun 11 ]

Which compiler flags do you use?

The most important part is:

-g -O0 -Wall -Wextra"

I can reproduce the issue if changed to:

-g -O2 -Wall -Wextra"
Comment by Glebs Ivanovskis [ 2019 Jun 11 ]

Yes, -Wmaybe-uninitialized relies on optimizer data.

These warnings are only possible in optimizing compilation, because otherwise GCC does not keep track of the state of variables.

Comment by Vladislavs Sokurenko [ 2019 Jun 12 ]

Event though a false positive it is better to get rid of such warnings if easily possible

Comment by Viktors Tjarve [ 2019 Jul 09 ]

Releases in:

Generated at Fri Mar 29 10:53:24 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.