On Mon, Jul 29, 2024 at 11:37 AM Bruno Haible <br...@clisp.org> wrote: > > Jeffrey Walton wrote: > > You should consider making the interface easy to use correctly, and > > hard to use incorrectly. That will help novice programmers avoid > > mistakes. > > Novice programmers need to learn that they need to look at the return > value. Once they have learned this, everything is easy.
Everyone makes mistakes, including expert programmers: <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=glibc>. Making the function easy to use correctly, and hard to use incorrectly, serves the best interest of the internet community. > > In that light, set the ptr to NULL to make it as safe as possible. > > With the same argument, you could claim that functions that can set > errno should always set errno to 0 when they succeed. So that > users don't need to set 'errno = 0;' before the call, if they want > to inspect errno after the call, regardless of the return value. Jeff