{"thread":{"id":"33943","subject":"[PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","startedAt":"2013-05-26T20:05:19Z","lastAt":"2013-05-28T08:22:05Z","messageCount":6,"participants":["Stefan Beller","Stefano Lattarini","Joachim Schmitz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"218580","messageId":"1369598719-10798-1-git-send-email-stefanbeller@googlemail.com","threadId":"33943","inReplyTo":null,"subject":"[PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Stefan Beller","fromEmail":"stefanbeller@googlemail.com","sentAt":"2013-05-26T20:05:19Z","receivedAt":"2013-05-26T20:05:19Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reported by cppcheck.\n\nSigned-off-by: Stefan Beller <stefanbeller@googlemail.com>\n---\n fast-import.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 5f539d7..0142e3a 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n static void parse_cat_blob(void)\n {\n \tconst char *p;\n-\tstruct object_entry *oe = oe;\n+\tstruct object_entry *oe;\n \tunsigned char sha1[20];\n \n \t/* cat-blob SP <object> LF */\n-- \n1.8.3\n"},{"id":"218581","messageId":"51A26BB7.3060702@gmail.com","threadId":"33943","inReplyTo":"1369598719-10798-1-git-send-email-stefanbeller@googlemail.com","subject":"Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Stefano Lattarini","fromEmail":"stefano.lattarini@gmail.com","sentAt":"2013-05-26T20:08:23Z","receivedAt":"2013-05-26T20:08:23Z","isPatch":true,"sender":{"key":"stefano.lattarini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1429199?v=4"},"body":"On 05/26/2013 10:05 PM, Stefan Beller wrote:\n> Reported by cppcheck.\n> \n> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>\n> ---\n>  fast-import.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/fast-import.c b/fast-import.c\n> index 5f539d7..0142e3a 100644\n> --- a/fast-import.c\n> +++ b/fast-import.c\n> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n>  static void parse_cat_blob(void)\n>  {\n>  \tconst char *p;\n> -\tstruct object_entry *oe = oe;\n>\nThis was done on purpose, to avoid spurious warnings with (at least)\nsome versions of GCC.\n\n> +\tstruct object_entry *oe;\n>  \tunsigned char sha1[20];\n>  \n>  \t/* cat-blob SP <object> LF */\n\nRegards,\n  Stefano\n"},{"id":"218582","messageId":"51A26D0D.2030702@googlemail.com","threadId":"33943","inReplyTo":"51A26BB7.3060702@gmail.com","subject":"Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Stefan Beller","fromEmail":"stefanbeller@googlemail.com","sentAt":"2013-05-26T20:14:05Z","receivedAt":"2013-05-26T20:14:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"It's not done very often.\nFor example at the very same place of the patch there is\nconst char *p; not assigned.\n\nWell you could argue, that it can be detected by gcc as that variable p\nis assigned next line.\nSo another counterexample, having the same pattern would be\nfast-import.c line 2992 in parse_treeish_dataref(const char **p)\nthere we have a pointer to a struct, which is only assigned inside\nthe following if/else branches.\nThen that place would need to be fixed up to\nstruct object_entry *e = e;\n\nRegards,\nStefan\n\nOn 05/26/2013 10:08 PM, Stefano Lattarini wrote:\n> On 05/26/2013 10:05 PM, Stefan Beller wrote:\n>> Reported by cppcheck.\n>>\n>> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>\n>> ---\n>>  fast-import.c | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/fast-import.c b/fast-import.c\n>> index 5f539d7..0142e3a 100644\n>> --- a/fast-import.c\n>> +++ b/fast-import.c\n>> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n>>  static void parse_cat_blob(void)\n>>  {\n>>  \tconst char *p;\n>> -\tstruct object_entry *oe = oe;\n>>\n> This was done on purpose, to avoid spurious warnings with (at least)\n> some versions of GCC.\n> \n>> +\tstruct object_entry *oe;\n>>  \tunsigned char sha1[20];\n>>  \n>>  \t/* cat-blob SP <object> LF */\n> \n> Regards,\n>   Stefano\n> \n"},{"id":"218583","messageId":"51A26DBD.80106@gmail.com","threadId":"33943","inReplyTo":"51A26D0D.2030702@googlemail.com","subject":"Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Stefano Lattarini","fromEmail":"stefano.lattarini@gmail.com","sentAt":"2013-05-26T20:17:01Z","receivedAt":"2013-05-26T20:17:01Z","isPatch":true,"sender":{"key":"stefano.lattarini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1429199?v=4"},"body":"On 05/26/2013 10:14 PM, Stefan Beller wrote:\n> It's not done very often.\n>\nOf course; it's done only in those places where GCC gave spurious\nwarnings.  And it's done for no other reason that to silence said\nwarnings.\n\n> [SNIP] rest of message\n\nRegards,\n  Stefano\n"},{"id":"218584","messageId":"51A26F44.4020406@googlemail.com","threadId":"33943","inReplyTo":"51A26DBD.80106@gmail.com","subject":"Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Stefan Beller","fromEmail":"stefanbeller@googlemail.com","sentAt":"2013-05-26T20:23:32Z","receivedAt":"2013-05-26T20:23:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The line in question was not fixed up, but originally added in\n85c6239. However I see your point, it may reintroduce warnings.\n\nRegards,\nStefan\n\nOn 05/26/2013 10:17 PM, Stefano Lattarini wrote:\n> On 05/26/2013 10:14 PM, Stefan Beller wrote:\n>> It's not done very often.\n>>\n> Of course; it's done only in those places where GCC gave spurious\n> warnings.  And it's done for no other reason that to silence said\n> warnings.\n> \n>> [SNIP] rest of message\n> \n> Regards,\n>   Stefano\n> \n"},{"id":"218634","messageId":"ko1pfi$7f6$1@ger.gmane.org","threadId":"33943","inReplyTo":"51A26BB7.3060702@gmail.com","subject":"Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2013-05-28T08:22:05Z","receivedAt":"2013-05-28T08:22:05Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Stefano Lattarini wrote:\n> On 05/26/2013 10:05 PM, Stefan Beller wrote:\n>> Reported by cppcheck.\n>>\n>> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>\n>> ---\n>>  fast-import.c | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/fast-import.c b/fast-import.c\n>> index 5f539d7..0142e3a 100644\n>> --- a/fast-import.c\n>> +++ b/fast-import.c\n>> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe,\n>>  unsigned char sha1[20]) static void parse_cat_blob(void)\n>>  {\n>>  const char *p;\n>> - struct object_entry *oe = oe;\n>>\n> This was done on purpose, to avoid spurious warnings with (at least)\n> some versions of GCC.\n>\n>> + struct object_entry *oe;\n>>  unsigned char sha1[20];\n>>\n>>  /* cat-blob SP <object> LF */\n>\n\nThis strange construct has been removed in other places meanwhile. It is \nviolating C-standards (C89, C99) and as such causes warnings with other \ncompilers, so this is fighting fire with fire. As it is a pointer it may be \nmore sensible to initialize with NULL, should appease all compilers and \nstill be correct.\n\nBye, Jojo \n"}]}