[PATCH xf86-input-joystick 1/2] Deprecated code cleanup.

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 19 15:31:52 PDT 2010


On Tue, Oct 19, 2010 at 04:59:47PM +0200, walter harms wrote:
> 
> 
> Mikhail Gusarov schrieb:
> > Twas brillig at 10:07:23 19.10.2010 UTC+02 when wharms at bfs.de did gyre and gimble:
> > 
> >  wh> malloc will return (void *) so there is no need to cast.
> >  wh> i do not know xmalloc() but i see no check for OOM condition.
> >  wh> instead of removing xmalloc() it would be more useful to follow
> >  wh> XtMalloc() that has error handling inside.
> > 
> > Sho what's the reasonable error strategy? Shut down the server?
> > 
> > xmalloc is just a funny name for malloc nowadays.
> > 
> 
> You just run out of mem. What else can you you expect ?
> Either you crash with segfault because you are accessing
> unrelated memory or you seqfault instandly because you
> access NULL. I prefer an errormsg telling the user what the
> problem is (OOM) instead let him curse about a sudden crash.
> 
> 
> I have seen xmalloc() in several unrelated projekts doing exactly
> this: return memory or die. (xcalloc etc. doing the same).

I'd argue that none of these code paths are actually tested, so while it is
a nice theory, it's likely that trying to print an error message and
shutting down the server afterwards will eventually result in a crash
anyway.

Cheers,
  Peter


More information about the xorg-devel mailing list