Utilise cliptom() macro

This commit is contained in:
stefanrueger
2026-08-19 07:39:01 +02:00
parent a0f5c47bc0
commit 584368df84
3 changed files with 5 additions and 5 deletions

View File

@@ -1508,7 +1508,7 @@ static size_t qwertydist(size_t w, unsigned char c1, unsigned char c2) {
ret += sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))/2.5*w;
return ret > w? w: ret < 1? 1: ret;
return cliptom(ret, 1, w);
}
// Substitution cost considering qwerty keyboard typos and case

View File

@@ -375,7 +375,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc,
toread = maxsize - whence;
int gap = maxsize - whence - toread;
after = gap > 16? 16: gap < 0? 0: gap;
after = cliptom(gap, 0, 16);
toread += after;
if(toread - before < 2) // Cannot disassemble just one byte
goto nocontent;
@@ -3064,7 +3064,7 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int
cx->term_header = mmt_strdup(hdr);
}
percent = percent > 100? 100: percent < 0? 0: percent;
percent = cliptom(percent, 0, 100);
if(cx->term_tty_todo) {
if(!cx->term_header)
@@ -3095,7 +3095,7 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int
static void update_progress_no_tty(int percent, double etime, const char *hdr, int finish) {
setvbuf(stderr, (char *) NULL, _IONBF, 0);
percent = percent > 100? 100: percent < 0? 0: percent;
percent = cliptom(percent, 0, 100);
if(hdr) {
lmsg_info("%s | ", hdr);

View File

@@ -425,7 +425,7 @@ static int rawuartbrr(const Avrintel *up, long f_cpu, long br, int nsamples) {
static int uartbrr(const Avrintel *up, long f_cpu, long br, int nsamples) {
int ret = rawuartbrr(up, f_cpu, br, nsamples), mxb = maxbrr(up);
return ret < 0? 0: ret > mxb? mxb: ret;
return cliptom(ret, 0, mxb);
}
// Actual baud rate given f_cpu, desired baud rated and number 8..63 of samples