From: Wolfgang Denk Date: Mon, 13 Nov 2017 21:04:40 +0100 Subject: [U-Boot] [PATCH v2 1/1] malloc: don't compare pointers to 0 In-Reply-To: <20171110204634.20515-1-xypron.glpk@gmx.de> References: <20171110195135.14617-1-xypron.glpk@gmx.de> <20171110204634.20515-1-xypron.glpk@gmx.de> Message-ID: <20171113200440.2E2481204BE@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Heinrich, In message <20171110204634.20515-1-xypron.glpk@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_