mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-10 16:54:08 -05:00
xdiff: use unambiguous types in xdl_bogo_sqrt()
There is no real square root for a negative number and size_t may not be large enough for certain applications, replace long with uint64_t. Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
da1a90eab0
commit
e85a4167dd
@@ -348,7 +348,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
kvdf += xe->xdf2.nreff + 1;
|
||||
kvdb += xe->xdf2.nreff + 1;
|
||||
|
||||
xenv.mxcost = xdl_bogosqrt(ndiags);
|
||||
xenv.mxcost = (long)xdl_bogosqrt((uint64_t)ndiags);
|
||||
if (xenv.mxcost < XDL_MAX_COST_MIN)
|
||||
xenv.mxcost = XDL_MAX_COST_MIN;
|
||||
xenv.snake_cnt = XDL_SNAKE_CNT;
|
||||
|
||||
@@ -290,7 +290,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
|
||||
/*
|
||||
* Initialize temporary arrays with DISCARD, KEEP, or INVESTIGATE.
|
||||
*/
|
||||
if ((mlim = xdl_bogosqrt((long)xdf1->nrec)) > XDL_MAX_EQLIMIT)
|
||||
if ((mlim = (long)xdl_bogosqrt((uint64_t)xdf1->nrec)) > XDL_MAX_EQLIMIT)
|
||||
mlim = XDL_MAX_EQLIMIT;
|
||||
for (i = xdf1->dstart; i <= xdf1->dend; i++) {
|
||||
size_t mph1 = xdf1->recs[i].minimal_perfect_hash;
|
||||
@@ -299,7 +299,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
|
||||
action1[i] = (nm == 0) ? DISCARD: (nm >= mlim && !need_min) ? INVESTIGATE: KEEP;
|
||||
}
|
||||
|
||||
if ((mlim = xdl_bogosqrt((long)xdf2->nrec)) > XDL_MAX_EQLIMIT)
|
||||
if ((mlim = (long)xdl_bogosqrt((uint64_t)xdf2->nrec)) > XDL_MAX_EQLIMIT)
|
||||
mlim = XDL_MAX_EQLIMIT;
|
||||
for (i = xdf2->dstart; i <= xdf2->dend; i++) {
|
||||
size_t mph2 = xdf2->recs[i].minimal_perfect_hash;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "xinclude.h"
|
||||
|
||||
|
||||
long xdl_bogosqrt(long n) {
|
||||
long i;
|
||||
uint64_t xdl_bogosqrt(uint64_t n) {
|
||||
uint64_t i;
|
||||
|
||||
/*
|
||||
* Classical integer square root approximation using shifts.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
|
||||
long xdl_bogosqrt(long n);
|
||||
uint64_t xdl_bogosqrt(uint64_t n);
|
||||
int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,
|
||||
xdemitcb_t *ecb);
|
||||
int xdl_cha_init(chastore_t *cha, long isize, long icount);
|
||||
|
||||
Reference in New Issue
Block a user