git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fast-import: Remove redundant assignment of 'oe' to itself.

From
Stefan Beller <stefanbeller@googlemail.com>
Date
May 26, 2013, 20:14 UTC
Message-ID
<51A26D0D.2030702@googlemail.com>
In-Reply-To
<51A26BB7.3060702@gmail.com>

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:
Show 29 quoted lines
> 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
> 
Previous: Stefano LattariniNext: Stefano Lattarini
Message 3 of 6 in “fast-import: Remove redundant assignment of 'oe' to itself.”
  1. fast-import: Remove redundant assignment of 'oe' to itself.Stefan Beller, May 26, 2013
  2. Stefano LattariniMay 26, 2013
  3. Stefan BellerMay 26, 2013
  4. Stefano LattariniMay 26, 2013
  5. Stefan BellerMay 26, 2013
  6. Joachim SchmitzMay 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.