xref: /btstack/tool/migration_to_v1.0/migration.cocci (revision efda0b48f920fa795cb4c2d0cf0c4acf184fb858)
1@@
2typedef uint8_t, uint16_t, uint32_t;
3@@
4- dummy_rule_to_add_typedefs( ... );
5
6@@
7expression dest, src;
8@@
9- bt_flip_addr(dest,src)
10+ reverse_bd_addr(src, dest)
11
12@@
13expression handle;
14@@
15- hci_remote_eSCO_supported(handle)
16+ hci_remote_esco_supported(handle)
17
18// HCI Packet Handler
19
20@@
21identifier packet_handler;
22@@
23- hci_register_packet_handler(packet_handler);
24+ hci_register_packet_handler(&packet_handler);
25
26@hci_register_packet_handler@
27identifier packet_handler;
28@@
29- hci_register_packet_handler(&packet_handler);
30+ static btstack_packet_callback_registration_t callback_registration;
31+ callback_registration.callback = &packet_handler;
32+ hci_add_event_handler(&callback_registration);
33
34@@
35identifier hci_register_packet_handler.packet_handler, packet_type, packet, size;
36@@
37packet_handler(uint8_t packet_type,
38+ uint16_t channel,
39uint8_t * packet, uint16_t size)
40{ ... }
41
42// L2CAP Packet Handler
43
44@@
45identifier packet_handler;
46@@
47- l2cap_register_packet_handler(packet_handler);
48+ l2cap_register_packet_handler(&packet_handler);
49
50@l2cap_register_packet_handler@
51identifier packet_handler;
52@@
53- l2cap_register_packet_handler(&packet_handler);
54+ static btstack_packet_callback_registration_t callback_registration;
55+ callback_registration.callback = &packet_handler;
56+ hci_add_event_handler(&callback_registration);
57
58@@
59identifier l2cap_register_packet_handler.packet_handler, connection, packet_type, channel, packet, size;
60@@
61- void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size)
62+ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size)
63{ ... }
64
65
66@@
67expression handle;
68@@
69- hci_can_send_sco_packet_now(handle)
70+ hci_can_send_sco_packet_now()
71
72@@
73expression uuid;
74@@
75- printUUID128(uuid)
76+ printf("%s", uuid128_to_str(uuid))
77
78@@
79expression addr;
80@@
81- print_bd_addr(addr)
82+ printf("%s", bd_addr_to_str(addr))
83
84@@
85expression str, addr;
86typedef bd_addr_t;
87@@
88- sscan_bd_addr((uint8_t*)str, addr)
89+ sscanf_bd_addr(str, addr)
90
91@@
92typedef timer;
93typedef btstack_timer_source_t;
94identifier fn, ts;
95@@
96- fn(struct timer * ts)
97+ fn(btstack_timer_source_t * ts)
98{ ... }
99
100// SDP Client
101
102// propagate sdp client callback into individual sdp client calls
103// add warning that type doesn't match
104
105// remove sdp_parser_init()
106@@
107@@
108- sdp_parser_init();
109
110// track calls to sdp_parser_register_callback
111
112@@
113identifier sdp_client_callback;
114@@
115- sdp_parser_register_callback(sdp_client_callback);
116+ sdp_parser_register_callback(&sdp_client_callback);
117
118@sdp_parser_register_callback@
119identifier sdp_client_callback;
120@@
121- sdp_parser_register_callback(&sdp_client_callback);
122
123// fix calls for sdp_query_util.h
124@@
125identifier sdp_parser_register_callback.sdp_client_callback;
126expression E1, E2;
127@@
128- sdp_general_query_for_uuid(E1, E2)
129+ sdp_client_query_uuid16(sdp_client_callback, E1, E2)
130
131@@
132identifier sdp_parser_register_callback.sdp_client_callback;
133expression E1, E2;
134@@
135- sdp_general_query_for_uuid128(E1, E2)
136+ sdp_client_query_uuid128(sdp_client_callback, E1, E2)
137
138// fix calls for sdp_client.h
139@@
140identifier sdp_parser_register_callback.sdp_client_callback;
141expression E1, E2, E3;
142@@
143+ sdp_client_query(E1, E2, E3)
144- sdp_client_query(sdp_client_callback, E1, E2, E3)
145
146// track calls to sdp_client_query_rfcomm_register_callback
147@@
148identifier sdp_client_callback;
149expression E1;
150@@
151- sdp_client_query_rfcomm_register_callback(sdp_client_callback, E1);
152+ sdp_client_query_rfcomm_register_callback(&sdp_client_callback, E1);
153
154@sdp_client_query_rfcomm_register_callback @
155identifier sdp_client_callback;
156expression E1;
157@@
158- sdp_client_query_rfcomm_register_callback(&sdp_client_callback, E1);
159
160@@
161typedef sdp_query_event_t;
162identifier fn, event;
163type T;
164@@
165- T fn(sdp_query_event_t * event)
166+
167+ // MIGRATION: SDP Client callback changed to btstack_packet_handler_t
168+ // Please  use sdp_client_X functions from btstack_event.h to access event fields
169+
170+ T fn(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size)
171{ ... }
172
173// fix calls to sdp_query_rfcomm
174@@
175identifier sdp_client_query_rfcomm_register_callback.sdp_client_callback;
176expression E1, E2;
177@@
178- sdp_client_query_rfcomm_channel_and_name_for_uuid(E1, E2)
179+ sdp_client_query_rfcomm_channel_and_name_for_uuid(sdp_client_callback, E1, E2)
180
181@@
182identifier sdp_client_query_rfcomm_register_callback.sdp_client_callback;
183expression E1, E2;
184@@
185- sdp_client_query_rfcomm_channel_and_name_for_search_pattern(E1, E2)
186+ sdp_client_query_rfcomm_channel_and_name_for_search_pattern(sdp_client_callback, E1, E2)
187
188@@
189identifier fn, event, context;
190type T;
191@@
192- T fn(sdp_query_event_t * event, void * context)
193+
194+ // MIGRATION: SDP Client callback changed to btstack_packet_handler_t
195+ // Please  use sdp_client_X functions from btstack_event.h to access event fields
196+
197+ T fn(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size)
198{ ... }
199
200// SDP Util
201
202@@
203expression E1, E2, E3;
204@@
205- spp_create_sdp_record(E1, E2, E3)
206+ // MIGRATION: using 0x10001 as Service Record Handle. Please fix if using multiple services
207+ spp_create_sdp_record(E1, 0x10001, E2, E3)
208
209// SDP Server
210@@
211expression E1, E2;
212@@
213- sdp_register_service(E1, E2)
214+ sdp_register_service(E2)
215
216// L2CAP - just drop connection param
217@@
218expression E1, E2, E3, E4, E5;
219@@
220- l2cap_create_channel(E1, E2, E3, E4, E5)
221+ l2cap_create_channel(E2, E3, E4, E5)
222
223@@
224expression E1, E2, E3, E4, E5;
225@@
226- l2cap_create_service(E1, E2, E3, E4, E5)
227+ l2cap_create_service(E2, E3, E4, E5)
228
229// RFCOMM
230
231// track calls to rfcomm_register_packet_handler
232@@
233identifier rfcomm_callback;
234@@
235- rfcomm_register_packet_handler(rfcomm_callback);
236+ rfcomm_register_packet_handler(&rfcomm_callback);
237
238@rfcomm_register_packet_handler@
239identifier rfcomm_callback;
240@@
241- rfcomm_register_packet_handler(&rfcomm_callback);
242
243// fix calls to
244// rfcomm_register_service
245@@
246identifier rfcomm_register_packet_handler.rfcomm_callback;
247expression E1, E2, E3;
248@@
249- rfcomm_register_service(E1, E2, E3)
250+ rfcomm_register_service(rfcomm_callback, E2, E3)
251
252// rfcomm_register_service_with_initial_credits,
253@@
254identifier rfcomm_register_packet_handler.rfcomm_callback;
255expression E1, E2, E3, E4;
256@@
257- rfcomm_register_service_with_initial_credits(E1, E2, E3, E4)
258+ rfcomm_register_service_with_initial_credits(rfcomm_callback, E2, E3, E4)
259
260// rfcomm_create_channel
261@@
262identifier rfcomm_register_packet_handler.rfcomm_callback;
263expression E1, E2, E3;
264@@
265- rfcomm_create_channel(E1, E2, E3)
266+ rfcomm_create_channel(rfcomm_callback, E2, E3)
267
268// rfcomm_create_channel_with_initial_credits
269@@
270identifier rfcomm_register_packet_handler.rfcomm_callback;
271expression E1, E2, E3, E4;
272@@
273- rfcomm_create_channel_with_initial_creditis(E1, E2, E3, E4)
274+ rfcomm_create_channel_with_initial_creditis(rfcomm_callback, E2, E3, E4)
275
276// HSP
277@@
278expression E1, E2, E3, E4;
279@@
280- hsp_hs_create_sdp_record(E1, E2, E3, E4)
281+ // MIGRATION: using 0x10002 as Service Record Handle. Please fix if using multiple services
282+ hsp_hs_create_sdp_record(E1, 0x10002, E2, E3, E4)
283
284@@
285expression E1, E2, E3;
286@@
287- hsp_ag_create_sdp_record(E1, E2, E3)
288+ // MIGRATION: using 0x10002 as Service Record Handle. Please fix if using multiple services
289+ hsp_ag_create_sdp_record(E1, 0x10002, E2, E3)
290
291// GATT Client
292
293// track callback registration
294@@
295identifier gatt_callback;
296@@
297- gatt_client_register_packet_handler(gatt_callback);
298+ gatt_client_register_packet_handler(&gatt_callback);
299
300@gatt_client_register_packet_handler@
301identifier gatt_callback;
302identifier gc_id;
303@@
304- gc_id = gatt_client_register_packet_handler(&gatt_callback);
305
306// update callback
307@@
308identifier gatt_client_register_packet_handler.gatt_callback;
309identifier event;
310typedef le_event_t;
311@@
312- gatt_callback(le_event_t * event)
313+
314+ // MIGRATION: GATT Client callback changed to btstack_packet_handler_t
315+ // Please  use gatt_event_X functions from btstack_event.h to access event fields
316+
317+ gatt_callback(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size)
318{ ... }
319
320// update all calls
321@@
322expression gc_id;
323identifier gatt_client_register_packet_handler.gatt_callback;
324@@
325gatt_client_discover_primary_services(
326- gc_id,
327+ gatt_callback,
328... );
329
330@@
331expression gc_id;
332identifier gatt_client_register_packet_handler.gatt_callback;
333@@
334gatt_client_discover_primary_services_by_uuid16(
335- gc_id,
336+ gatt_callback,
337... );
338
339@@
340expression gc_id;
341identifier gatt_client_register_packet_handler.gatt_callback;
342@@
343gatt_client_discover_primary_services_by_uuid128(
344- gc_id,
345+ gatt_callback,
346... )
347
348@@
349expression gc_id;
350identifier gatt_client_register_packet_handler.gatt_callback;
351@@
352gatt_client_find_included_services_for_service(
353- gc_id,
354+ gatt_callback,
355... )
356
357@@
358expression gc_id;
359identifier gatt_client_register_packet_handler.gatt_callback;
360@@
361gatt_client_discover_characteristics_for_service(
362- gc_id,
363+ gatt_callback,
364... );
365
366@@
367expression gc_id;
368identifier gatt_client_register_packet_handler.gatt_callback;
369@@
370gatt_client_discover_characteristics_for_handle_range_by_uuid16(
371- gc_id,
372+ gatt_callback,
373... );
374
375@@
376expression gc_id;
377identifier gatt_client_register_packet_handler.gatt_callback;
378@@
379gatt_client_discover_characteristics_for_handle_range_by_uuid128(
380- gc_id,
381+ gatt_callback,
382... );
383
384@@
385expression gc_id;
386identifier gatt_client_register_packet_handler.gatt_callback;
387@@
388gatt_client_discover_characteristics_for_service_by_uuid16 (
389- gc_id,
390+ gatt_callback,
391... );
392
393@@
394expression gc_id;
395identifier gatt_client_register_packet_handler.gatt_callback;
396@@
397gatt_client_discover_characteristics_for_service_by_uuid128(
398- gc_id,
399+ gatt_callback,
400... );
401
402@@
403expression gc_id;
404identifier gatt_client_register_packet_handler.gatt_callback;
405@@
406gatt_client_discover_characteristic_descriptors(
407- gc_id,
408+ gatt_callback,
409... );
410
411@@
412expression gc_id;
413identifier gatt_client_register_packet_handler.gatt_callback;
414@@
415gatt_client_read_value_of_characteristic(
416- gc_id,
417+ gatt_callback,
418... );
419
420@@
421expression gc_id;
422identifier gatt_client_register_packet_handler.gatt_callback;
423@@
424gatt_client_read_value_of_characteristic_using_value_handle(
425- gc_id,
426+ gatt_callback,
427... );
428
429@@
430expression gc_id;
431identifier gatt_client_register_packet_handler.gatt_callback;
432@@
433gatt_client_read_value_of_characteristics_by_uuid16(
434- gc_id,
435+ gatt_callback,
436... );
437
438@@
439expression gc_id;
440identifier gatt_client_register_packet_handler.gatt_callback;
441@@
442gatt_client_read_value_of_characteristics_by_uuid128(
443- gc_id,
444+ gatt_callback,
445... );
446
447@@
448expression gc_id;
449identifier gatt_client_register_packet_handler.gatt_callback;
450@@
451gatt_client_read_long_value_of_characteristic(
452- gc_id,
453+ gatt_callback,
454... );
455
456@@
457expression gc_id;
458identifier gatt_client_register_packet_handler.gatt_callback;
459@@
460gatt_client_read_long_value_of_characteristic_using_value_handle(
461- gc_id,
462+ gatt_callback,
463... );
464
465@@
466expression gc_id;
467identifier gatt_client_register_packet_handler.gatt_callback;
468@@
469gatt_client_read_long_value_of_characteristic_using_value_handle_with_offset(
470- gc_id,
471+ gatt_callback,
472... );
473
474@@
475expression gc_id;
476identifier gatt_client_register_packet_handler.gatt_callback;
477@@
478gatt_client_read_multiple_characteristic_values(
479- gc_id,
480+ gatt_callback,
481... );
482
483@@
484expression gc_id;
485identifier gatt_client_register_packet_handler.gatt_callback;
486@@
487gatt_client_write_value_of_characteristic_without_response(
488- gc_id,
489+ gatt_callback,
490... );
491
492@@
493expression gc_id;
494identifier gatt_client_register_packet_handler.gatt_callback;
495@@
496gatt_client_signed_write_without_response(
497- gc_id,
498+ gatt_callback,
499... );
500
501@@
502expression gc_id;
503identifier gatt_client_register_packet_handler.gatt_callback;
504@@
505gatt_client_write_value_of_characteristic(
506- gc_id,
507+ gatt_callback,
508... );
509
510@@
511expression gc_id;
512identifier gatt_client_register_packet_handler.gatt_callback;
513@@
514gatt_client_write_long_value_of_characteristic(
515- gc_id,
516+ gatt_callback,
517... );
518
519@@
520expression gc_id;
521identifier gatt_client_register_packet_handler.gatt_callback;
522@@
523gatt_client_write_long_value_of_characteristic_with_offset(
524- gc_id,
525+ gatt_callback,
526... );
527
528@@
529expression gc_id;
530identifier gatt_client_register_packet_handler.gatt_callback;
531@@
532gatt_client_reliable_write_long_value_of_characteristic(
533- gc_id,
534+ gatt_callback,
535... );
536
537@@
538expression gc_id;
539identifier gatt_client_register_packet_handler.gatt_callback;
540@@
541gatt_client_read_characteristic_descriptor(
542- gc_id,
543+ gatt_callback,
544... );
545
546@@
547expression gc_id;
548identifier gatt_client_register_packet_handler.gatt_callback;
549@@
550gatt_client_read_characteristic_descriptor_using_descriptor_handle(
551- gc_id,
552+ gatt_callback,
553... );
554
555@@
556expression gc_id;
557identifier gatt_client_register_packet_handler.gatt_callback;
558@@
559gatt_client_read_long_characteristic_descriptor(
560- gc_id,
561+ gatt_callback,
562... );
563
564@@
565expression gc_id;
566identifier gatt_client_register_packet_handler.gatt_callback;
567@@
568gatt_client_read_long_characteristic_descriptor_using_descriptor_handle(
569- gc_id,
570+ gatt_callback,
571... );
572
573@@
574expression gc_id;
575identifier gatt_client_register_packet_handler.gatt_callback;
576@@
577gatt_client_read_long_characteristic_descriptor_using_descriptor_handle_with_offset(
578- gc_id,
579+ gatt_callback,
580... );
581
582@@
583expression gc_id;
584identifier gatt_client_register_packet_handler.gatt_callback;
585@@
586gatt_client_write_characteristic_descriptor(
587- gc_id,
588+ gatt_callback,
589... );
590
591@@
592expression gc_id;
593identifier gatt_client_register_packet_handler.gatt_callback;
594@@
595gatt_client_write_characteristic_descriptor_using_descriptor_handle(
596- gc_id,
597+ gatt_callback,
598... );
599
600@@
601expression gc_id;
602identifier gatt_client_register_packet_handler.gatt_callback;
603@@
604gatt_client_write_long_characteristic_descriptor(
605- gc_id,
606+ gatt_callback,
607... );
608
609@@
610expression gc_id;
611identifier gatt_client_register_packet_handler.gatt_callback;
612@@
613gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(
614- gc_id,
615+ gatt_callback,
616... );
617
618@@
619expression gc_id;
620identifier gatt_client_register_packet_handler.gatt_callback;
621@@
622gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(
623- gc_id,
624+ gatt_callback,
625... );
626
627@@
628expression gc_id;
629identifier gatt_client_register_packet_handler.gatt_callback;
630@@
631gatt_client_write_client_characteristic_configuration(
632- gc_id,
633+ gatt_callback,
634... );
635
636