Skip to content

Commit fa0a213

Browse files
committed
sdp: rework handling of 128bit types
The old cose was causing warnings: ``` /__w/libogc/libogc/bt-embedded/bt-embedded/services/sdp.c: In function 'uint128_from_64': /__w/libogc/libogc/bt-embedded/bt-embedded/services/sdp.c:53:12: warning: 'ret' is used uninitialized [-Wuninitialized] 53 | return ret; | ^~~ /__w/libogc/libogc/bt-embedded/bt-embedded/services/sdp.c:46:19: note: 'ret' declared here 46 | BteSdpUint128 ret; | ^~~ ```
1 parent 2700b68 commit fa0a213

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

bt-embedded/services/sdp.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,19 @@ static inline BteSdpInt128 int128_from_64(int64_t v) {
4444
#else
4545
static inline BteSdpUint128 uint128_from_64(uint64_t v) {
4646
BteSdpUint128 ret;
47-
uint64_t *parts = (void*)&ret;
4847
#if __BYTE_ORDER == __LITTLE_ENDIAN
49-
parts[0] = v; parts[1] = 0;
48+
ret.parts[0] = v; ret.parts[1] = 0;
5049
#else
51-
parts[1] = v; parts[0] = 0;
50+
ret.parts[1] = v; ret.parts[0] = 0;
5251
#endif
5352
return ret;
5453
}
5554
static inline BteSdpInt128 int128_from_64(int64_t v) {
5655
BteSdpUint128 ret;
57-
int64_t *parts = (void*)&ret;
5856
#if __BYTE_ORDER == __LITTLE_ENDIAN
59-
parts[0] = v; parts[1] = v > 0 ? 0 : -1;
57+
ret.parts[0] = (uint64_t)v; ret.parts[1] = (uint64_t)(v > 0 ? 0 : -1);
6058
#else
61-
parts[1] = v; parts[0] = v > 0 ? 0 : -1;
59+
ret.parts[1] = (uint64_t)v; ret.parts[0] = (uint64_t)(v > 0 ? 0 : -1);
6260
#endif
6361
return ret;
6462
}

bt-embedded/services/sdp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef __int128 BteSdpInt128;
1515
typedef unsigned __int128 BteSdpUint128;
1616
#else
1717
typedef struct {
18-
uint8_t bytes[16];
18+
uint64_t parts[2];
1919
} BteSdpUint128;
2020
typedef BteSdpUint128 BteSdpInt128;
2121
#endif

0 commit comments

Comments
 (0)