[systemd-devel] [PATCH] Always use our own MAX/MIN definitions
Greg KH
gregkh at linuxfoundation.org
Fri Apr 5 10:39:23 PDT 2013
On Fri, Apr 05, 2013 at 07:20:28PM +0200, Lennart Poettering wrote:
> On Mon, 01.04.13 03:08, Cristian Rodríguez (crrodriguez at opensuse.org) wrote:
>
> > code in src/shared/macro.h only defined MAX/MIN in case
> > they were not defined previously. however the MAX/MIN
> > macros implemented in glibc are not of the "safe" kind but defined
> > as:
> >
> > define MIN(a,b) (((a)<(b))?(a):(b))
> > define MAX(a,b) (((a)>(b))?(a):(b))
> >
> > Avoid nasty side effects by using our own versions instead.
>
> Just wondering: nasty side effects? Can you elaborate? In real-life it
> shouldn't matter too much, should it?
Different variable types being compared incorrectly, as well as the
usual "using the expression twice in the same macro" issue. I recommend
using the typesafe ones you all have created instead, much like the
kernel does.
thanks,
greg k-h
More information about the systemd-devel
mailing list