[U-Boot] [PATCH v2 1/1] malloc: don't compare pointers to 0

Wolfgang Denk wd at denx.de
Mon Nov 13 20:04:40 UTC 2017


Dear Heinrich,

In message <20171110204634.20515-1-xypron.glpk at gmx.de> you wrote:
> 0 is not a pointer. So do not compare pointers to 0.

Who says so?  0 can be the value of a pointer to a valid, existing
address.  For example a large number of Power Architecture systems
map the RAM beginning at physical address 0, so if you want to
wrtite to the very first byte in memory your pointer value is 0.

> Do not return 0 from functions with a pointer return
> type.

Why?  It could be a valid value - or not.

> -				if (new_address == 0)
> +				if (!new_address)

In which way is "new_address == 0" and "!new_address" different?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
He'd heard her use that sweet, innocent  tone  of  voice  before.  It
meant that, pretty soon, there was going to be trouble.
                                        - Terry Pratchett, _Truckers_


More information about the U-Boot mailing list