catalog: fix error codes handling in catalog_list_items

Previously r was set to zero and so if(r<0) was never true.