Re: [Python-Dev] [Python-checkins] cpython: no one passes NULL here (or should anyway)
On Mon, Jul 4, 2011 at 8:02 AM, benjamin.peterson <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/bbbeddafeec0 changeset: 71160:bbbeddafeec0 user: Benjamin Peterson <benjamin@python.org> date: Sun Jul 03 17:06:32 2011 -0500 summary: no one passes NULL here (or should anyway)
files: Python/ceval.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1115,9 +1115,6 @@
/* Start of code */
- if (f == NULL) - return NULL; -
May need to replace that with an assert(f != NULL) to keep static analysers happy. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
2011/7/3 Nick Coghlan <ncoghlan@gmail.com>:
On Mon, Jul 4, 2011 at 8:02 AM, benjamin.peterson <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/bbbeddafeec0 changeset: 71160:bbbeddafeec0 user: Benjamin Peterson <benjamin@python.org> date: Sun Jul 03 17:06:32 2011 -0500 summary: no one passes NULL here (or should anyway)
files: Python/ceval.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1115,9 +1115,6 @@
/* Start of code */
- if (f == NULL) - return NULL; -
May need to replace that with an assert(f != NULL) to keep static analysers happy.
Surely static analyzers don't assume every argument passed in is NULL? -- Regards, Benjamin
On Mon, Jul 4, 2011 at 12:54 PM, Benjamin Peterson <benjamin@python.org> wrote:
2011/7/3 Nick Coghlan <ncoghlan@gmail.com>:
May need to replace that with an assert(f != NULL) to keep static analysers happy.
Surely static analyzers don't assume every argument passed in is NULL?
I didn't check - was this change in a static function? For those, I think they can figure it out. For functions exposed to the linker, I think they demand an explicit check for a non-NULL pointer (which may be in the form of an assertion). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
2011/7/3 Nick Coghlan <ncoghlan@gmail.com>:
On Mon, Jul 4, 2011 at 12:54 PM, Benjamin Peterson <benjamin@python.org> wrote:
2011/7/3 Nick Coghlan <ncoghlan@gmail.com>:
May need to replace that with an assert(f != NULL) to keep static analysers happy.
Surely static analyzers don't assume every argument passed in is NULL?
I didn't check - was this change in a static function? For those, I think they can figure it out. For functions exposed to the linker, I think they demand an explicit check for a non-NULL pointer (which may be in the form of an assertion).
If someone's static analysis tool starts complaining about it, I'd be happy to consider adding an assert... -- Regards, Benjamin
On Monday 04 July 2011, Benjamin Peterson wrote:
If someone's static analysis tool starts complaining about it, I'd be happy to consider adding an assert...
Here is one! To me an assertion is what actually documents that you don't expect NULL in this context and that the missing check is not an oversight. +1 for assert() Uli ************************************************************************************** Domino Laser GmbH, Fangdieckstraße 75a, 22547 Hamburg, Deutschland Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 ************************************************************************************** Visit our website at http://www.dominolaser.com ************************************************************************************** Diese E-Mail einschließlich sämtlicher Anhänge ist nur für den Adressaten bestimmt und kann vertrauliche Informationen enthalten. Bitte benachrichtigen Sie den Absender umgehend, falls Sie nicht der beabsichtigte Empfänger sein sollten. Die E-Mail ist in diesem Fall zu löschen und darf weder gelesen, weitergeleitet, veröffentlicht oder anderweitig benutzt werden. E-Mails können durch Dritte gelesen werden und Viren sowie nichtautorisierte Änderungen enthalten. Domino Laser GmbH ist für diese Folgen nicht verantwortlich. **************************************************************************************
participants (3)
-
Benjamin Peterson -
Nick Coghlan -
Ulrich Eckhardt