{"thread":{"id":"34517","subject":"[PATCH] open_istream: remove unneeded check for null pointer","startedAt":"2013-07-23T13:16:04Z","lastAt":"2013-07-23T13:16:04Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"223978","messageId":"1374585364-12159-1-git-send-email-stefanbeller@googlemail.com","threadId":"34517","inReplyTo":null,"subject":"[PATCH] open_istream: remove unneeded check for null pointer","fromName":"Stefan Beller","fromEmail":"stefanbeller@googlemail.com","sentAt":"2013-07-23T13:16:04Z","receivedAt":"2013-07-23T13:16:04Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"'st' is allocated via xmalloc a few lines before and passed to\nthe stream opening functions.\nThe xmalloc function is written in a way that either 'st' is allocated\nvalid memory or xmalloc already dies.\nThe function calls to open_istream_* do not change 'st', as the pointer is\npassed by reference and not a pointer of a pointer.\n\nHence 'st' cannot be null at that part of the code.\n\nSigned-off-by: Stefan Beller <stefanbeller@googlemail.com>\n---\n streaming.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/streaming.c b/streaming.c\nindex acc07a6..debe904 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -144,17 +144,17 @@ struct git_istream *open_istream(const unsigned char *sha1,\n \n \tst = xmalloc(sizeof(*st));\n \tif (open_istream_tbl[src](st, &oi, real, type)) {\n \t\tif (open_istream_incore(st, &oi, real, type)) {\n \t\t\tfree(st);\n \t\t\treturn NULL;\n \t\t}\n \t}\n-\tif (st && filter) {\n+\tif (filter) {\n \t\t/* Add \"&& !is_null_stream_filter(filter)\" for performance */\n \t\tstruct git_istream *nst = attach_stream_filter(st, filter);\n \t\tif (!nst)\n \t\t\tclose_istream(st);\n \t\tst = nst;\n \t}\n \n \t*size = st->size;\n-- \n1.8.3.3.1135.ge2c9e63\n"}]}