Using negative cache index

Stefan Kalkowski stefan.kalkowski at ...1...
Thu Oct 18 09:37:50 CEST 2012


Hello Ildar,

thank you for pointing to this. I wonder whether the error condition was
met in some of your scenarios? Obviously that should never be the case.
I think the best will be to change that snippet into an assertion statement.

Regards
Stefan

On 16.10.2012 10:33, Ildar Ismagilov wrote:
> In function Req_cache::remove on ports-foc/src/lib/l4lx/genode_block.cc file:
> 
> void remove(void *packet, void **request)
> {
>    int idx = _find(packet);
> 
>    if (idx < 0) {
>          *request = 0;
>           PERR("Req cache entry not found!");
>     }
>     *request = _cache[idx].req; // <--- if idx is -1, this negative
> index used for access _cache array elements
>      _cache[idx].pkt = 0;
>      _cache[idx].req = 0;
> }
> 
> should be:
> 
> void remove(void *packet, void **request)
> {
>    int idx = _find(packet);
> 
>    if (idx < 0) {
>          *request = 0;
>           PERR("Req cache entry not found!");
>     }
>     else {
>          *request = _cache[idx].req;
>          _cache[idx].pkt = 0;
>          _cache[idx].req = 0;
>     }
> }
> 

-- 
Stefan Kalkowski
Genode Labs

http://www.genode-labs.com/ ยท http://genode.org/




More information about the users mailing list