@@ -140,7 +140,7 @@ static struct rd_main_item_node * rd_append_main_item_node(int first_bit, int la
140140 list = & (* list )-> next ;
141141 }
142142
143- new_list_node = malloc (sizeof (* new_list_node )); // Create new list entry
143+ new_list_node = ( struct rd_main_item_node * ) malloc (sizeof (* new_list_node )); // Create new list entry
144144 new_list_node -> FirstBit = first_bit ;
145145 new_list_node -> LastBit = last_bit ;
146146 new_list_node -> TypeOfNode = type_of_node ;
@@ -203,21 +203,21 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
203203
204204 // Allocate memory and initialize lookup table
205205 rd_bit_range * * * * coll_bit_range ;
206- coll_bit_range = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_bit_range ));
206+ coll_bit_range = ( rd_bit_range * * * * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_bit_range ));
207207 for (USHORT collection_node_idx = 0 ; collection_node_idx < pp_data -> NumberLinkCollectionNodes ; collection_node_idx ++ ) {
208- coll_bit_range [collection_node_idx ] = malloc (256 * sizeof (* coll_bit_range [0 ])); // 256 possible report IDs (incl. 0x00)
208+ coll_bit_range [collection_node_idx ] = ( rd_bit_range * * * ) malloc (256 * sizeof (* coll_bit_range [0 ])); // 256 possible report IDs (incl. 0x00)
209209 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
210- coll_bit_range [collection_node_idx ][reportid_idx ] = malloc (NUM_OF_HIDP_REPORT_TYPES * sizeof (* coll_bit_range [0 ][0 ]));
211- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
212- coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ] = malloc (sizeof (rd_bit_range ));
210+ coll_bit_range [collection_node_idx ][reportid_idx ] = ( rd_bit_range * * ) malloc (NUM_OF_HIDP_REPORT_TYPES * sizeof (* coll_bit_range [0 ][0 ]));
211+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
212+ coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ] = ( rd_bit_range * ) malloc (sizeof (rd_bit_range ));
213213 coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ]-> FirstBit = -1 ;
214214 coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ]-> LastBit = -1 ;
215215 }
216216 }
217217 }
218218
219219 // Fill the lookup table where caps exist
220- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
220+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
221221 for (USHORT caps_idx = pp_data -> caps_info [rt_idx ].FirstCap ; caps_idx < pp_data -> caps_info [rt_idx ].LastCap ; caps_idx ++ ) {
222222 int first_bit , last_bit ;
223223 first_bit = (pp_data -> caps [caps_idx ].BytePosition - 1 ) * 8
@@ -241,8 +241,8 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
241241 // coll_number_of_direct_childs[COLLECTION_INDEX]
242242 // *************************************************************************
243243 int max_coll_level = 0 ;
244- int * coll_levels = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_levels [0 ]));
245- int * coll_number_of_direct_childs = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_number_of_direct_childs [0 ]));
244+ int * coll_levels = ( int * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_levels [0 ]));
245+ int * coll_number_of_direct_childs = ( int * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_number_of_direct_childs [0 ]));
246246 for (USHORT collection_node_idx = 0 ; collection_node_idx < pp_data -> NumberLinkCollectionNodes ; collection_node_idx ++ ) {
247247 coll_levels [collection_node_idx ] = -1 ;
248248 coll_number_of_direct_childs [collection_node_idx ] = 0 ;
@@ -286,7 +286,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
286286 USHORT child_idx = link_collection_nodes [collection_node_idx ].FirstChild ;
287287 while (child_idx ) {
288288 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
289- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
289+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
290290 // Merge bit range from childs
291291 if ((coll_bit_range [child_idx ][reportid_idx ][rt_idx ]-> FirstBit != -1 ) &&
292292 (coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ]-> FirstBit > coll_bit_range [child_idx ][reportid_idx ][rt_idx ]-> FirstBit )) {
@@ -307,11 +307,9 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
307307 // Determine child collection order of the whole hierarchy, based on previously determined bit ranges
308308 // and store it this index coll_child_order[COLLECTION_INDEX][DIRECT_CHILD_INDEX]
309309 // **************************************************************************************************
310- USHORT * * coll_child_order ;
311- coll_child_order = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_child_order ));
310+ USHORT * * coll_child_order = (USHORT * * )malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_child_order ));
312311 {
313- BOOLEAN * coll_parsed_flag ;
314- coll_parsed_flag = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_parsed_flag [0 ]));
312+ BOOLEAN * coll_parsed_flag = (BOOLEAN * )malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_parsed_flag [0 ]));
315313 for (USHORT collection_node_idx = 0 ; collection_node_idx < pp_data -> NumberLinkCollectionNodes ; collection_node_idx ++ ) {
316314 coll_parsed_flag [collection_node_idx ] = FALSE;
317315 }
@@ -321,7 +319,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
321319 if ((coll_number_of_direct_childs [collection_node_idx ] != 0 ) &&
322320 (coll_parsed_flag [link_collection_nodes [collection_node_idx ].FirstChild ] == FALSE)) {
323321 coll_parsed_flag [link_collection_nodes [collection_node_idx ].FirstChild ] = TRUE;
324- coll_child_order [collection_node_idx ] = malloc ((coll_number_of_direct_childs [collection_node_idx ]) * sizeof (* coll_child_order [0 ]));
322+ coll_child_order [collection_node_idx ] = ( USHORT * ) malloc ((coll_number_of_direct_childs [collection_node_idx ]) * sizeof (* coll_child_order [0 ]));
325323
326324 {
327325 // Create list of child collection indices
@@ -339,7 +337,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
339337
340338 if (coll_number_of_direct_childs [collection_node_idx ] > 1 ) {
341339 // Sort child collections indices by bit positions
342- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
340+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
343341 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
344342 for (int child_idx = 1 ; child_idx < coll_number_of_direct_childs [collection_node_idx ]; child_idx ++ ) {
345343 // since the coll_bit_range array is not sorted, we need to reference the collection index in
@@ -380,10 +378,10 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
380378 // ***************************************************************************************
381379 struct rd_main_item_node * main_item_list = NULL ; // List root
382380 // Lookup table to find the Collection items in the list by index
383- struct rd_main_item_node * * coll_begin_lookup = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_begin_lookup ));
384- struct rd_main_item_node * * coll_end_lookup = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_end_lookup ));
381+ struct rd_main_item_node * * coll_begin_lookup = ( struct rd_main_item_node * * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_begin_lookup ));
382+ struct rd_main_item_node * * coll_end_lookup = ( struct rd_main_item_node * * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (* coll_end_lookup ));
385383 {
386- int * coll_last_written_child = malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_last_written_child [0 ]));
384+ int * coll_last_written_child = ( int * ) malloc (pp_data -> NumberLinkCollectionNodes * sizeof (coll_last_written_child [0 ]));
387385 for (USHORT collection_node_idx = 0 ; collection_node_idx < pp_data -> NumberLinkCollectionNodes ; collection_node_idx ++ ) {
388386 coll_last_written_child [collection_node_idx ] = -1 ;
389387 }
@@ -467,7 +465,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
467465 // Inserted Input/Output/Feature main items into the main_item_list
468466 // in order of reconstructed bit positions
469467 // ****************************************************************
470- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
468+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
471469 // Add all value caps to node list
472470 struct rd_main_item_node * firstDelimiterNode = NULL ;
473471 struct rd_main_item_node * delimiterCloseNode = NULL ;
@@ -530,7 +528,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
530528 {
531529 int last_bit_position [NUM_OF_HIDP_REPORT_TYPES ][256 ];
532530 struct rd_main_item_node * last_report_item_lookup [NUM_OF_HIDP_REPORT_TYPES ][256 ];
533- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
531+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
534532 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
535533 last_bit_position [rt_idx ][reportid_idx ] = -1 ;
536534 last_report_item_lookup [rt_idx ][reportid_idx ] = NULL ;
@@ -570,7 +568,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
570568 }
571569
572570 // Add 8 bit padding at each report end
573- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
571+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
574572 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
575573 if (last_bit_position [rt_idx ][reportid_idx ] != -1 ) {
576574 int padding = 8 - ((last_bit_position [rt_idx ][reportid_idx ] + 1 ) % 8 );
@@ -588,7 +586,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
588586 }
589587
590588 // Add full byte padding at the end of the report descriptor (only reconstructable, for devices without Report IDs)
591- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
589+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
592590 if (!devicehasReportIDs && pp_data -> caps_info [rt_idx ].NumberOfCaps > 0 && pp_data -> caps_info [rt_idx ].ReportByteLength > 0 ) {
593591 // ReportID 0 means this device uses not Report IDs
594592 // => Maximum one report per type possible, so we can take the size from the buffer size for the report type
@@ -1010,7 +1008,7 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
10101008 // Free multidimensionable array: coll_child_order[COLLECTION_INDEX][DIRECT_CHILD_INDEX]
10111009 for (USHORT collection_node_idx = 0 ; collection_node_idx < pp_data -> NumberLinkCollectionNodes ; collection_node_idx ++ ) {
10121010 for (int reportid_idx = 0 ; reportid_idx < 256 ; reportid_idx ++ ) {
1013- for (HIDP_REPORT_TYPE rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
1011+ for (int rt_idx = 0 ; rt_idx < NUM_OF_HIDP_REPORT_TYPES ; rt_idx ++ ) {
10141012 free (coll_bit_range [collection_node_idx ][reportid_idx ][rt_idx ]);
10151013 }
10161014 free (coll_bit_range [collection_node_idx ][reportid_idx ]);
0 commit comments