[ZBX-11970] Anonymous enumeration type definition in performance counter related code Created: 2017 Mar 24  Updated: 2024 Apr 10  Resolved: 2017 Sep 07

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 3.4.0alpha1
Fix Version/s: 4.0.0alpha1, 4.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Glebs Ivanovskis (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: codequality
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Epic Link: DEV-591
Team: Team A
Sprint: Sprint 12, Sprint 13, Sprint 14, Sprint 15, Sprint 16
Story Points: 0.5

 Description   

In include/perfmon.h there is a definition of an enum type without a name:

typedef enum
{
	PERF_COUNTER_NOTSUPPORTED = 0,
	PERF_COUNTER_INITIALIZED,
	PERF_COUNTER_GET_SECOND_VALUE,	/* waiting for the second raw value (needed for some, e.g. rate, counters) */
	PERF_COUNTER_ACTIVE,
};

and hence these values need to be stored in a generic int:

typedef struct perf_counter_data
{
	...
	int				status;
	...
}
PERF_COUNTER_DATA;

Would be so much better for readability to give this type a meaningful name.

P.S. Also struct type naming does not follow the latest guidelines.



 Comments   
Comment by Andris Mednis [ 2017 Aug 04 ]

The warning is

D:\....\include\perfmon.h(41): warning C4091: 'typedef ': ignored on left of '' when no variable is declared

Possible fix:

Index: include/perfmon.h
===================================================================
--- include/perfmon.h	(revision 70937)
+++ include/perfmon.h	(working copy)
@@ -37,8 +37,9 @@
 	PERF_COUNTER_NOTSUPPORTED = 0,
 	PERF_COUNTER_INITIALIZED,
 	PERF_COUNTER_GET_SECOND_VALUE,	/* waiting for the second raw value (needed for some, e.g. rate, counters) */
-	PERF_COUNTER_ACTIVE,
-};
+	PERF_COUNTER_ACTIVE
+}
+zbx_perf_counter_status_t;
 
 typedef struct perf_counter_id
 {
Comment by Andrea Biscuola (Inactive) [ 2017 Sep 04 ]

Fixed in r72124

To see the complete diff: svn diff -r r72116:r72124

Fixed the enumerator naming and also the structure declarations and related typedefs.

Comment by Andris Mednis [ 2017 Sep 06 ]

Successfully tested with proposed modifications r72263 - r72286.

Comment by Andrea Biscuola (Inactive) [ 2017 Sep 07 ]

Fixed in:

  • pre-4.0.0alpha1(trunk)
Generated at Fri Apr 26 01:10:34 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.