* [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
@ 2013-05-26 20:05 Stefan Beller
2013-05-26 20:08 ` Stefano Lattarini
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Beller @ 2013-05-26 20:05 UTC (permalink / raw)
To: David Barr, Junio C Hamano, git; +Cc: Stefan Beller
Reported by cppcheck.
Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
---
fast-import.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fast-import.c b/fast-import.c
index 5f539d7..0142e3a 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])
static void parse_cat_blob(void)
{
const char *p;
- struct object_entry *oe = oe;
+ struct object_entry *oe;
unsigned char sha1[20];
/* cat-blob SP <object> LF */
--
1.8.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
2013-05-26 20:05 [PATCH] fast-import: Remove redundant assignment of 'oe' to itself Stefan Beller
@ 2013-05-26 20:08 ` Stefano Lattarini
2013-05-26 20:14 ` Stefan Beller
2013-05-28 8:22 ` Joachim Schmitz
0 siblings, 2 replies; 6+ messages in thread
From: Stefano Lattarini @ 2013-05-26 20:08 UTC (permalink / raw)
To: Stefan Beller; +Cc: David Barr, Junio C Hamano, git
On 05/26/2013 10:05 PM, Stefan Beller wrote:
> Reported by cppcheck.
>
> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
> ---
> fast-import.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fast-import.c b/fast-import.c
> index 5f539d7..0142e3a 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])
> static void parse_cat_blob(void)
> {
> const char *p;
> - struct object_entry *oe = oe;
>
This was done on purpose, to avoid spurious warnings with (at least)
some versions of GCC.
> + struct object_entry *oe;
> unsigned char sha1[20];
>
> /* cat-blob SP <object> LF */
Regards,
Stefano
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
2013-05-26 20:08 ` Stefano Lattarini
@ 2013-05-26 20:14 ` Stefan Beller
2013-05-26 20:17 ` Stefano Lattarini
2013-05-28 8:22 ` Joachim Schmitz
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Beller @ 2013-05-26 20:14 UTC (permalink / raw)
To: Stefano Lattarini; +Cc: David Barr, Junio C Hamano, git
It's not done very often.
For example at the very same place of the patch there is
const char *p; not assigned.
Well you could argue, that it can be detected by gcc as that variable p
is assigned next line.
So another counterexample, having the same pattern would be
fast-import.c line 2992 in parse_treeish_dataref(const char **p)
there we have a pointer to a struct, which is only assigned inside
the following if/else branches.
Then that place would need to be fixed up to
struct object_entry *e = e;
Regards,
Stefan
On 05/26/2013 10:08 PM, Stefano Lattarini wrote:
> On 05/26/2013 10:05 PM, Stefan Beller wrote:
>> Reported by cppcheck.
>>
>> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
>> ---
>> fast-import.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fast-import.c b/fast-import.c
>> index 5f539d7..0142e3a 100644
>> --- a/fast-import.c
>> +++ b/fast-import.c
>> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])
>> static void parse_cat_blob(void)
>> {
>> const char *p;
>> - struct object_entry *oe = oe;
>>
> This was done on purpose, to avoid spurious warnings with (at least)
> some versions of GCC.
>
>> + struct object_entry *oe;
>> unsigned char sha1[20];
>>
>> /* cat-blob SP <object> LF */
>
> Regards,
> Stefano
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
2013-05-26 20:14 ` Stefan Beller
@ 2013-05-26 20:17 ` Stefano Lattarini
2013-05-26 20:23 ` Stefan Beller
0 siblings, 1 reply; 6+ messages in thread
From: Stefano Lattarini @ 2013-05-26 20:17 UTC (permalink / raw)
To: Stefan Beller; +Cc: David Barr, Junio C Hamano, git
On 05/26/2013 10:14 PM, Stefan Beller wrote:
> It's not done very often.
>
Of course; it's done only in those places where GCC gave spurious
warnings. And it's done for no other reason that to silence said
warnings.
> [SNIP] rest of message
Regards,
Stefano
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
2013-05-26 20:17 ` Stefano Lattarini
@ 2013-05-26 20:23 ` Stefan Beller
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Beller @ 2013-05-26 20:23 UTC (permalink / raw)
To: Stefano Lattarini; +Cc: Junio C Hamano, git
The line in question was not fixed up, but originally added in
85c6239. However I see your point, it may reintroduce warnings.
Regards,
Stefan
On 05/26/2013 10:17 PM, Stefano Lattarini wrote:
> On 05/26/2013 10:14 PM, Stefan Beller wrote:
>> It's not done very often.
>>
> Of course; it's done only in those places where GCC gave spurious
> warnings. And it's done for no other reason that to silence said
> warnings.
>
>> [SNIP] rest of message
>
> Regards,
> Stefano
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.
2013-05-26 20:08 ` Stefano Lattarini
2013-05-26 20:14 ` Stefan Beller
@ 2013-05-28 8:22 ` Joachim Schmitz
1 sibling, 0 replies; 6+ messages in thread
From: Joachim Schmitz @ 2013-05-28 8:22 UTC (permalink / raw)
To: git
Stefano Lattarini wrote:
> On 05/26/2013 10:05 PM, Stefan Beller wrote:
>> Reported by cppcheck.
>>
>> Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
>> ---
>> fast-import.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fast-import.c b/fast-import.c
>> index 5f539d7..0142e3a 100644
>> --- a/fast-import.c
>> +++ b/fast-import.c
>> @@ -2914,7 +2914,7 @@ static void cat_blob(struct object_entry *oe,
>> unsigned char sha1[20]) static void parse_cat_blob(void)
>> {
>> const char *p;
>> - struct object_entry *oe = oe;
>>
> This was done on purpose, to avoid spurious warnings with (at least)
> some versions of GCC.
>
>> + struct object_entry *oe;
>> unsigned char sha1[20];
>>
>> /* cat-blob SP <object> LF */
>
This strange construct has been removed in other places meanwhile. It is
violating C-standards (C89, C99) and as such causes warnings with other
compilers, so this is fighting fire with fire. As it is a pointer it may be
more sensible to initialize with NULL, should appease all compilers and
still be correct.
Bye, Jojo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-28 8:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-26 20:05 [PATCH] fast-import: Remove redundant assignment of 'oe' to itself Stefan Beller
2013-05-26 20:08 ` Stefano Lattarini
2013-05-26 20:14 ` Stefan Beller
2013-05-26 20:17 ` Stefano Lattarini
2013-05-26 20:23 ` Stefan Beller
2013-05-28 8:22 ` Joachim Schmitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).