Re: [PATCH 04/15] Set _O_BINARY as default fmode for both MinGW and MSVC

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

 



Alexey Borzenkov schrieb:
> Searching which executables set _fmode and which don't I found the
> culprit. test-genrandom.c didn't include git-compat-util.h, so mingw.h
> was never included. This caused different random data to be generated,
> and as it seems more importantly, of different sizes. Can be fixed
> with this patch:
> 
> diff --git a/test-genrandom.c b/test-genrandom.c
> index 8ad276d..b3c28d9 100644
> --- a/test-genrandom.c
> +++ b/test-genrandom.c
> @@ -4,8 +4,7 @@
>   * Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
>   */
> 
> -#include <stdio.h>
> -#include <stdlib.h>
> +#include "git-compat-util.h"
> 
>  int main(int argc, char *argv[])
>  {

Thanks for digging this out. With this change, the t5302 passes again.

I verified that the SHA1s that are generated with this fix are identical
to those that are generated on Linux. (And without this fix they are
different.)

Just for the records: The reason why including git-compat-util.h was not
necessary before 04/15 is that test-genrandom is linked against libgit.a.
This way the startup code had picked up the definition of _CRT_fmode from
mingw.c that is initialized to _O_BINARY. After the original 04/15 this
symbol was not present anymore in libgit.a, and the default (text mode)
was used. And with this fix, main() is overridden to explicitly set the
mode of stdout to _O_BINARY.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]