@@ -255,15 +255,13 @@ static int packetize_data(const u8 *data, size_t length)
255
255
return rc ;
256
256
}
257
257
258
- static int do_packet_read (char * data , struct list_head * ptemp_list ,
258
+ static int do_packet_read (char * data , struct packet_data * newpacket ,
259
259
int length , int bytes_read , int * list_read_count )
260
260
{
261
261
void * ptemp_buf ;
262
- struct packet_data * newpacket = NULL ;
263
262
int bytes_copied = 0 ;
264
263
int j = 0 ;
265
264
266
- newpacket = list_entry (ptemp_list , struct packet_data , list );
267
265
* list_read_count += newpacket -> length ;
268
266
269
267
if (* list_read_count > bytes_read ) {
@@ -291,7 +289,7 @@ static int do_packet_read(char *data, struct list_head *ptemp_list,
291
289
292
290
static int packet_read_list (char * data , size_t * pread_length )
293
291
{
294
- struct list_head * ptemp_list ;
292
+ struct packet_data * newpacket ;
295
293
int temp_count = 0 ;
296
294
int bytes_copied = 0 ;
297
295
int bytes_read = 0 ;
@@ -305,9 +303,8 @@ static int packet_read_list(char *data, size_t * pread_length)
305
303
remaining_bytes = * pread_length ;
306
304
bytes_read = rbu_data .packet_read_count ;
307
305
308
- ptemp_list = (& packet_data_head .list )-> next ;
309
- while (!list_empty (ptemp_list )) {
310
- bytes_copied = do_packet_read (pdest , ptemp_list ,
306
+ list_for_each_entry (newpacket , (& packet_data_head .list )-> next , list ) {
307
+ bytes_copied = do_packet_read (pdest , newpacket ,
311
308
remaining_bytes , bytes_read , & temp_count );
312
309
remaining_bytes -= bytes_copied ;
313
310
bytes_read += bytes_copied ;
@@ -318,8 +315,6 @@ static int packet_read_list(char *data, size_t * pread_length)
318
315
*/
319
316
if (remaining_bytes == 0 )
320
317
break ;
321
-
322
- ptemp_list = ptemp_list -> next ;
323
318
}
324
319
/*finally set the bytes read */
325
320
* pread_length = bytes_read - rbu_data .packet_read_count ;
@@ -329,17 +324,11 @@ static int packet_read_list(char *data, size_t * pread_length)
329
324
330
325
static void packet_empty_list (void )
331
326
{
332
- struct list_head * ptemp_list ;
333
- struct list_head * pnext_list ;
334
- struct packet_data * newpacket ;
327
+ struct packet_data * newpacket , * tmp ;
328
+
329
+ list_for_each_entry_safe (newpacket , tmp , (& packet_data_head .list )-> next , list ) {
330
+ list_del (& newpacket -> list );
335
331
336
- ptemp_list = (& packet_data_head .list )-> next ;
337
- while (!list_empty (ptemp_list )) {
338
- newpacket =
339
- list_entry (ptemp_list , struct packet_data , list );
340
- pnext_list = ptemp_list -> next ;
341
- list_del (ptemp_list );
342
- ptemp_list = pnext_list ;
343
332
/*
344
333
* zero out the RBU packet memory before freeing
345
334
* to make sure there are no stale RBU packets left in memory
0 commit comments