Re: [PATCH 6/8] sequencer: simplify allocation of result array in todo_list_rearrange_squash()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 23, 2023 at 07:46:28PM +0000, Phillip Wood wrote:
+		assert(nr == todo_list->nr);

If this assert fails we may have already had some out of bounds memory accesses.

the loop could have run short, too.
but anyway, this isn't a runtime check, it's an assertion of a loop invariant.

+		todo_list->alloc = nr;
  		FREE_AND_NULL(todo_list->items);

I think it would be cleaner to keep the original ordering and free the old list before assigning todo_list->alloc

my reasoning is that it's closer to the assert which also refers to it, and it really makes sense to have _that_ first. also, the value is more likely to be still in a register at that point.

  		todo_list->items = items;
-		todo_list->nr = nr;
-		todo_list->alloc = alloc;
  	}




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux