Re: [PATCH 03/10] fast-export: store anonymized oids as hex strings

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

 



On Tue, Jun 23, 2020 at 11:24:51AM -0400, Jeff King wrote:

> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> index 289395a131..4a3a4c933e 100644
> --- a/builtin/fast-export.c
> +++ b/builtin/fast-export.c
> @@ -387,16 +387,19 @@ static void *generate_fake_oid(const void *old, size_t *len)
>  {
>  	static uint32_t counter = 1; /* avoid null oid */
>  	const unsigned hashsz = the_hash_algo->rawsz;
> -	unsigned char *out = xcalloc(hashsz, 1);
> -	put_be32(out + hashsz - 4, counter++);
> -	return out;
> +	struct object_id oid;
> +	char *hex = xmallocz(GIT_MAX_HEXSZ);
> +
> +	oidclr(&oid);
> +	put_be32(oid.hash + hashsz - 4, counter++);
> +	return oid_to_hex_r(hex, &oid);
>  }

GCC 4.8 complains about this change in our CI job:

  $ make CC=gcc-4.8 builtin/fast-export.o
      CC builtin/fast-export.o
  builtin/fast-export.c: In function ‘generate_fake_oid’:
  builtin/fast-export.c:394:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
    put_be32(oid.hash + hashsz - 4, counter++);
    ^
  cc1: all warnings being treated as errors





[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