Skip to content

Commit af7ddb6

Browse files
committed
Remove unused variables
1 parent c0d80c7 commit af7ddb6

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

libdivecomputer/include/libdivecomputer/bluetooth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ dc_bluetooth_open (dc_iostream_t **iostream, dc_context_t *context, dc_bluetooth
132132
#ifdef __cplusplus
133133
}
134134
#endif /* __cplusplus */
135-
#endif /* DC_BLUETOOTH_H */
135+
#endif /* DC_BLUETOOTH_H */

libdivecomputer/include/libdivecomputer/descriptor.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define DC_DESCRIPTOR_H
2424

2525
#include "common.h"
26+
#include "context.h"
2627
#include "iterator.h"
2728

2829
#ifdef __cplusplus
@@ -38,11 +39,15 @@ typedef struct dc_descriptor_t dc_descriptor_t;
3839
* Create an iterator to enumerate the supported dive computers.
3940
*
4041
* @param[out] iterator A location to store the iterator.
42+
* @param[in] context A valid device descriptor.
4143
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
4244
* on failure.
4345
*/
4446
dc_status_t
45-
dc_descriptor_iterator (dc_iterator_t **iterator);
47+
dc_descriptor_iterator_new (dc_iterator_t **iterator, dc_context_t *context);
48+
49+
/* For backwards compatibility */
50+
#define dc_descriptor_iterator(iterator) dc_descriptor_iterator_new(iterator, NULL)
4651

4752
/**
4853
* Free the device descriptor.
@@ -122,4 +127,4 @@ dc_descriptor_filter (const dc_descriptor_t *descriptor, dc_transport_t transpor
122127
#ifdef __cplusplus
123128
}
124129
#endif /* __cplusplus */
125-
#endif /* DC_DESCRIPTOR_H */
130+
#endif /* DC_DESCRIPTOR_H */

libdivecomputer/src/bluetooth.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@
5252
#include "iostream-private.h"
5353
#include "iterator-private.h"
5454
#include "platform.h"
55+
#include "array.h"
5556

5657
#ifdef _WIN32
5758
#define DC_ADDRESS_FORMAT "%012I64X"
5859
#else
5960
#define DC_ADDRESS_FORMAT "%012llX"
6061
#endif
6162

62-
#define C_ARRAY_SIZE(array) (sizeof (array) / sizeof *(array))
63-
6463
#define MAX_DEVICES 255
6564
#define MAX_PERIODS 8
6665

@@ -569,4 +568,4 @@ dc_bluetooth_open (dc_iostream_t **out, dc_context_t *context, dc_bluetooth_addr
569568
#else
570569
return DC_STATUS_UNSUPPORTED;
571570
#endif
572-
}
571+
}

libdivecomputer/src/descriptor.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
#include "iterator-private.h"
3131
#include "platform.h"
32-
33-
#define C_ARRAY_SIZE(array) (sizeof (array) / sizeof *(array))
34-
#define C_ARRAY_ITEMSIZE(array) (sizeof *(array))
32+
#include "array.h"
3533

3634
#define DC_FILTER_INTERNAL(key, values, isnullterminated, match) \
3735
dc_filter_internal( \
@@ -41,6 +39,10 @@
4139
C_ARRAY_ITEMSIZE(values), \
4240
match)
4341

42+
#undef dc_descriptor_iterator
43+
44+
dc_status_t dc_descriptor_iterator (dc_iterator_t **out);
45+
4446
typedef int (*dc_match_t)(const void *, const void *);
4547

