Re: [PATCH v2 1/3] merge-base, xdiff: zero out xpparam_t structures
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 12, 2020, 11:14 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2010121313020.50@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20201012091751.19594-2-michal@isc.org>
Hi Michał,
On Mon, 12 Oct 2020, Michał Kępień wrote:
Show 10 quoted lines
> diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
> index c7b35a9667..e694bfd9e3 100644
> --- a/xdiff/xhistogram.c
> +++ b/xdiff/xhistogram.c
> @@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
> int line1, int count1, int line2, int count2)
> {
> xpparam_t xpparam;
> +
> + memset(&xpparam, 0, sizeof(xpparam));A slightly more elegant way to do this would be
xpparam_t xpparam = { 0l };Or even
xpparam_t xpparam = XPPARAM_T_INIT;
with
#define XPPARAM_T_INIT { 0l, NULL, 0 }in `xdiff/xdiff.h`.
Thanks, Dscho
Show 21 quoted lines
> xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
>
> return xdl_fall_back_diff(env, &xpparam,
> diff --git a/xdiff/xpatience.c b/xdiff/xpatience.c
> index 3c5601b602..20699a6f60 100644
> --- a/xdiff/xpatience.c
> +++ b/xdiff/xpatience.c
> @@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map,
> int line1, int count1, int line2, int count2)
> {
> xpparam_t xpp;
> +
> + memset(&xpp, 0, sizeof(xpp));
> xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
>
> return xdl_fall_back_diff(map->env, &xpp,
> --
> 2.28.0
>
>
>