This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] remote: Fix hw watchpoint address matching


On Wednesday 30 November 2011 18:23:35, Maciej W. Rozycki wrote:
>  
> +static int
> +remote_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr,
> +				     CORE_ADDR start, int length)
> +{
> +  CORE_ADDR diff = remote_address_masked (addr - start);
> +
> +  return diff >= 0 && diff < length;
> +}

CORE_ADDR is unsigned.  `>= 0' is always true.

Wouldn't it be much more readable to:

{
  CORE_ADDR start = remote_address_masked (start);

  return start <= addr && addr < start + length;
}

?

(assuming addr is already masked, since that was the address
the target reported.)

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]