4648
typedef int (*dc_filter_t) (const dc_descriptor_t *descriptor, dc_transport_t transport, const void *userdata);
@@ -330,7 +332,7 @@ static const dc_descriptor_t g_descriptors[] = {
330332
{"Heinrichs Weikamp", "OSTC Plus", DC_FAMILY_HW_OSTC3, 0x13, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw},
331333
{"Heinrichs Weikamp", "OSTC Plus", DC_FAMILY_HW_OSTC3, 0x1A, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw},
332334
{"Heinrichs Weikamp", "OSTC 4", DC_FAMILY_HW_OSTC3, 0x3B, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw},
333-
{"Heinrichs Weikamp", "OSTC 5", DC_FAMILY_HW_OSTC3, 0x3B, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw}
335+
{"Heinrichs Weikamp", "OSTC 5", DC_FAMILY_HW_OSTC3, 0x3B, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw},
334336
{"Heinrichs Weikamp", "OSTC cR", DC_FAMILY_HW_OSTC3, 0x05, DC_TRANSPORT_SERIAL, NULL},
335337
{"Heinrichs Weikamp", "OSTC cR", DC_FAMILY_HW_OSTC3, 0x07, DC_TRANSPORT_SERIAL, NULL},
336338
{"Heinrichs Weikamp", "OSTC Sport", DC_FAMILY_HW_OSTC3, 0x12, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLUETOOTH | DC_TRANSPORT_BLE, dc_filter_hw},
@@ -694,7 +696,7 @@ dc_filter_hw (const dc_descriptor_t *descriptor, dc_transport_t transport, const
694696

695697
if (transport == DC_TRANSPORT_BLUETOOTH || transport == DC_TRANSPORT_BLE) {
696698
return DC_FILTER_INTERNAL (userdata, bluetooth, 0, dc_match_prefix);
697-
}
699+
}
698700

699701
return 1;
700702
}
@@ -718,7 +720,7 @@ dc_filter_shearwater (const dc_descriptor_t *descriptor, dc_transport_t transpor
718720

719721
if (transport == DC_TRANSPORT_BLUETOOTH || transport == DC_TRANSPORT_BLE) {
720722
return DC_FILTER_INTERNAL (userdata, bluetooth, 0, dc_match_name);
721-
}
723+
}
722724

723725
return 1;
724726
}
@@ -732,7 +734,7 @@ dc_filter_tecdiving (const dc_descriptor_t *descriptor, dc_transport_t transport
732734

733735
if (transport == DC_TRANSPORT_BLUETOOTH) {
734736
return DC_FILTER_INTERNAL (userdata, bluetooth, 0, dc_match_name);
735-
}
737+
}
736738

737739
return 1;
738740
}
@@ -812,7 +814,7 @@ dc_filter_mclean(const dc_descriptor_t *descriptor, dc_transport_t transport, co
812814

813815
if (transport == DC_TRANSPORT_BLUETOOTH || transport == DC_TRANSPORT_BLE) {
814816
return DC_FILTER_INTERNAL (userdata, bluetooth, 0, dc_match_name);
815-
}
817+
}
816818

817819
return 1;
818820
}
@@ -927,7 +929,7 @@ dc_filter_halcyon (const dc_descriptor_t *descriptor, dc_transport_t transport,
927929
}
928930

929931
dc_status_t
930-
dc_descriptor_iterator (dc_iterator_t **out)
932+
dc_descriptor_iterator_new (dc_iterator_t **out, dc_context_t *context)
931933
{
932934
dc_descriptor_iterator_t *iterator = NULL;
933935

@@ -945,6 +947,12 @@ dc_descriptor_iterator (dc_iterator_t **out)
945947
return DC_STATUS_SUCCESS;
946948
}
947949

950+
dc_status_t
951+
dc_descriptor_iterator (dc_iterator_t **out)
952+
{
953+
return dc_descriptor_iterator_new (out, NULL);
954+
}
955+
948956
static dc_status_t
949957
dc_descriptor_iterator_next (dc_iterator_t *abstract, void *out)
950958
{
@@ -1030,4 +1038,4 @@ dc_descriptor_filter (const dc_descriptor_t *descriptor, dc_transport_t transpor
10301038
return 1;
10311039

10321040
return descriptor->filter (descriptor, transport, userdata);
1033-
}
1041+
}

0 commit comments

Comments
 (0)