Re: [PATCH v6 1/5] common-main: split init and exit code into new files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Josh Steadmon <steadmon@xxxxxxxxxx> writes:

> This split has previously been proposed ([1], [2]) to support fuzz tests
> and unit tests by avoiding conflicting definitions for main(). However,
> both of those issues were resolved by other methods of avoiding symbol
> conflicts. Now we are trying to make libgit.a more self-contained, so
> hopefully we can revisit this approach.

Yay!

> Additionally, move the initialization code out of main() into a new
> init_git() function in its own file. Include this in libgit.a as well,
> so that external users can share our setup code without calling our
> main().

Sounds good.

> diff --git a/common-main.c b/common-main.c
> index 8e68ac9e42..6b7ab077b0 100644
> --- a/common-main.c
> +++ b/common-main.c
> @@ -1,92 +1,13 @@
> ...
> +#include "common-init.h"
>  
>  int main(int argc, const char **argv)
>  {
>  	int result;
>  
> +	init_git(argv);
>  	result = cmd_main(argc, argv);
>  
>  	/* Not exit(3), but a wrapper calling our common_exit() */
>  	exit(result);
>  }

Nice.  Very nice.  I wasn't too carefully validating what we lost
here is identical to what we added to init_git(), but hopefully
others would spot and stop us if that is not the case.

Thanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux