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

Re: [PATCH v2 1/2] submodule: port submodule subcommand 'sync' from shell to C

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 11, 2018, 20:31 UTC
Message-ID
<xmqqshbcxhla.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20180111201721.25930-2-pc44800@gmail.com>
Prathamesh Chavan <pc44800@gmail.com> writes:
Show 14 quoted lines
> +		} else {
> +			sub_origin_url = xstrdup(sub->url);
> +			super_config_url = xstrdup(sub->url);
> +		}
> +	} else {
> +		sub_origin_url = "";
> +		super_config_url = "";
> +	}
> + ...
> +cleanup:
> +	if (strlen(super_config_url))
> +		free(super_config_url);
> +	if (strlen(sub_origin_url))
> +		free(sub_origin_url);

The above is ugly and veriy likely to be wrong; imagine that sub->url was an empty string to begin with.

Doing xstrdup("") before assigning the constant to *_url would be a lot more sensible and maintainable solution for things like this.

Previous: Prathamesh ChavanNext: Junio C Hamano
Message 14 of 19 in “Incremental rewrite of git-submodules”
  1. 0/2 Incremental rewrite of git-submodulesPrathamesh Chavan, Jan 9, 2018
  2. 1/2 submodule: port submodule subcommand 'sync' from shell to CPrathamesh Chavan, Jan 9, 2018
  3. Junio C HamanoJan 9, 2018
  4. 2/2 submodule: port submodule subcommand 'deinit' from shell to CPrathamesh Chavan, Jan 9, 2018
  5. Junio C HamanoJan 9, 2018
  6. Prathamesh ChavanJan 10, 2018
  7. Junio C HamanoJan 10, 2018
  8. Stefan BellerJan 9, 2018
  9. Brandon WilliamsJan 9, 2018
  10. 0/2 Incremental rewrite of git-submodulesPrathamesh Chavan, Jan 11, 2018
  11. 2/2 submodule: port submodule subcommand 'deinit' from shell to CPrathamesh Chavan, Jan 11, 2018
  12. Junio C HamanoJan 11, 2018
  13. 1/2 submodule: port submodule subcommand 'sync' from shell to CPrathamesh Chavan, Jan 11, 2018
  14. Junio C HamanoJan 11, 2018
  15. Junio C HamanoJan 11, 2018
  16. 0/2 Incremental rewrite of git-submodulesPrathamesh Chavan, Jan 14, 2018
  17. 1/2 submodule: port submodule subcommand 'sync' from shell to CPrathamesh Chavan, Jan 14, 2018
  18. 2/2 submodule: port submodule subcommand 'deinit' from shell to CPrathamesh Chavan, Jan 14, 2018
  19. Junio C HamanoJan 16, 2018

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.