Better way to fix a 'return from incompatible pointer type' compiler warning

Now apply only to const return types to avoid other side effects (i.e. to avoid creating other warnings  with some compilers)