Re: [dev] [st PATCH 1/3] xloadcols: remove cp variable
On Wed, Apr 22, 2015 at 4:14 PM, Garrick Peterson <garrickp_AT_gmail.com> wrote:
[...]
>> for (cp = dc.col; cp < &dc.col[LEN(dc.col)]; ++cp)
>
> Forgive my ignorance of the LEN macro, but doesn’t this rely on accessing a memory address outside of the allocated array? Wouldn’t that cause problems if you’re up against memory boundaries? I would personally write it as either
> for (cp = dc.col; cp <= &dc.col[LEN(dc.col)-1]; ++cp)
> or even better
> for (cp = dc.col; cp - dc.col < LEN(dc.col); ++cp)
>
The only way to obtain the "upper end" pointer that cp is compared to
is to evaluate dc.col + sizeof(dc.col). No dereference of the value
that address holds is required.
cheers!
mar77i
Received on Fri Apr 24 2015 - 08:18:33 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 24 2015 - 08:24:07 CEST