Skip to content

fix(wos-thermal): store metric IDs instead of indices in zone map#16

Open
Skand Gupta (skandg41) wants to merge 1 commit into
mainfrom
fix/wos-thermal-metric-id-map-v2
Open

fix(wos-thermal): store metric IDs instead of indices in zone map#16
Skand Gupta (skandg41) wants to merge 1 commit into
mainfrom
fix/wos-thermal-metric-id-map-v2

Conversation

@skandg41

@skandg41 Skand Gupta (skandg41) commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Issue : #12

g_zone_id_to_metric_index_map stored the metrics_data array position (metric_index) instead of the actual metric ID, causing metric_response entries to carry an index value in their metric_id field. This happened to match today because metric ID defines are sequential, but breaks if zone detection order changes or metric IDs become non-sequential.

Rename the map and getter to metric_id and store metrics_data[metric_index].metric_id at each zone assignment site.

UT :
image

g_zone_id_to_metric_index_map stored the metrics_data array position
(metric_index) instead of the actual metric ID, causing metric_response
entries to carry an index value in their metric_id field. This happened
to match today because metric ID defines are sequential, but breaks if
zone detection order changes or metric IDs become non-sequential.

Rename the map and getter to _metric_id_ and store
metrics_data[metric_index].metric_id at each zone assignment site.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: skangupt <skangupt@qti.qualcomm.com>

// Store mapping
g_zone_id_to_metric_index_map[zone_id][0] = metric_index;
g_zone_id_to_metric_id_map[zone_id][0] = metrics_data[metric_index].metric_id;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 represents temperature and 1 represents passive cooling. If these values are fixed, could we define descriptive macros (or enums) and use them instead of hardcoded constants for better readability and maintainability?

#define TZ_TEMPERATURE             0
#define TZ_PASSIVE_COOLING       1

Then replace the literal values 0 and 1 with TZ_TEMP and TZ_PASSIVE_COOLING respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants