@@ -2171,7 +2171,7 @@ static bool GIP_HandleMessage(
2171
2171
return false;
2172
2172
}
2173
2173
2174
- static int GIP_ReceivePacket (GIP_Device * device , const Uint8 * bytes , int num_bytes )
2174
+ static void GIP_ReceivePacket (GIP_Device * device , const Uint8 * bytes , int num_bytes )
2175
2175
{
2176
2176
GIP_Header header ;
2177
2177
int offset = 3 ;
@@ -2183,7 +2183,7 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2183
2183
GIP_Attachment * attachment ;
2184
2184
2185
2185
if (num_bytes < 5 ) {
2186
- return -1 ;
2186
+ return ;
2187
2187
}
2188
2188
2189
2189
header .message_type = bytes [0 ];
@@ -2216,21 +2216,21 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2216
2216
}
2217
2217
offset += GIP_DecodeLength (& total_length , & bytes [offset ], num_bytes - offset );
2218
2218
if (total_length > MAX_MESSAGE_LENGTH ) {
2219
- return -1 ;
2219
+ return ;
2220
2220
}
2221
2221
attachment -> total_length = (Uint16 ) total_length ;
2222
2222
attachment -> fragment_message = header .message_type ;
2223
2223
if (header .length > num_bytes - offset ) {
2224
2224
SDL_LogWarn (SDL_LOG_CATEGORY_INPUT ,
2225
2225
"GIP: Received fragment that claims to be %" SDL_PRIu64 " bytes, expected %i" ,
2226
2226
header .length , num_bytes - offset );
2227
- return -1 ;
2227
+ return ;
2228
2228
}
2229
2229
if (header .length > total_length ) {
2230
2230
SDL_LogWarn (SDL_LOG_CATEGORY_INPUT ,
2231
2231
"GIP: Received too long fragment, %" SDL_PRIu64 " bytes, exceeds %d" ,
2232
2232
header .length , attachment -> total_length );
2233
- return -1 ;
2233
+ return ;
2234
2234
}
2235
2235
attachment -> fragment_data = SDL_malloc (attachment -> total_length );
2236
2236
SDL_memcpy (attachment -> fragment_data , & bytes [offset ], (size_t ) header .length );
@@ -2243,24 +2243,25 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2243
2243
"GIP: Received out of sequence message type %02x, expected %02x" ,
2244
2244
header .message_type , attachment -> fragment_message );
2245
2245
GIP_FragmentFailed (attachment , & header );
2246
- return -1 ;
2246
+ return ;
2247
2247
}
2248
2248
2249
2249
offset += GIP_DecodeLength (& fragment_offset , & bytes [offset ], num_bytes - offset );
2250
2250
if (fragment_offset != attachment -> fragment_offset ) {
2251
2251
SDL_LogWarn (SDL_LOG_CATEGORY_INPUT ,
2252
2252
"GIP: Received out of sequence fragment, (claimed %" SDL_PRIu64 ", expected %d)" ,
2253
2253
fragment_offset , attachment -> fragment_offset );
2254
- return GIP_Acknowledge (device ,
2254
+ GIP_Acknowledge (device ,
2255
2255
& header ,
2256
2256
attachment -> fragment_offset ,
2257
2257
(Uint16 ) (attachment -> total_length - attachment -> fragment_offset ));
2258
+ return ;
2258
2259
} else if (fragment_offset + header .length > attachment -> total_length ) {
2259
2260
SDL_LogWarn (SDL_LOG_CATEGORY_INPUT ,
2260
2261
"GIP: Received too long fragment, %" SDL_PRIu64 " exceeds %d" ,
2261
2262
fragment_offset + header .length , attachment -> total_length );
2262
2263
GIP_FragmentFailed (attachment , & header );
2263
- return -1 ;
2264
+ return ;
2264
2265
}
2265
2266
2266
2267
bytes_remaining = attachment -> total_length - (Uint16 ) (fragment_offset + header .length );
@@ -2282,7 +2283,7 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2282
2283
SDL_LogWarn (SDL_LOG_CATEGORY_INPUT ,
2283
2284
"GIP: Received message with erroneous length (claimed %" SDL_PRIu64 ", actual %d), discarding" ,
2284
2285
header .length + offset , num_bytes );
2285
- return -1 ;
2286
+ return ;
2286
2287
} else {
2287
2288
num_bytes -= offset ;
2288
2289
bytes += offset ;
@@ -2293,7 +2294,6 @@ static int GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_byt
2293
2294
if (ok && (header .flags & GIP_FLAG_ACME )) {
2294
2295
GIP_Acknowledge (device , & header , (Uint32 ) fragment_offset , bytes_remaining );
2295
2296
}
2296
- return offset + (Uint16 ) header .length ;
2297
2297
}
2298
2298
2299
2299
static void HIDAPI_DriverGIP_RumbleSent (void * userdata )
@@ -2611,10 +2611,7 @@ static bool HIDAPI_DriverGIP_UpdateDevice(SDL_HIDAPI_Device *device)
2611
2611
2612
2612
while ((num_bytes = SDL_hid_read_timeout (device -> dev , bytes , sizeof (bytes ), ctx -> timeout )) > 0 ) {
2613
2613
ctx -> timeout = 0 ;
2614
- int parsed = GIP_ReceivePacket (ctx , bytes , num_bytes );
2615
- if (parsed <= 0 ) {
2616
- break ;
2617
- }
2614
+ GIP_ReceivePacket (ctx , bytes , num_bytes );
2618
2615
}
2619
2616
2620
2617
timestamp = SDL_GetTicks ();
0 commit comments